From d02c64180a9514c39f3fca0369bcdf4b7f43d93a Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 26 Nov 2018 21:58:23 +1300 Subject: [PATCH] Set currency template variable from contribution pages When we load the PaymentForm the currency is set there and assigned to the template. However, if the form doesn't load by default (ie because there is no payment processor selected by default) the currency variable is not assigned to the template. When the payment form is loaded by var dataUrl = '{crmURL p='civicrm/payment/form' h=0 q=formName= --- CRM/Contribute/Form/ContributionBase.php | 5 +++++ CRM/Core/Payment/ProcessorForm.php | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 45a62b78bb..137c645f88 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -484,8 +484,13 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $this->_defaults = array(); $this->_amount = $this->get('amount'); + // Assigning this to the template means it will be passed through to the payment form. + // This can, for example, by used by payment processors using client side encryption + $this->assign('currency', $this->getCurrency()); //CRM-6907 + // these lines exist to support a non-default currenty on the form but are probably + // obsolete & meddling wth the defaultCurrency is not the right approach.... $config = CRM_Core_Config::singleton(); $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values, diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 4b777356ec..4229a4a8e8 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -72,8 +72,7 @@ class CRM_Core_Payment_ProcessorForm { $form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons()); - $currency = $form->getCurrency(); - $form->assign('currency', $currency); + $form->assign('currency', $form->getCurrency()); // also set cancel subscription url if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) { -- 2.25.1