From 2a792295ad6d26757c415430a706bf08197370fa Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 8 Feb 2024 18:21:40 +1300 Subject: [PATCH] Fix some currencies not passed --- CRM/Contribute/Form/Contribution/Confirm.php | 2 ++ CRM/Contribute/Form/ContributionBase.php | 13 ++++--------- CRM/Member/Form/MembershipRenewal.php | 1 + 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index a4a59982b8..1f60ac83ba 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1562,6 +1562,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // be performed yet, so do it now. if ($isPaidMembership && !$this->isSeparatePaymentSelected()) { $paymentParams['amount'] = $this->getMainContributionAmount(); + $paymentParams['currency'] = $this->getCurrency(); $paymentActionResult = $payment->doPayment($paymentParams); $paymentResults[] = ['contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult]; } @@ -2604,6 +2605,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // and always calling it first. $form->postProcessHook(); } + $paymentParams['currency'] = $this->getCurrency(); $result = $payment->doPayment($paymentParams); $form->_params = array_merge($form->_params, $result); $form->assign('trxn_id', $result['trxn_id'] ?? ''); diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index d92dbf9fe9..f8d8592279 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -1545,19 +1545,14 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { * Rather historic - might have unneeded stuff * * @return string + * @throws \CRM_Core_Exception */ - public function getCurrency() { - $currency = $this->_values['currency'] ?? NULL; - // For event forms, currency is in a different spot - if (empty($currency)) { - $currency = CRM_Utils_Array::value('currency', CRM_Utils_Array::value('event', $this->_values)); - } + public function getCurrency(): string { + $currency = $this->getContributionValue('currency'); if (empty($currency)) { $currency = CRM_Utils_Request::retrieveValue('currency', 'String'); } - // @todo If empty there is a problem - we should probably put in a deprecation notice - // to warn if that seems to be happening. - return (string) $currency; + return (string) ($currency ?? \Civi::settings()->get('currency')); } } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 60a87af891..ea9c8a110b 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -561,6 +561,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $paymentParams['invoiceID'] = $paymentParams['invoice_id']; $payment = $this->_paymentProcessor['object']; + $paymentParams['currency'] = $this->getCurrency(); $result = $payment->doPayment($paymentParams); $this->_params = array_merge($this->_params, $result); -- 2.25.1