From 52767de00f342681e117825ad004fff8d9f1fb66 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 7 Jan 2015 03:10:56 +1300 Subject: [PATCH] CRM-15771 fix inconsistencies with test vs live instances by making key more complex --- CRM/Contribute/Form/AbstractEditPayment.php | 6 +-- CRM/Core/Config.php | 2 + CRM/Core/Payment.php | 21 ++++++---- CRM/Core/Payment/AuthorizeNet.php | 21 ++++++---- CRM/Core/Payment/Dummy.php | 14 +++++-- CRM/Core/Payment/Elavon.php | 14 +++++-- CRM/Core/Payment/FirstData.php | 14 +++++-- CRM/Core/Payment/Google.php | 14 +++++-- CRM/Core/Payment/IATS.php | 15 +++++-- CRM/Core/Payment/Moneris.php | 14 +++++-- CRM/Core/Payment/PayJunction.php | 14 +++++-- CRM/Core/Payment/PayPalImpl.php | 14 +++++-- CRM/Core/Payment/PayflowPro.php | 14 +++++-- CRM/Core/Payment/PaymentExpress.php | 14 +++++-- CRM/Core/Payment/Realex.php | 14 +++++-- CRM/Core/Payment/eWAY.php | 17 +++++--- CRM/Financial/BAO/PaymentProcessor.php | 44 ++++++++++++++++----- CRM/Pledge/Page/Payment.php | 2 +- 18 files changed, 192 insertions(+), 76 deletions(-) diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 692c26bf46..9164234e80 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -375,8 +375,8 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co public function getValidProcessors() { $defaultID = NULL; $capabilities = array('BackOffice'); - if ($this->_mode == 'live') { - $capabilities[] = 'LiveMode'; + if ($this->_mode) { + $capabilities[] = (ucfirst($this->_mode) . 'Mode'); } $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors($capabilities); return $processors; @@ -407,7 +407,7 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co //only valid processors get display to user if ($this->_mode) { - $this->assign(CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate')), TRUE); + $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate'))); $this->_paymentProcessors = $this->getValidProcessors(); if (!isset($this->_paymentProcessor['id'])) { // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index ee1317c150..a7f7947646 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -858,6 +858,8 @@ AND /** * Is back office credit card processing enabled for this site - ie are there any installed processors that support * it? + * This function is used for determining whether to show the submit credit card link, not for determining which processors to show, hence + * it is a config var * @return bool */ public static function isEnabledBackOfficeCreditCardPayments() { diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index eb5a78e6f9..b5a066a706 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -86,14 +86,13 @@ abstract class CRM_Core_Payment { /** * Singleton function used to manage this object * - * @param string $mode the mode of operation: live or test - * @param array $paymentProcessor the details of the payment processor being invoked + * @param string $mode the mode of operation: live or test + * @param array $paymentProcessor the details of the payment processor being invoked * @param object $paymentForm deprecated - avoid referring to this if possible. If you have to use it document why as this is scary interaction - * @param boolean $force should we force a reload of this payment object - * - * @return CRM_Core_Payment + * @param boolean $force should we force a reload of this payment object + * @return \CRM_Core_Payment + * @throws \CRM_Core_Exception * @static - * */ public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { // make sure paymentProcessor is not empty @@ -178,13 +177,21 @@ abstract class CRM_Core_Payment { } /** - * Are back office payments supported - e.g paypal standard won't permit you to enter a credit card associated with someone else's login + * Are live payments supported - e.g dummy doesn't support this * @return bool */ protected function supportsLiveMode() { return TRUE; } + /** + * Are test payments supported + * @return bool + */ + protected function supportsTestMode() { + return TRUE; + } + /** * Should the first payment date be configurable when setting up back office recurring payments * We set this to false for historical consistency but in fact most new processors use tokens for recurring and can support this diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index f84dc38cc4..3aabcc2241 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -67,20 +67,27 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { * Singleton function used to manage this object * * @param string $mode the mode of operation: live or test - * @param object $paymentProcessor the details of the payment processor being invoked - * @param CRM_Core_Form $paymentForm reference to the form object if available - * @param boolean $force should we force a reload of this payment object + * @param array $paymentProcessor the details of the payment processor being invoked + * @param CRM_Core_Form $paymentForm reference (deprecated) + * @param boolean $force + * should we force a reload of this payment object * * @return object * @static * */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - $processorName = $paymentProcessor['name']; - if (!isset(self::$_singleton[$processorName]) || self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_AuthorizeNet($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_AuthorizeNet($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index 24e13229ea..bc1b046eca 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -70,11 +70,17 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - $processorName = $paymentProcessor['name']; - if (CRM_Utils_Array::value($processorName, self::$_singleton) === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_Dummy($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (CRM_Utils_Array::value($cacheKey, self::$_singleton) === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_Dummy($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/Elavon.php b/CRM/Core/Payment/Elavon.php index 360e4626d2..b0b3e6bcdb 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -64,11 +64,17 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_Elavon($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_Elavon($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /********************************************************** diff --git a/CRM/Core/Payment/FirstData.php b/CRM/Core/Payment/FirstData.php index f0b9169676..b725821c08 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -88,11 +88,17 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_FirstData($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_FirstData($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /********************************************************** diff --git a/CRM/Core/Payment/Google.php b/CRM/Core/Payment/Google.php index c418e54517..50bb83aeec 100644 --- a/CRM/Core/Payment/Google.php +++ b/CRM/Core/Payment/Google.php @@ -85,11 +85,17 @@ class CRM_Core_Payment_Google extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (!isset(self::$_singleton[$processorName]) || self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_Google($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_Google($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/IATS.php b/CRM/Core/Payment/IATS.php index b6588811b6..8eda80cfcd 100644 --- a/CRM/Core/Payment/IATS.php +++ b/CRM/Core/Payment/IATS.php @@ -81,11 +81,18 @@ class CRM_Core_Payment_IATS extends CRM_Core_Payment { * @return mixed */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_IATS($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_IATS($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/Moneris.php b/CRM/Core/Payment/Moneris.php index 2d2ec2f786..975fee6552 100644 --- a/CRM/Core/Payment/Moneris.php +++ b/CRM/Core/Payment/Moneris.php @@ -89,11 +89,17 @@ class CRM_Core_Payment_Moneris extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_Moneris($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_Moneris($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/PayJunction.php b/CRM/Core/Payment/PayJunction.php index 9124dd40fb..62bc2f3f01 100644 --- a/CRM/Core/Payment/PayJunction.php +++ b/CRM/Core/Payment/PayJunction.php @@ -59,11 +59,17 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_PayJunction($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_PayJunction($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /* diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 2bf2783a1e..1171467e16 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -87,11 +87,17 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - $processorName = $paymentProcessor['name']; - if (!isset(self::$_singleton[$processorName]) || self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_PaypalImpl($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_PaypalImpl($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index aec2327e12..9a7aec0950 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -55,11 +55,17 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_PayflowPro($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; + } + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_PayflowPro($mode, $paymentProcessor); } - return self::$_singleton[$processorName]; + return self::$_singleton[$cacheKey]; } /* diff --git a/CRM/Core/Payment/PaymentExpress.php b/CRM/Core/Payment/PaymentExpress.php index 92fa7ffffd..a04acb8cf1 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -79,11 +79,17 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { * @static */ public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_PaymentExpress($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_PaymentExpress($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/Realex.php b/CRM/Core/Payment/Realex.php index 8710fcc627..b52db211f3 100644 --- a/CRM/Core/Payment/Realex.php +++ b/CRM/Core/Payment/Realex.php @@ -88,11 +88,17 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_Realex($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_Realex($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /** diff --git a/CRM/Core/Payment/eWAY.php b/CRM/Core/Payment/eWAY.php index ddeb1abaa3..a4721ec84d 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -113,7 +113,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { * @return \CRM_Core_Payment_eWAY ******************************************************* */ public function __construct($mode, &$paymentProcessor) { - // require Standaard eWAY API libraries + // require Standard eWAY API libraries require_once 'eWAY/eWAY_GatewayRequest.php'; require_once 'eWAY/eWAY_GatewayResponse.php'; @@ -136,11 +136,18 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { * @static */ public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_eWAY($mode, $paymentProcessor); + if (!empty($paymentProcessor['id'])) { + $cacheKey = $paymentProcessor['id']; } - return self::$_singleton[$processorName]; + else { + //@todo eliminated instances of this in favour of id-specific instances. + $cacheKey = $mode . '_' . $paymentProcessor['name']; + } + + if (self::$_singleton[$cacheKey] === NULL) { + self::$_singleton[$cacheKey] = new CRM_Core_Payment_eWAY($mode, $paymentProcessor); + } + return self::$_singleton[$cacheKey]; } /********************************************************** diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 3e0c66ab76..3c3345bb37 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -275,15 +275,16 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces /** * Get all payment processors as an array of objects. * - * @param $isExcludeTest + * @param string|NULL $mode + * only return this mode - test|live or NULL for all * @param bool $reset * * @throws CiviCRM_API3_Exception * @return array */ - public static function getAllPaymentProcessors($isExcludeTest, $reset = FALSE) { + public static function getAllPaymentProcessors($mode, $reset = FALSE) { /** - * $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($isExcludeTest ? 'test' : 'all'); + * $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all'); if (!$reset) { $processors = CRM_Utils_Cache::singleton()->get($cacheKey); if (!empty($processors)) { @@ -292,13 +293,24 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } * */ $retrievalParameters = array('is_active' => TRUE, 'options' => array('sort' => 'is_default DESC, name'), 'api.payment_processor_type.getsingle' => 1); - if ($isExcludeTest) { + if ($mode == 'test') { + $retrievalParameters['is_test'] = 1; + } + elseif ($mode == 'live') { $retrievalParameters['is_test'] = 0; } $processors = civicrm_api3('payment_processor', 'get', $retrievalParameters); foreach ($processors['values'] as $processor) { + $fieldsToProvide = array('user_name', 'password', 'signature', 'subject'); + foreach ($fieldsToProvide as $field) { + //prevent e-notices in processor classes when not configured + if (!isset($processor[$field])) { + $processor[$field] = NULL; + } + } $processors['values'][$processor['id']]['payment_processor_type'] = $processor['payment_processor_type'] = $processors['values'][$processor['id']]['api.payment_processor_type.getsingle']['name']; - $processors['values'][$processor['id']]['object'] = CRM_Core_Payment::singleton(empty($processor['is_test']) ? 'live' : 'test', $processor); + $mode = empty($processor['is_test']) ? 'live' : 'test'; + $processors['values'][$processor['id']]['object'] = CRM_Core_Payment::singleton($mode, $processor); } /* CRM_Utils_Cache::singleton()->set($cacheKey, $processors); @@ -312,14 +324,26 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * arguably this could go on the pseudoconstant class * * @param array $capabilities - * @param bool $isIncludeTest + * capabilities of processor e.g + * - BackOffice + * - TestMode + * - LiveMode + * - FutureStartDate + * include test processors (we want to phase this out in favour of the testMode Capability) * * @param array $ids * * @return array available processors */ - public static function getPaymentProcessors($capabilities = array(), $isIncludeTest = FALSE, $ids = array()) { - $processors = self::getAllPaymentProcessors(!$isIncludeTest); + public static function getPaymentProcessors($capabilities = array(), $ids = array()) { + $mode = NULL; + if (in_array('TestMode', $capabilities)) { + $mode = 'test'; + } + elseif (in_array('LiveMode', $capabilities)) { + $mode = 'live'; + } + $processors = self::getAllPaymentProcessors($mode); if ($capabilities) { foreach ($processors as $index => $processor) { if (!empty($ids) && !in_array($processor['id'], $ids)) { @@ -348,7 +372,9 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * @return bool */ public static function hasPaymentProcessorSupporting($capabilities = array(), $isIncludeTest = FALSE) { - $result = self::getPaymentProcessors($capabilities, $isIncludeTest); + $mode = $isIncludeTest ? 'Test' : 'Live'; + $capabilities[] = $mode . 'Mode'; + $result = self::getPaymentProcessors($capabilities); return (!empty($result)) ? TRUE : FALSE; } diff --git a/CRM/Pledge/Page/Payment.php b/CRM/Pledge/Page/Payment.php index b697f565c5..bee1d2284a 100644 --- a/CRM/Pledge/Page/Payment.php +++ b/CRM/Pledge/Page/Payment.php @@ -62,7 +62,7 @@ class CRM_Pledge_Page_Payment extends CRM_Core_Page { $this->assign('pledgeId', $pledgeId); $this->assign('contactId', $this->_contactId); - // check if we can process credit card contribs + // check if we can process credit card contributions $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); // check is the user has view/edit signer permission -- 2.25.1