Skip to content

Commit

Permalink
Don't try and set Cancelled contribution to Failed as this is not all…
Browse files Browse the repository at this point in the history
…owed
  • Loading branch information
mattwire committed Feb 7, 2018
1 parent b98fee2 commit a7ae3fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions CRM/Core/Payment/OmnipayMultiProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,23 @@ public function processPaymentNotification($params) {
$this->redirectOrExit('success', $response);
}
elseif ($this->transaction_id) {
civicrm_api3('contribution', 'create', array('id' => $this->transaction_id, 'contribution_status_id' => 'Failed'));
}
// Mark the contribution as failed (only allowed if status=Pending).
// We get multiple requests from some processors (eg. Sagepay) where the contribution has already been marked as "Cancelled".
try {
$contribution = civicrm_api3('contribution', 'getsingle', array(
'id' => $this->transaction_id,
'return' => 'contribution_status_id',
));

//$this->redirectOrExit('error', $response);
$contributionStatusName = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution['contribution_status_id']);
if ($contributionStatusName === 'Pending') {
civicrm_api3('contribution', 'create', array('id' => $this->transaction_id, 'contribution_status_id' => 'Failed'));
}
}
catch (Exception $e) {
Civi::log()->error('CRM_Core_Payment_OmnipayMultiProcessor::processPaymentNotification: ' . $e->getMessage());
}
}

$_REQUEST = $originalRequest;
$this->redirectOrExit('fail', $response);
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 @@
<url desc="Support">http://forum.civicrm.org</url>
<url desc="Licensing">http://civicrm.org/licensing</url>
</urls>
<releaseDate>2018-12-04</releaseDate>
<version>2.5_sagepay</version>
<releaseDate>2018-02-07</releaseDate>
<version>2.5_sagepay1</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
Expand Down

0 comments on commit a7ae3fd

Please sign in to comment.