Merge pull request #23258 from civicrm/5.49
[civicrm-core.git] / CRM / Core / Payment / AuthorizeNet.php
index e28bdbf900a5f4487e50a316495b431a11e8719a..ed28adc948c362b751b652d0e6efd59e02f4eeb3 100644 (file)
@@ -184,13 +184,13 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment {
     // fetch available contribution statuses
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
 
+    $result = [];
     // check for application errors
     // TODO:
     // AVS, CVV2, CAVV, and other verification results
     switch ($response_fields[0]) {
       case self::AUTH_REVIEW:
-        $params['payment_status_id'] = array_search('Pending', $contributionStatus);
-        $params['payment_status'] = 'Pending';
+        $result = $this->setStatusPaymentPending($result);
         break;
 
       case self::AUTH_ERROR:
@@ -203,13 +203,12 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment {
 
       default:
         // Success
-        $params['trxn_id'] = !empty($response_fields[6]) ? $response_fields[6] : $this->getTestTrxnID();
-        $params['payment_status_id'] = array_search('Completed', $statuses);
-        $params['payment_status'] = 'Completed';
+        $result['trxn_id'] = !empty($response_fields[6]) ? $response_fields[6] : $this->getTestTrxnID();
+        $result = $this->setStatusPaymentCompleted($result);
         break;
     }
 
-    return $params;
+    return $result;
   }
 
   /**
@@ -304,7 +303,8 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment {
     $template->assign('billingState', $this->_getParam('state_province'));
     $template->assign('billingZip', $this->_getParam('postal_code', TRUE));
     $template->assign('billingCountry', $this->_getParam('country'));
-
+    // Required to be set for s
+    $template->ensureVariablesAreAssigned(['subscriptionType']);
     $arbXML = $template->fetch('CRM/Contribute/Form/Contribution/AuthorizeNetARB.tpl');
 
     // Submit to authorize.net