From 9b344b95d9c89c7dccdb2628da037e1b7a2a8cf6 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 29 Sep 2020 10:14:59 +1300 Subject: [PATCH] [REF] Parse ids before sending to single function (minor simplification) Overview ---------------------------------------- Minor simplification - parse ids into valid format & pass them into single, rather than passing them in wrong & 'asking' singleto parse them Before ---------------------------------------- parsing of ids into usable array done at the last minute, other values passes around unnecessarily After ---------------------------------------- parsing done close to the point where they are derived Technical Details ---------------------------------------- Comments ---------------------------------------- --- CRM/Core/Payment/PayPalIPN.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 2a3616fce0..c9e35fae42 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -206,7 +206,11 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { return; } - $this->single($input, $ids, $objects, TRUE); + $this->single($input, [ + 'related_contact' => $ids['related_contact'] ?? NULL, + 'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL, + 'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL, + ], $objects, TRUE); } /** @@ -248,11 +252,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { return; } - CRM_Contribute_BAO_Contribution::completeOrder($input, [ - 'related_contact' => $ids['related_contact'] ?? NULL, - 'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL, - 'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL, - ], $objects); + CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects); } /** @@ -359,7 +359,11 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { Civi::log()->debug('Returning since contribution status is not handled'); return; } - $this->single($input, $ids, $objects); + $this->single($input, [ + 'related_contact' => $ids['related_contact'] ?? NULL, + 'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL, + 'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL, + ], $objects); } catch (CRM_Core_Exception $e) { Civi::log()->debug($e->getMessage()); -- 2.25.1