From 46168cb88f8e79a1c1b37044925abaa277e7ac3a Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 14 Mar 2017 09:54:42 +0000 Subject: [PATCH] Disable/enable both processors directly in BAO create function --- CRM/Financial/BAO/PaymentProcessor.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 80125a8edc..dd0b8de7bc 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -79,6 +79,17 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces CRM_Financial_BAO_FinancialTypeAccount::add($values); } + if (isset($params['id']) && isset($params['is_active']) && !isset($params['is_test'])) { + // check if is_active has changed & if so update test instance is_active too. + $test_id = self::getTestProcessorId($params['id']); + $testDAO = new CRM_Financial_DAO_PaymentProcessor(); + $testDAO->id = $test_id; + if ($testDAO->find(true)) { + $testDAO->is_active = $params['is_active']; + $testDAO->save(); + } + } + Civi\Payment\System::singleton()->flushProcessors(); return $processor; } @@ -252,6 +263,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces return civicrm_api3('payment_processor', 'getvalue', array( 'return' => 'id', 'name' => $liveProcessorName, + 'is_test' => 1, 'domain_id' => CRM_Core_Config::domainID(), )); } -- 2.25.1