Fix amount not getting passed through in simple contribution flow
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 14 Dec 2023 20:34:04 +0000 (09:34 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 14 Dec 2023 20:53:02 +0000 (09:53 +1300)
CRM/Contribute/Form/Contribution/Confirm.php

index 76cf517f8ef7515e23f7c9371aeaa98c41b9b0a7..6375776a4afb844dbb952eb5039c986b356bbc81 100644 (file)
@@ -1553,6 +1553,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       // If this is a single membership-related contribution, it won't have
       // be performed yet, so do it now.
       if ($isPaidMembership && !$this->isSeparatePaymentSelected()) {
+        $paymentParams['amount'] = $this->getMainContributionAmount();
         $paymentActionResult = $payment->doPayment($paymentParams);
         $paymentResults[] = ['contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult];
       }
@@ -1863,7 +1864,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     if ($form->isSeparateMembershipPayment()) {
       $amount -= $form->order->getMembershipTotalAmount();
     }
-    $form->_amount = $params['amount'] = $form->_params['amount'] = $amount;
     // hack these in for test support.
     $form->_fields['billing_first_name'] = 1;
     $form->_fields['billing_last_name'] = 1;
@@ -2215,7 +2215,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
           }
         }
       }
-
+      $paymentParams['amount'] = $this->getMainContributionAmount();
+      $paymentParams['line_item'] = [$this->getPriceSetID() => $this->getMainContributionLineItems()];
       $result = $this->processConfirm($paymentParams,
         $contactID,
         $this->wrangleFinancialTypeID($this->_values['financial_type_id']),
@@ -2512,11 +2513,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       CRM_Utils_Date::mysqlToIso($form->_params['receive_date'])
     );
 
-    if (empty($form->_values['amount'])) {
-      // If the amount is not in _values[], set it
-      $form->_values['amount'] = $form->_params['amount'];
-    }
-
     if (isset($paymentParams['contribution_source'])) {
       $paymentParams['source'] = $paymentParams['contribution_source'];
     }