Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Realex to doPayment #20327

Merged
merged 1 commit into from
May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions CRM/Core/Payment/Realex.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,28 @@ public function __construct($mode, &$paymentProcessor) {
/**
* 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);
Expand Down Expand Up @@ -176,6 +189,8 @@ public function doDirectPayment(&$params) {
$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;
}
Expand Down