From 48cb708406c6fb701a9011b44c7f5eb2ba32e818 Mon Sep 17 00:00:00 2001
From: Matthew Wire <devel@mrwire.co.uk>
Date: Sat, 25 Nov 2017 10:37:28 +0000
Subject: [PATCH] Allow submit of a different payment processor when Stripe is
 default but not selected

---
 CRM/Core/Payment/Stripe.php |  2 +-
 js/civicrm_stripe.js        | 33 +++++++++++++++++----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/CRM/Core/Payment/Stripe.php b/CRM/Core/Payment/Stripe.php
index 427b9160..68cc7ddd 100644
--- a/CRM/Core/Payment/Stripe.php
+++ b/CRM/Core/Payment/Stripe.php
@@ -891,7 +891,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
    *
    */
   public function doTransferCheckout(&$params, $component) {
-    CRM_Core_Error::fatal(ts('Use direct billing instead of Transfer method.'));
+    self::doDirectPayment($params);
   }
 
   /**
diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js
index 899c7ccf..3d06db27 100644
--- a/js/civicrm_stripe.js
+++ b/js/civicrm_stripe.js
@@ -141,6 +141,23 @@
         return false;
       }
 
+      // Handle multiple payment options and Stripe not being chosen.
+      if ($form.find(".crm-section.payment_processor-section").length > 0) {
+        var extMode = $('#ext-mode').val();
+        var stripeProcessorId = $('#stripe-id').val();
+        var chosenProcessorId = $form.find('input[name="payment_processor_id"]:checked').val();
+
+        // Bail if we're not using Stripe or are using pay later (option value '0' in payment_processor radio group).
+        if ((chosenProcessorId !== stripeProcessorId) || (chosenProcessorId === 0)) {
+          debugging('debug: Not a Stripe transaction, or pay-later');
+          $form.get(0).submit();
+          return true;
+        }
+      }
+      else {
+        debugging('debug: Stripe is the selected payprocessor');
+      }
+
       $form = getBillingForm();
 
       // Don't handle submits generated by non-stripe processors
@@ -192,22 +209,6 @@
       // Disable the submit button to prevent repeated clicks
       $submit.prop('disabled', true);
 
-      // Handle multiple payment options and Stripe not being chosen.
-      if ($form.find(".crm-section.payment_processor-section").length > 0) {
-        var extMode = $('#ext-mode').val();
-        var stripeProcessorId = $('#stripe-id').val();
-        var chosenProcessorId = $form.find('input[name="payment_processor_id"]:checked').val();
-
-        // Bail if we're not using Stripe or are using pay later (option value '0' in payment_processor radio group).
-        if ((chosenProcessorId !== stripeProcessorId) || (chosenProcessorId === 0)) {
-          debugging('debug: Not a Stripe transaction, or pay-later');
-          return true;
-        }
-      }
-      else {
-        debugging('debug: Stripe is the selected payprocessor');
-      }
-
       // If there's no credit card field, no use in continuing (probably wrong
       // context anyway)
       if (!$form.find('#credit_card_number').length) {
-- 
GitLab