Skip to content
Snippets Groups Projects
Commit 848172f0 authored by mattwire's avatar mattwire
Browse files

Add ACH direct debit support and disable SEPA if currency NOT EUR

parent e7a59ab0
No related branches found
No related tags found
1 merge request!217Implement Stripe Checkout (with support for SEPA and ACH)
......@@ -192,7 +192,7 @@ class CRM_Core_Payment_StripeCheckout extends CRM_Core_Payment_Stripe {
'customer' => $stripeCustomerID,
// 'submit_type' => one of 'auto', pay, book, donate
'client_reference_id' => $propertyBag->getInvoiceID(),
'payment_method_types' => \Civi::settings()->get('stripe_checkout_supported_payment_methods'),
'payment_method_types' => $this->getSupportedPaymentMethods($propertyBag),
];
// Allows you to alter the params passed to StripeCheckout (eg. payment_method_types)
......@@ -208,6 +208,33 @@ class CRM_Core_Payment_StripeCheckout extends CRM_Core_Payment_Stripe {
CRM_Utils_System::redirect($checkoutSession->url);
}
/**
* @param \Civi\Payment\PropertyBag $propertyBag
*
* @return array
*/
private function getSupportedPaymentMethods(\Civi\Payment\PropertyBag $propertyBag): array {
$paymentMethods = \Civi::settings()->get('stripe_checkout_supported_payment_methods');
$result = [];
foreach ($paymentMethods as $index => $paymentMethod) {
switch ($paymentMethod) {
case 'sepa_debit':
if ($propertyBag->getCurrency() === 'EUR') {
$result[] = $paymentMethod;
}
break;
default:
$result[] = $paymentMethod;
}
}
if (empty($result)) {
throw new PaymentProcessorException('There are no valid Stripe payment methods enabled for this configuration. Check currency etc.');
}
return $result;
}
/**
* Takes the lineitems passed into doPayment and converts them into an array suitable for passing to Stripe Checkout
*
......
......@@ -296,7 +296,7 @@ class CRM_Stripe_Api {
// 'promptpay',
'sepa_debit' => E::ts('SEPA Direct Debit'),
// 'sofort',
//'us_bank_account',
'us_bank_account' => E::ts('ACH Direct Debit'),
// 'wechat_pay',
];
}
......
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