diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index d3c26c8e65ab5..a4eee3680af53 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -10,7 +10,7 @@ ToComplete=To complete YourEMail=Email to receive payment confirmation Creditor=Creditor PaymentCode=Payment code -PayBoxDoPayment=Pay with Credit or Debit Card (Paybox) +PayBoxDoPayment=Pay with Paybox ToPay=Do payment YouWillBeRedirectedOnPayBox=You will be redirected on secured Paybox page to input you credit card information Continue=Next diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 1db01a590129f..5eb5f389445f9 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -33,3 +33,4 @@ PostActionAfterPayment=Post actions after payments ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. You must complete post actions manually if they are necessary. ValidationOfPaymentFailed=Validation of payment has failed CardOwner=Card holder +PayPalBalance=Paypal credit diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 1eb0a649a7463..91d1f5a54c5bb 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -12,7 +12,7 @@ YourEMail=Email to receive payment confirmation STRIPE_PAYONLINE_SENDEMAIL=Email notification after a payment attempt (success or fail) Creditor=Creditor PaymentCode=Payment code -StripeDoPayment=Pay with Credit or Debit Card (Stripe) +StripeDoPayment=Pay with Stripe YouWillBeRedirectedOnStripe=You will be redirected on secured Stripe page to input you credit card information Continue=Next ToOfferALinkForOnlinePayment=URL for %s payment diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 145df4f9e94b2..90646ef9b4138 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -313,8 +313,6 @@ // Other $PAYPAL_API_DEVISE="USD"; - //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; - //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; // Show var initialized by include fo paypal lib at begin of this file @@ -340,9 +338,6 @@ dol_syslog("desc: $desc", LOG_DEBUG); dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO - //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; - //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; - //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); @@ -662,7 +657,7 @@ else { // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method - // Note that with other Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. + // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); } } @@ -777,16 +772,20 @@ //print ''."\n"; // Define urllogo $urllogo=''; +$urllogofull=''; if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull=$dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); $width=150; } elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull=$dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); $width=150; } + // Output html code for logo if ($urllogo) { @@ -864,25 +863,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = null; - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum // as they don't exists (buyer is unknown, tag is free). } @@ -974,26 +954,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && empty($order->billed) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = $stripe->customerStripe($order->thirdparty, $stripeacc, $servicestatus, 1); - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.' ref='.$object->ref, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } - // Shipping address $shipToName=$order->thirdparty->name; $shipToStreet=$order->thirdparty->address; @@ -1121,25 +1081,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && ($paymentmethod == 'stripe') && empty($object->paye) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = $stripe->customerStripe($invoice->thirdparty, $stripeacc, $servicestatus, 1); - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.' ref='.$object->ref, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } - // Shipping address $shipToName=$invoice->thirdparty->name; $shipToStreet=$invoice->thirdparty->address; @@ -1350,26 +1291,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = null; - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } - // Shipping address $shipToName=$contract->thirdparty->name; $shipToStreet=$contract->thirdparty->address; @@ -1536,26 +1457,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = null; - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } - // Shipping address $shipToName=$member->getFullName($langs); $shipToStreet=$member->address; @@ -1697,26 +1598,6 @@ print ''; print ''."\n"; - if (! empty($conf->stripe->enabled) && ($paymentmethod == 'stripe') && empty($object->paid) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) - { - $service = 'StripeTest'; - $servicestatus = 0; - } - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = $stripe->customerStripe($don->thirdparty, $stripeacc, $servicestatus, 1); - - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus); - if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); - } - // Shipping address $shipToName=$don->getFullName($langs); $shipToStreet=$don->address; @@ -1758,6 +1639,7 @@ print "\n"; +// Show all payment mode buttons (Stripe, Paypal, ...) if ($action != 'dopayment') { if ($found && ! $error) // We are in a management option and no error @@ -1788,27 +1670,37 @@ if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of paybox - print '
'; + print '
'; + print '
'; + print ''.$langs->trans("CreditOrDebitCard").''; + print '
'; } if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe - print '
'; + print '
'; + print '
'; + print ''.$langs->trans("CreditOrDebitCard").''; + print '
'; } if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + print '
'; if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') { - print '
'; + print '
'; + print ''.$langs->trans("CreditOrDebitCard").' - '; + print ''.$langs->trans("PayPalBalance").''; } if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') { - print '
'; + //print '
'.$langs->trans("PaypalAccount").'">'; } + print '
'; } } } @@ -1833,7 +1725,7 @@ // Add more content on page for some services -if (preg_match('/^dopayment/', $action)) +if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment mode { // Stripe @@ -1888,6 +1780,30 @@ print ''; print ''; + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) + { + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + + $service = 'StripeLive'; + $servicestatus = 1; + + if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) + { + $service = 'StripeTest'; + $servicestatus = 0; + } + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + $stripecu = null; + if (is_object($object) && is_object($object->thirdparty)) $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); + + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus); + if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); + } + } + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) { print ' @@ -1943,18 +1859,122 @@ print ''."\n"; + + // JS Code for Stripe if (empty($stripearrayofkeys['publishable_key'])) { print info_admin($langs->trans("ErrorModuleSetupNotComplete", "stripe"), 0, 0, 'error'); } else { + print ''; print ''."\n"; // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. print '