From: Matthew Wire (MJW Consulting) Date: Thu, 19 Sep 2019 14:48:17 +0000 (+0100) Subject: Fix issues with retrieving supportsTestMode/supportsLiveMode for payment processors X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=95863863e62b5272a5be0dc0be916d1e7e659d1b;p=civicrm-core.git Fix issues with retrieving supportsTestMode/supportsLiveMode for payment processors --- diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 04be631bb1..7469609f7f 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -372,19 +372,12 @@ WHERE contribution_id = {$id} } $this->_processors = []; foreach ($this->_paymentProcessors as $id => $processor) { - // @todo review this. The inclusion of this IF was to address test processors being incorrectly loaded. - // However the function $this->getValidProcessors() is expected to only return the processors relevant - // to the mode (using the actual id - ie. the id of the test processor for the test processor). - // for some reason there was a need to filter here per commit history - but this indicates a problem - // somewhere else. - if ($processor['is_test'] == ($this->_mode == 'test')) { - $this->_processors[$id] = $processor['name']; - if (!empty($processor['description'])) { - $this->_processors[$id] .= ' : ' . $processor['description']; - } - if ($processor['is_recur']) { - $this->_recurPaymentProcessors[$id] = $this->_processors[$id]; - } + $this->_processors[$id] = $processor['name']; + if (!empty($processor['description'])) { + $this->_processors[$id] .= ' : ' . $processor['description']; + } + if ($processor['is_recur']) { + $this->_recurPaymentProcessors[$id] = $this->_processors[$id]; } } // CRM-21002: pass the default payment processor ID whose credit card type icons should be populated first diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 5eb5167b31..782f72ca44 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -776,10 +776,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @throws \CRM_Core_Exception */ protected function assignPaymentProcessor($isPayLaterEnabled) { - $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors( - [ucfirst($this->_mode) . 'Mode'], - $this->_paymentProcessorIDs - ); + $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors([ucfirst($this->_mode) . 'Mode'], $this->_paymentProcessorIDs); if ($isPayLaterEnabled) { $this->_paymentProcessors[0] = CRM_Financial_BAO_PaymentProcessor::getPayment(0); } diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 1af72a2301..18d89d9589 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -354,7 +354,7 @@ abstract class CRM_Core_Payment { * @return bool */ protected function supportsLiveMode() { - return TRUE; + return empty($this->_paymentProcessor['is_test']) ? TRUE : FALSE; } /** @@ -363,7 +363,7 @@ abstract class CRM_Core_Payment { * @return bool */ protected function supportsTestMode() { - return TRUE; + return empty($this->_paymentProcessor['is_test']) ? FALSE : TRUE; } /** diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index d7c39838ee..e0a079a8f1 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -132,17 +132,6 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { return $params; } - /** - * Are back office payments supported. - * - * E.g paypal standard won't permit you to enter a credit card associated with someone else's login. - * - * @return bool - */ - protected function supportsLiveMode() { - return TRUE; - } - /** * Does this payment processor support refund? * diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 65dae3da36..b2508ec865 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -379,8 +379,8 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * available processors */ public static function getPaymentProcessors($capabilities = [], $ids = FALSE) { - $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : []; if (is_array($ids)) { + $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : []; $processors = self::getAllPaymentProcessors('all', FALSE, FALSE); if (in_array('TestMode', $capabilities)) { $possibleLiveIDs = array_diff($ids, array_keys($testProcessors));