Fix some currencies not passed
authoreileen <emcnaughton@wikimedia.org>
Thu, 8 Feb 2024 05:21:40 +0000 (18:21 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 8 Feb 2024 05:33:41 +0000 (18:33 +1300)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/ContributionBase.php
CRM/Member/Form/MembershipRenewal.php

index a4a59982b81bf6afa598fce65de7c4ef4fd65b05..1f60ac83bacd8fbdf0d47cff9fa17af60d729ecb 100644 (file)
@@ -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'] ?? '');
index d92dbf9fe920ca9441d25e794811cd1601c59a8a..f8d8592279693f2d04af52bd1963b2a86cf0962c 100644 (file)
@@ -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'));
   }
 
 }
index 60a87af891df084b87715df5f5028168b423712d..ea9c8a110b8af39079490b89545e00f6cc83b488 100644 (file)
@@ -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);