Stop passing result into getContributionParams to get one value from it
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 10 Jul 2023 00:35:02 +0000 (12:35 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 10 Jul 2023 00:35:02 +0000 (12:35 +1200)
We are passing in a vague array but we care about only one value that might be in it,
from one of the places this is called. We
are better to simply pick the variable out in the
calling function

CRM/Contribute/Form/Contribution/Confirm.php

index 5b28abd7af396682fd72bc4fe2fa0b43abfcadc3..6e22c12c863329e52bb269e542a97319fdf7cdb6 100644 (file)
@@ -171,9 +171,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       'skipLineItem' => $params['skipLineItem'] ?? 0,
     ];
 
-    if ($paymentProcessorOutcome) {
-      $contributionParams['payment_processor'] = $paymentProcessorOutcome['payment_processor'] ?? NULL;
-    }
     if (!empty($params["is_email_receipt"])) {
       $contributionParams += [
         'receipt_date' => $receiptDate,
@@ -1083,9 +1080,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     if (isset($params['amount'])) {
       $contributionParams = array_merge(self::getContributionParams(
         $params, $financialType->id,
-        $result, $receiptDate,
+        NULL, $receiptDate,
         $recurringContributionID), $contributionParams
       );
+
+      $contributionParams['payment_processor'] = $result ? ($result['payment_processor'] ?? NULL) : NULL;
       $contributionParams['non_deductible_amount'] = self::getNonDeductibleAmount($params, $financialType, TRUE, $form);
       $contributionParams['skipCleanMoney'] = TRUE;
       // @todo this is the wrong place for this - it should be done as close to form submission