From: Eileen McNaughton Date: Tue, 12 May 2015 09:38:35 +0000 (+1200) Subject: CRM-16402 instantiate payment object in new way X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3155fe2141ffbaa905ed0653cbfc41178547676;p=civicrm-core.git CRM-16402 instantiate payment object in new way --- diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index e78c9eb830..67c6877df7 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -33,6 +33,8 @@ * */ +use Civi\Payment\System; + /** * This class generates form components for processing a contribution * @@ -346,7 +348,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { } if (isset($defaultProcessorId)) { - $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode); + $this->_paymentProcessor = Civi\Payment\System::singleton()->getByProcessor($defaultProcessorId, $this->_mode); $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor); } @@ -357,12 +359,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).')); } - // ensure that processor has a valid config - $this->_paymentObject = &CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this); - $error = $this->_paymentObject->checkConfig(); - if (!empty($error)) { - CRM_Core_Error::fatal($error); - } + $this->_paymentObject = Civi\Payment\System::singleton()->getByProcessor($eachPaymentProcessor); } } } diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index a32a319c54..1f552f605f 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -53,6 +53,9 @@ class System { } $this->cache[$id] = new $paymentClass(!empty($processor['is_test']) ? 'test' : 'live', $processor); + if ($this->cache[$id]->checkConfig()) { + $this->cache[$id] = NULL; + } } } return $this->cache[$id];