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

Add support for enabling payments on frontend forms (via setting)

parent 0171e81c
Branches
Tags
1 merge request!238Add support for enabling payments on frontend forms (via setting)
......@@ -466,6 +466,11 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$context = \Civi\Formprotection\Forms::getContextFromQuickform($form);
}
$motoEnabled = CRM_Core_Permission::check('allow stripe moto payments')
&& (
(in_array('backend', \Civi::settings()->get('stripe_moto')) && $form->isBackOffice)
|| (in_array('frontend', \Civi::settings()->get('stripe_moto')) && !$form->isBackOffice)
);
$jsVars = [
'id' => $form->_paymentProcessor['id'],
'currency' => $this->getDefaultCurrencyForForm($form),
......@@ -476,7 +481,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'apiVersion' => CRM_Stripe_Check::API_VERSION,
'csrfToken' => NULL,
'country' => \Civi::settings()->get('stripe_country'),
'moto' => \Civi::settings()->get('stripe_moto') && ($form->isBackOffice ?? FALSE) && CRM_Core_Permission::check('allow stripe moto payments'),
'moto' => $motoEnabled,
'disablelink' => \Civi::settings()->get('stripe_cardelement_disablelink'),
];
if (class_exists('\Civi\Firewall\Firewall')) {
......
......@@ -441,4 +441,12 @@ class CRM_Stripe_Upgrader extends CRM_Extension_Upgrader_Base {
return TRUE;
}
public function upgrade_6901() {
$this->ctx->log->info('Convert MOTO setting to array');
if (\Civi::settings()->get('stripe_moto') === TRUE) {
\Civi::settings()->set('stripe_moto', ['backend']);
}
return TRUE;
}
}
......@@ -19,7 +19,6 @@ It is supported for all payment types.
If you want to take payments in this way you have to:
1. Request that it is enabled on your Stripe account.
2. Enable "MOTO payments" in CiviCRM Stripe settings.
2. Enable "MOTO payments" in CiviCRM Stripe settings (and choose if you want it enabled on backoffice and/or frontend forms).
3. Give the "CiviCRM Stripe: Process MOTO transactions" permission to roles which are allowed to process MOTO payments (eg. administrator).
It will only be available on backend forms.
......@@ -176,21 +176,30 @@ If this is empty the "suffix" will be generated by CiviCRM using the information
],
'stripe_moto' => [
'name' => 'stripe_moto',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 0,
'type' => 'Array',
'html_type' => 'Select',
'default' => [],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Enable Mail Order Telephone Order (MOTO) transactions for backoffice payments'),
'description' => E::ts('If enabled payments submitted via the backoffice forms will be treated as MOTO and will not require additional (SCA/3DSecure) customer challenges.
Do NOT enable unless you\'ve enabled this feature on your Stripe account - see <a href="%1">Stripe MOTO payments</a>', [1 => 'https://support.stripe.com/questions/mail-order-telephone-order-moto-transactions-when-to-categorize-transactions-as-moto']),
'html_attributes' => [],
'title' => E::ts('Enable Mail Order Telephone Order (MOTO) transactions'),
'description' => E::ts('If enabled a checkbox will appear below the card details which, if checked, will submit the payment as MOTO and will not require (SCA/3DSecure) customer challenges.
Do NOT enable unless you\'ve enabled this feature on your Stripe account - see <a href="%1">Stripe MOTO payments</a>.
You also need to give the permission "CiviCRM Stripe: Process MOTO transactions" to any users that should be allowed to do this - do NOT give to unprivileged users!', [1 => 'https://support.stripe.com/questions/mail-order-telephone-order-moto-transactions-when-to-categorize-transactions-as-moto']),
'html_attributes' => [
'multiple' => TRUE,
'class' => 'crm-select2',
],
'options' => [
'backend' => E::ts('Backoffice forms'),
'frontend' => E::ts('Frontend forms (contribution/event pages)'),
],
'settings_pages' => [
'stripe' => [
'weight' => 110,
]
],
],
'stripe_minamount' => [
'name' => 'stripe_minamount',
'type' => 'Integer',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment