From a83a1f47f25254f79d6028d5648dae64a40a5706 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 21 Sep 2020 12:16:48 +1200 Subject: [PATCH] [REF] Move not-actually shared-code out of shared code function On looking at the recur function it turns out it never calls without a paymentStatus of 'Completed' - so the lines handling other payment statuses are not actually shared between the 2 code paths but specifically belong to the 'main' (non-recur) code path. Moving it out of this function we start to see there is very little shared code & probably no case for the function to exist when we get down to it --- CRM/Core/Payment/PayPalIPN.php | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index d63203a155..9d3d2e3936 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -248,24 +248,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { $contribution->total_amount = $input['amount']; } - $status = $input['paymentStatus']; - 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') { - $this->cancelled($objects); - return; - } - 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) { @@ -366,6 +348,23 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { return; } } + $status = $input['paymentStatus']; + if ($status === 'Denied' || $status === 'Failed' || $status === 'Voided') { + $this->failed($objects); + return; + } + if ($status === 'Pending') { + Civi::log()->debug('Returning since contribution status is Pending'); + return; + } + if ($status === 'Refunded' || $status === 'Reversed') { + $this->cancelled($objects); + return; + } + if ($status !== 'Completed') { + Civi::log()->debug('Returning since contribution status is not handled'); + return; + } $this->single($input, $ids, $objects); } catch (CRM_Core_Exception $e) { -- 2.25.1