From: eileenmcnaugton Date: Thu, 22 Oct 2015 02:29:01 +0000 (+1300) Subject: CRM-17426 fix paylater showing when not configured to X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cbcb5b49d6c71d9041d2ae2948a5ec7fdc7ca475;p=civicrm-core.git CRM-17426 fix paylater showing when not configured to --- diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 5967757f2d..2da894c39f 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -302,7 +302,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { CRM_Utils_Array::value('payment_processor', $this->_values) ); - $this->assignPaymentProcessor(); + $this->assignPaymentProcessor($isPayLater); } // get price info diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 63ab7fb404..47ccf65f33 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -93,13 +93,36 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * Available payment processors (IDS). * * As part of trying to consolidate various payment pages we store processors here & have functions - * at this level to manage them. + * at this level to manage them. An alternative would be to have a separate Form that is inherited + * by all forms that allow payment processing. * * @var array * An array of the IDS available on this form. */ public $_paymentProcessorIDs; + /** + * Default or selected processor id. + * + * As part of trying to consolidate various payment pages we store processors here & have functions + * at this level to manage them. An alternative would be to have a separate Form that is inherited + * by all forms that allow payment processing. + * + * @var int + */ + protected $_paymentProcessorID; + + /** + * Is pay later enabled for the form. + * + * As part of trying to consolidate various payment pages we store processors here & have functions + * at this level to manage them. An alternative would be to have a separate Form that is inherited + * by all forms that allow payment processing. + * + * @var int + */ + protected $_is_pay_later_enabled; + /** * The renderer used for this form * @@ -657,15 +680,20 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * It would be good to sync it with the back-end function on abstractEditPayment & use one everywhere. * + * @param bool $is_pay_later_enabled + * * @throws \CRM_Core_Exception */ - protected function assignPaymentProcessor() { + protected function assignPaymentProcessor($is_pay_later_enabled) { $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors( array(ucfirst($this->_mode) . 'Mode'), $this->_paymentProcessorIDs ); if (!empty($this->_paymentProcessors)) { + if ($is_pay_later_enabled) { + $this->_paymentProcessors[0] = CRM_Financial_BAO_PaymentProcessor::getPayment(0); + } foreach ($this->_paymentProcessors as $paymentProcessorID => $paymentProcessorDetail) { if (empty($this->_paymentProcessor) && $paymentProcessorDetail['is_default'] == 1 || (count($this->_paymentProcessors) == 1) ) { @@ -734,7 +762,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ protected function preProcessPaymentOptions() { $this->_paymentProcessorID = NULL; - $this->_paymentProcessors[0] = CRM_Financial_BAO_PaymentProcessor::getPayment(0); if ($this->_paymentProcessors) { if (!empty($this->_submitValues)) { $this->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $this->_submitValues); diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index f600b1a181..f550c3fcfc 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -299,7 +299,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { $this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values['event'] )); - $this->assignPaymentProcessor(); + $this->assignPaymentProcessor($isPayLater); } //init event fee.