diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 80125a8edc5c..4472bea0c1e6 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -79,6 +79,17 @@ public static function create($params) { 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 @@ public static function getTestProcessorId($id) { return civicrm_api3('payment_processor', 'getvalue', array( 'return' => 'id', 'name' => $liveProcessorName, + 'is_test' => 1, 'domain_id' => CRM_Core_Config::domainID(), )); }