From: Coleman Watts Date: Thu, 4 Apr 2013 00:45:17 +0000 (-0700) Subject: Remember payment processor during form reload, fix notices CRM-12149 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f92fc7eb15fd7031146543a37a5afb1259e3cec1;p=civicrm-core.git Remember payment processor during form reload, fix notices CRM-12149 --- diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 2064bc3cba..6d2f76c4b1 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -448,7 +448,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } $this->assign('priceSetID', $this->_priceSetId); $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name'); - if ($this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('Google_Checkout', $paymentProcessorType) + if ($this->_paymentProcessor && + $this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('Google_Checkout', $paymentProcessorType) && !$this->_params['is_pay_later'] && !($this->_amount == 0) ) { $this->_checkoutButtonName = $this->getButtonName('next', 'checkout'); diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 11fd190048..6c82532b33 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -968,7 +968,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu // return if this is express mode $config = CRM_Core_Config::singleton(); - if ($self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) { + if ($self->_paymentProcessor && + $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON + ) { if (CRM_Utils_Array::value($self->_expressButtonName . '_x', $fields) || CRM_Utils_Array::value($self->_expressButtonName . '_y', $fields) || CRM_Utils_Array::value($self->_expressButtonName, $fields) @@ -1024,7 +1026,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu // if the user has chosen a free membership or the amount is less than zero // i.e. we skip calling the payment processor and hence dont need credit card // info - if ((float ) $amount <= 0.0) { + if ((float) $amount <= 0.0) { return $errors; } @@ -1285,7 +1287,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu // default mode is direct $this->set('contributeMode', 'direct'); - if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) { + if ($this->_paymentProcessor && + $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON + ) { //get the button name $buttonName = $this->controller->getButtonName(); if (in_array($buttonName, @@ -1316,7 +1320,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu CRM_Utils_System::redirect($paymentURL); } } - elseif ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) { + elseif ($this->_paymentProcessor && + $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY + ) { $this->set('contributeMode', 'notify'); } } @@ -1356,26 +1362,24 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $paymentProcessors = $form->get('paymentProcessors'); $form->_ppType = NULL; if ($paymentProcessors) { - // Fetch type during form post - if (CRM_Utils_Array::value('hidden_processor', $_POST)) { - $form->_ppType = CRM_Utils_Array::value('payment_processor', $_POST); - $form->set('type', $form->_ppType); - $form->set('mode', $form->_mode); - $form->set('paymentProcessor', $form->_paymentProcessor); + // Fetch type during ajax request + if (isset($_GET['type']) && $form->_snippet) { + $form->_ppType = $_GET['type']; } - // When user presses the back button + // Remember type during form post elseif (!empty($form->_submitValues)) { $form->_ppType = CRM_Utils_Array::value('payment_processor', $form->_submitValues); - } - // Fetch type during ajax request - elseif (isset($_GET['type']) && $form->_snippet) { - $form->_ppType = $_GET['type']; + $form->_paymentProcessor = CRM_Utils_Array::value($form->_ppType, $paymentProcessors); + $form->set('type', $form->_ppType); + $form->set('mode', $form->_mode); + $form->set('paymentProcessor', $form->_paymentProcessor); } // Set default payment processor else { foreach ($paymentProcessors as $values) { if (!empty($values['is_default']) || count($paymentProcessors) == 1) { $form->_ppType = $values['id']; + break; } } } diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index c316601bb7..901527e098 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -510,7 +510,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $config = CRM_Core_Config::singleton(); if (isset($this->_values['is_recur']) && - $this->_paymentProcessor['is_recur'] + CRM_Utils_Array::value('is_recur', $this->_paymentProcessor) ) { $this->assign('is_recur_enabled', 1); $vars = array_merge($vars, array( @@ -584,7 +584,9 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { } if ($this->_contributeMode == 'direct' && $assignCCInfo) { - if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { + if ($this->_paymentProcessor && + $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT + ) { $this->assign('payment_type', $this->_paymentProcessor['payment_type']); $this->assign('account_holder', $this->_params['account_holder']); $this->assign('bank_identification_number', $this->_params['bank_identification_number']); diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 5a4f0336b9..fe7d17ad6f 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -847,7 +847,9 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } // return if this is express mode $config = CRM_Core_Config::singleton(); - if ($self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) { + if ($self->_paymentProcessor && + $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON + ) { if (CRM_Utils_Array::value($self->_expressButtonName . '_x', $fields) || CRM_Utils_Array::value($self->_expressButtonName . '_y', $fields) || CRM_Utils_Array::value($self->_expressButtonName, $fields) @@ -1099,7 +1101,9 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $this->_params[] = $params; $this->set('params', $this->_params); - if ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) { + if ($this->_paymentProcessor && + $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON + ) { //get the button name $buttonName = $this->controller->getButtonName(); if (in_array($buttonName, @@ -1151,7 +1155,9 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { CRM_Utils_System::redirect($paymentURL); } } - elseif ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) { + elseif ($this->_paymentProcessor && + $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY + ) { $this->set('contributeMode', 'notify'); } } diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index c1cf62401a..aa017296b2 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -24,7 +24,7 @@ +--------------------------------------------------------------------+ *} {* Callback snippet: Load payment processor *} -{if $ppType and $snippet} +{if $snippet} {include file="CRM/Core/BillingBlock.tpl" context="front-end"} {if $is_monetary} {* Put PayPal Express button after customPost block since it's the submit button in this case. *} diff --git a/templates/CRM/Event/Form/Registration/Register.tpl b/templates/CRM/Event/Form/Registration/Register.tpl index 059bdbc4d3..0d64804fae 100644 --- a/templates/CRM/Event/Form/Registration/Register.tpl +++ b/templates/CRM/Event/Form/Registration/Register.tpl @@ -24,7 +24,7 @@ +--------------------------------------------------------------------+ *} {* Callback snippet: Load payment processor *} -{if $ppType and $snippet} +{if $snippet} {include file="CRM/Core/BillingBlock.tpl" context="front-end"}