From f917d7f7fba456b1a6c56780034a158593400c35 Mon Sep 17 00:00:00 2001 From: Andrew Cormick-Dockery Date: Wed, 1 Mar 2023 16:35:45 +1100 Subject: [PATCH 1/3] Reduce fragility of recurring payments processor upon internal error - proceed to attempt next transaction rather than quit altogether --- api/v3/Job/Eway.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/v3/Job/Eway.php b/api/v3/Job/Eway.php index 4b39529..fc85ab4 100644 --- a/api/v3/Job/Eway.php +++ b/api/v3/Job/Eway.php @@ -56,7 +56,16 @@ function civicrm_api3_job_eway($params) { $apiResult[] = "Processing " . count($scheduled_contributions) . " scheduled contributions"; foreach ($scheduled_contributions as $scheduled_contribution) { - $apiResult = array_merge($apiResult, _civicrm_api3_job_eway_process_contribution($scheduled_contribution)); + try { + $apiResult = array_merge($apiResult, _civicrm_api3_job_eway_process_contribution($scheduled_contribution)); + } + catch (CiviCRM_API3_Exception $e) { + $apiResult[] = "ERROR: failed to process payment for " . + $scheduled_contribution['type'] . " recurring contribution ID: " . + $scheduled_contribution['contribution']->contribution_recur_id; + $apiResult[] = 'Reason given: ' . $e->getMessage(); + $apiResult[] = "Contribution was not attempted."; + } } return civicrm_api3_create_success($apiResult, $params); From 16784cec17212cfe5e9ae661bc264e3a6e13b537 Mon Sep 17 00:00:00 2001 From: Andrew Cormick-Dockery Date: Wed, 1 Mar 2023 16:36:43 +1100 Subject: [PATCH 2/3] Eway developer mode: introduce a configurable failure mode: set amount to less than $10 --- CRM/Core/Payment/Ewayrecurring.php | 7 ++++++- api/v3/Ewayrecurring/Payment.php | 10 +++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CRM/Core/Payment/Ewayrecurring.php b/CRM/Core/Payment/Ewayrecurring.php index 26eb536..05ab987 100644 --- a/CRM/Core/Payment/Ewayrecurring.php +++ b/CRM/Core/Payment/Ewayrecurring.php @@ -658,7 +658,12 @@ protected function processSinglePayment(&$params) { $eWAYRequest = $this->getEwayRequest($params); if ($this->getDummySuccessResult()) { - return $this->getDummySuccessResult(); + if ($this->getAmountInCents($params) > 999) { + return $this->getDummySuccessResult(); + } + else { + throw new PaymentProcessorException(' * Eway Developer Mode: simulated payment failure (amount less than $10)'); + } } $eWAYResponse = new EwayRecurringGatewayResponse(); diff --git a/api/v3/Ewayrecurring/Payment.php b/api/v3/Ewayrecurring/Payment.php index 9b368f9..14c7a8e 100644 --- a/api/v3/Ewayrecurring/Payment.php +++ b/api/v3/Ewayrecurring/Payment.php @@ -17,9 +17,13 @@ function civicrm_api3_ewayrecurring_payment($params) { 'group' => 'eway', 'name' => 'eway_developer_mode', ))) { - return civicrm_api3_create_success(array( - $params['managed_customer_id'] => array('trxn_id' => uniqid()), - ), $params); + if ($params['amount_in_cents'] > 999) { + return civicrm_api3_create_success(array( + $params['managed_customer_id'] => array('trxn_id' => uniqid()), + ), $params); + } else { + throw new API_Exception(' * Eway Developer Mode: simulated payment failure (amount less than $10)'); + } } $client = CRM_Core_Payment_EwayUtils::getClient($params['payment_processor_id']); From e728b7fc2d5424e396761b0aeb7dd8abf3131a43 Mon Sep 17 00:00:00 2001 From: Andrew Cormick-Dockery Date: Thu, 2 Mar 2023 14:53:53 +1100 Subject: [PATCH 3/3] Bump version number --- info.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.xml b/info.xml index 0fc729f..b2f2fa4 100644 --- a/info.xml +++ b/info.xml @@ -14,8 +14,8 @@ Melbourne CiviCRM noreply@civicrm.org - 2020-02-19 - 1.2.1 + 2023-03-02 + 2.4.1 stable 4.4