X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPayment%2FPayPalIPN.php;h=b6948ddbd47b2f10cbea78e55e9e9a6daeff99e6;hb=0bdc815a4d495be16ddfb505d38d16e40655caaf;hp=be0424f7afd5cb3f3298f575ba970186659ade10;hpb=8011b900b037435fd9d779de90f2da4867516858;p=civicrm-core.git diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index be0424f7af..b6948ddbd4 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -13,7 +13,6 @@ * * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing - * */ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { @@ -230,8 +229,10 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { * @param bool $first * * @return void + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ - public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE) { + public function single($input, $ids, $objects, $recur = FALSE, $first = FALSE) { $contribution = &$objects['contribution']; // make sure the invoice is valid and matches what we have in the contribution record @@ -257,18 +258,18 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { $contribution->total_amount = $input['amount']; } - $transaction = new CRM_Core_Transaction(); - $status = $input['paymentStatus']; - if ($status == 'Denied' || $status == 'Failed' || $status == 'Voided') { - return $this->failed($objects, $transaction); + if ($status === 'Denied' || $status === 'Failed' || $status === 'Voided') { + $this->failed($objects); + return; } if ($status === 'Pending') { Civi::log()->debug('Returning since contribution status is Pending'); return; } - elseif ($status == 'Refunded' || $status == 'Reversed') { - return $this->cancelled($objects, $transaction); + elseif ($status === 'Refunded' || $status === 'Reversed') { + $this->cancelled($objects); + return; } elseif ($status !== 'Completed') { Civi::log()->debug('Returning since contribution status is not handled'); @@ -278,13 +279,12 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { // 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
'; return; } - $this->completeTransaction($input, $ids, $objects, $transaction, $recur); + $this->completeTransaction($input, $ids, $objects); } /** @@ -303,7 +303,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { $membershipID = $this->retrieve('membershipID', 'Integer', FALSE); $contributionRecurID = $this->retrieve('contributionRecurID', 'Integer', FALSE); - $this->getInput($input, $ids); + $this->getInput($input); if ($component == 'event') { $ids['event'] = $this->retrieve('eventID', 'Integer', TRUE); @@ -371,17 +371,16 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { return; } } - $this->single($input, $ids, $objects, FALSE, FALSE); + $this->single($input, $ids, $objects); } /** * @param array $input - * @param array $ids * * @throws \CRM_Core_Exception */ - public function getInput(&$input, &$ids) { - $billingID = $ids['billing'] = CRM_Core_BAO_LocationType::getBilling(); + public function getInput(&$input) { + $billingID = CRM_Core_BAO_LocationType::getBilling(); $input['txnType'] = $this->retrieve('txn_type', 'String', FALSE); $input['paymentStatus'] = $this->retrieve('payment_status', 'String', FALSE); $input['invoice'] = $this->retrieve('invoice', 'String', TRUE);