Skip to content
Snippets Groups Projects
Commit 0e7645da authored by mattwire's avatar mattwire
Browse files

Use calculated amount for multiple event participant registration. This allows...

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
parent 85786ccc
No related branches found
No related tags found
No related merge requests found
...@@ -624,25 +624,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment { ...@@ -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. // save card functionality but should not save by default as the customer has not agreed.
return $this->doRecurPayment($propertyBag, $amountFormattedForStripe, $stripeCustomer); 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) // @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 // Note that we set both $propertyBag and $params paymentIntentID in the case of participants above
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
if (totalAmount) { if (totalAmount) {
totalAmount = totalAmount.toFixed(2); totalAmount = totalAmount.toFixed(2);
} }
if (CRM.payment.getIsRecur() || CRM.payment.isEventAdditionalParticipants() || (totalAmount === null)) { if (CRM.payment.getIsRecur() || (totalAmount === null)) {
CRM.api3('StripePaymentintent', 'Process', { CRM.api3('StripePaymentintent', 'Process', {
setup: true, setup: true,
payment_method_id: createPaymentMethodResult.paymentMethod.id, payment_method_id: createPaymentMethodResult.paymentMethod.id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment