From 2204d007f98ffc70a4f3eb6786234b9c3dffb942 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Mon, 6 May 2019 22:58:11 +0100 Subject: [PATCH] Refactor to reduce duplication on payment forms --- CRM/Core/Form.php | 10 ++++++++-- CRM/Core/Payment/ProcessorForm.php | 3 +++ CRM/Financial/Form/Payment.php | 5 ----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index b396667fe7..8dcc839ae2 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -766,6 +766,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->assign('bltID', $this->_bltID); } + /** + * @return int + */ + public function getPaymentProcessorID() { + return $this->_paymentProcessorID; + } + /** * This if a front end form function for setting the payment processor. * @@ -878,9 +885,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { else { $this->_paymentProcessor = []; } - CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessorID); } - $this->assign('paymentProcessorID', $this->_paymentProcessorID); + // We save the fact that the profile 'billing' is required on the payment form. // Currently pay-later is the only 'processor' that takes notice of this - but ideally // 1) it would be possible to select the minimum_billing_profile_id for the contribution form diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 6afebf6e53..9b8fc660e6 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -73,6 +73,9 @@ class CRM_Core_Payment_ProcessorForm { $form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons()); + CRM_Financial_Form_Payment::addCreditCardJs($form->getPaymentProcessorID()); + $form->assign('paymentProcessorID', $form->getPaymentProcessorID()); + $form->assign('currency', $form->getCurrency()); // also set cancel subscription url diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index a559e5ec92..9deb8ea265 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -79,11 +79,6 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { CRM_Core_Payment_ProcessorForm::preProcess($this); - self::addCreditCardJs($this->_paymentProcessorID); - - $this->assign('paymentProcessorID', $this->_paymentProcessorID); - $this->assign('currency', $this->currency); - $this->assign('suppressForm', TRUE); $this->controller->_generateQFKey = FALSE; } -- 2.25.1