From: Eileen McNaughton Date: Wed, 13 May 2015 04:52:04 +0000 (+1200) Subject: CRM-16402 payment processor factory change X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=428e38a4c2b9ae47b72d4dfe15174fe4c24f9304;p=civicrm-core.git CRM-16402 payment processor factory change --- diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index da26df31e6..8c88cde118 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -348,7 +348,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { if (empty($this->_paymentProcessor) && $paymentProcessorDetail['is_default'] == 1 || (count ($this->_paymentProcessors) == 1) ) { - $this->_paymentProcessor = $processor; + $this->_paymentProcessor = $paymentProcessorDetail; $this->assign('paymentProcessor', $this->_paymentProcessor); } } diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 43b47f3035..d43def24b5 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -210,6 +210,26 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } } + /** + * Given a live processor ID get the test id. + * + * @param int $id + * + * @return int + * Test payment processor ID. + */ + public static function getTestProcessorId($id) { + $liveProcessorName = civicrm_api3('payment_processor', 'getvalue', array( + 'id' => $id, + 'return' => 'name', + )); + return civicrm_api3('payment_processor', 'getvalue', array( + 'return' => 'id', + 'name' => $liveProcessorName, + 'domain_id' => CRM_Core_Config::domainID(), + )); + } + /** * @param $paymentProcessorIDs * @param $mode diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index 3f10f10484..f01e56d961 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -29,7 +29,14 @@ class System { } /** + * Starting from the processor as an array retrieve the processor as an object. + * + * If there is no valid configuration it will not be retrieved. + * * @param array $processor + * + * @return CRM_Core_Payment|NULL + * * @throws \CRM_Core_Exception */ public function getByProcessor($processor) {