Skip to content

Commit

Permalink
Merge pull request #70 from andrew-cormick-dockery/fix/reduce-recurri…
Browse files Browse the repository at this point in the history
…ng-job-fragility

Reduce fragility of recurring payment processor upon internal error
  • Loading branch information
eileenmcnaughton authored Jun 9, 2023
2 parents 8af042a + e728b7f commit 93d55e7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CRM/Core/Payment/Ewayrecurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 7 additions & 3 deletions api/v3/Ewayrecurring/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
11 changes: 10 additions & 1 deletion api/v3/Job/Eway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<author>Melbourne CiviCRM</author>
<email>[email protected]</email>
</maintainer>
<releaseDate>2020-02-19</releaseDate>
<version>1.2.1</version>
<releaseDate>2023-03-02</releaseDate>
<version>2.4.1</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.4</ver>
Expand Down

0 comments on commit 93d55e7

Please sign in to comment.