From a573c91754b70a834a31a8afcceaa1145bc98d2c Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 16 May 2022 13:44:48 +0100 Subject: [PATCH] Simplify parameters for completetransaction for zero value payment --- CRM/Contribute/Form/Contribution/Confirm.php | 30 +++++++------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 16a0e40d3f..1a167039e8 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1755,25 +1755,17 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_values['payment_processor'] ?? NULL); $this->_paymentProcessor['id'] = $paymentProcessorIDs[0]; } - $result = ['payment_status_id' => 1, 'contribution' => $membershipContribution]; - if (($result['payment_status_id'] ?? NULL) == 1) { - try { - civicrm_api3('contribution', 'completetransaction', [ - 'id' => $result['contribution']->id, - 'trxn_id' => $result['trxn_id'] ?? NULL, - 'payment_processor_id' => $result['payment_processor_id'] ?? $this->_paymentProcessor['id'], - 'is_transactional' => FALSE, - 'fee_amount' => $result['fee_amount'] ?? NULL, - 'receive_date' => $result['receive_date'] ?? NULL, - 'card_type_id' => $result['card_type_id'] ?? NULL, - 'pan_truncation' => $result['pan_truncation'] ?? NULL, - ]); - } - catch (CiviCRM_API3_Exception $e) { - if ($e->getErrorCode() != 'contribution_completed') { - \Civi::log()->error('CRM_Contribute_Form_Contribution_Confirm::completeTransaction CiviCRM_API3_Exception: ' . $e->getMessage()); - throw new CRM_Core_Exception('Failed to update contribution in database'); - } + try { + civicrm_api3('contribution', 'completetransaction', [ + 'id' => $membershipContribution->id, + 'payment_processor_id' => $this->_paymentProcessor['id'], + 'is_transactional' => FALSE, + ]); + } + catch (CiviCRM_API3_Exception $e) { + if ($e->getErrorCode() != 'contribution_completed') { + \Civi::log()->error('CRM_Contribute_Form_Contribution_Confirm::completeTransaction CiviCRM_API3_Exception: ' . $e->getMessage()); + throw new CRM_Core_Exception('Failed to update contribution in database'); } } } -- 2.25.1