From: Matthew Wire Date: Mon, 17 May 2021 15:31:38 +0000 (+0100) Subject: Convert Realex to doPayment X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2d9ca6420ca339b08b3ac3eb2149779a82ff804c;p=civicrm-core.git Convert Realex to doPayment --- diff --git a/CRM/Core/Payment/Realex.php b/CRM/Core/Payment/Realex.php index 03ad040db4..f82eb024df 100644 --- a/CRM/Core/Payment/Realex.php +++ b/CRM/Core/Payment/Realex.php @@ -54,15 +54,28 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { /** * Submit a payment using Advanced Integration Method. * - * @param array $params - * Assoc array of input parameters for this transaction. + * @param array|PropertyBag $params + * + * @param string $component * * @return array - * the result in a nice formatted array (or an error object) + * Result array (containing at least the key payment_status_id) * * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function doDirectPayment(&$params) { + 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'); + + // 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'; + return $result; + } if (!defined('CURLOPT_SSLCERT')) { throw new PaymentProcessorException(ts('RealAuth requires curl with SSL support'), 9001); @@ -176,6 +189,8 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { $params['trxn_result_code'] = serialize($extras); $params['currencyID'] = $this->_getParam('currency'); $params['fee_amount'] = 0; + $params['payment_status_id'] = array_search('Completed', $statuses); + $params['payment_status'] = 'Completed'; return $params; }