Update return parameters on all paymentprocessors to match expected result
[civicrm-core.git] / ext / ewaysingle / CRM / Core / Payment / eWAY.php
index 7dc7d233b51852a68cde30bda2f8790e5b9d7470..a36c28c5ec007ca64a8801c564ee666e171f7ca8 100644 (file)
@@ -140,14 +140,13 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment {
   public function doPayment(&$params, $component = 'contribute') {
     $propertyBag = \Civi\Payment\PropertyBag::cast($params);
     $this->_component = $component;
-    $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate');
+    $result = $this->setStatusPaymentPending([]);
 
     // If we have a $0 amount, skip call to processor and set payment_status to Completed.
     // Conceivably a processor might override this - perhaps for setting up a token - but we don't
     // have an example of that at the moment.
     if ($propertyBag->getAmount() == 0) {
-      $result['payment_status_id'] = array_search('Completed', $statuses);
-      $result['payment_status'] = 'Completed';
+      $result = $this->setStatusPaymentCompleted($result);
       return $result;
     }
 
@@ -335,11 +334,9 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment {
       $beaglestatus = ': ' . $beaglestatus;
     }
     $params['trxn_result_code'] = $eWAYResponse->Status() . $beaglestatus;
-    $params['trxn_id'] = $eWAYResponse->TransactionNumber();
-    $params['payment_status_id'] = array_search('Completed', $statuses);
-    $params['payment_status'] = 'Completed';
-
-    return $params;
+    $result['trxn_id'] = $eWAYResponse->TransactionNumber();
+    $result = $this->setStatusPaymentCompleted($result);
+    return $result;
   }
 
   /**