From 0e7645da79d14140d23ddd9c3127f966a59c0042 Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Sat, 26 Mar 2022 23:19:50 +0000 Subject: [PATCH] Use calculated amount for multiple event participant registration. This allows use to use paymentIntent instead of setupIntent which means that cards requiring 3DSs will not fail for multiple event participant registration --- CRM/Core/Payment/Stripe.php | 19 ------------------- js/civicrm_stripe.js | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/CRM/Core/Payment/Stripe.php b/CRM/Core/Payment/Stripe.php index b30472ce..c1097c44 100644 --- a/CRM/Core/Payment/Stripe.php +++ b/CRM/Core/Payment/Stripe.php @@ -624,25 +624,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment { // save card functionality but should not save by default as the customer has not agreed. return $this->doRecurPayment($propertyBag, $amountFormattedForStripe, $stripeCustomer); } - elseif ($this->isPaymentForEventAdditionalParticipants($propertyBag)) { - // We're processing an event registration for multiple participants - because we did not know - // the amount until now we process via a saved paymentMethod. - $intent = $this->stripeClient->paymentIntents->create([ - 'payment_method' => $paymentMethodID, - 'customer' => $stripeCustomer->id, - 'amount' => $amountFormattedForStripe, - 'currency' => $this->getCurrency($params), - 'confirmation_method' => 'automatic', - 'capture_method' => 'manual', - // authorize the amount but don't take from card yet - 'setup_future_usage' => 'off_session', - // Setup the card to be saved and used later - 'confirm' => true, - ]); - - $propertyBag->setCustomProperty('paymentIntentID', $intent->id); - $params['paymentIntentID'] = $intent->id; - } // @fixme FROM HERE we are using $params ONLY - SET things if required ($propertyBag is not used beyond here) // Note that we set both $propertyBag and $params paymentIntentID in the case of participants above diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js index 0f5a4273..ecfb7c54 100644 --- a/js/civicrm_stripe.js +++ b/js/civicrm_stripe.js @@ -116,7 +116,7 @@ if (totalAmount) { totalAmount = totalAmount.toFixed(2); } - if (CRM.payment.getIsRecur() || CRM.payment.isEventAdditionalParticipants() || (totalAmount === null)) { + if (CRM.payment.getIsRecur() || (totalAmount === null)) { CRM.api3('StripePaymentintent', 'Process', { setup: true, payment_method_id: createPaymentMethodResult.paymentMethod.id, -- GitLab