From 428e38a4c2b9ae47b72d4dfe15174fe4c24f9304 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 13 May 2015 16:52:04 +1200 Subject: [PATCH] CRM-16402 payment processor factory change --- CRM/Contribute/Form/ContributionBase.php | 2 +- CRM/Financial/BAO/PaymentProcessor.php | 20 ++++++++++++++++++++ Civi/Payment/System.php | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) 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) { -- 2.25.1