Skip to content

Commit

Permalink
Merge pull request #17499 from eileenmcnaughton/unhandled
Browse files Browse the repository at this point in the history
[Ref] Remove calls to, and deprecate, unhandled function
  • Loading branch information
seamuslee001 authored Jun 8, 2020
2 parents f08e7a4 + 85ce114 commit 911365c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions CRM/Core/Payment/BaseIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,18 @@ public function cancelled(&$objects, &$transaction, $input = []) {
/**
* Rollback unhandled outcomes.
*
* @deprecated
*
* @param array $objects
* @param CRM_Core_Transaction $transaction
*
* @return bool
*/
public function unhandled(&$objects, &$transaction) {
CRM_Core_Error::deprecatedFunctionWarning('This function will be removed at some point');
$transaction->rollback();
Civi::log()->debug("Returning since contribution status is not handled");
echo "Failure: contribution status is not handled<p>";
Civi::log()->debug('Returning since contribution status is not handled');
echo 'Failure: contribution status is not handled<p>';
return FALSE;
}

Expand Down
7 changes: 4 additions & 3 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,17 @@ public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE
elseif ($status == 'Refunded' || $status == 'Reversed') {
return $this->cancelled($objects, $transaction);
}
elseif ($status != 'Completed') {
return $this->unhandled($objects, $transaction);
elseif ($status !== 'Completed') {
Civi::log()->debug('Returning since contribution status is not handled');
return;
}

// check if contribution is already completed, if so we ignore this ipn
$completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if ($contribution->contribution_status_id == $completedStatusId) {
$transaction->commit();
Civi::log()->debug('PayPalIPN: Returning since contribution has already been handled. (ID: ' . $contribution->id . ').');
echo "Success: Contribution has already been handled<p>";
echo 'Success: Contribution has already been handled<p>';
return;
}

Expand Down
6 changes: 3 additions & 3 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE
$this->cancelled($objects, $transaction);
return;
}
elseif ($status != 'Completed') {
$this->unhandled($objects, $transaction);
elseif ($status !== 'Completed') {
Civi::log()->debug('Returning since contribution status is not handled');
return;
}

Expand All @@ -369,7 +369,7 @@ public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE
if ($contribution->contribution_status_id == $completedStatusId) {
$transaction->commit();
Civi::log()->debug('PayPalProIPN: Returning since contribution has already been handled.');
echo "Success: Contribution has already been handled<p>";
echo 'Success: Contribution has already been handled<p>';
return;
}

Expand Down

0 comments on commit 911365c

Please sign in to comment.