diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index 145df4f9e94..8c6753db54b 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -662,7 +662,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
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');
}
}
@@ -864,25 +864,6 @@ if (! $source)
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 +955,6 @@ if ($source == 'order')
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 +1082,6 @@ if ($source == 'invoice')
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 +1292,6 @@ if ($source == 'contractline')
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 +1458,6 @@ if ($source == 'membersubscription')
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 +1599,6 @@ if ($source == 'donation')
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 +1640,7 @@ print ''."\n";
print "\n";
+// Show all payment mode buttons (Stripe, Paypal, ...)
if ($action != 'dopayment')
{
if ($found && ! $error) // We are in a management option and no error
@@ -1833,7 +1716,7 @@ print '
';
// 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 +1771,27 @@ if (preg_match('/^dopayment/', $action))
print '';
print '';
+ if (! 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;
+ if (is_object($object) && is_object($object->thirdparty)) $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1);
+
+ $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 '
@@ -1949,12 +1853,75 @@ if (preg_match('/^dopayment/', $action))
}
else
{
+ // JS Code for Stripe
+ 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 '