From d8e1e2fb5f441d8d4146eb515fd7ed35f1a0f9c3 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Tue, 27 Sep 2016 03:16:29 +0530 Subject: [PATCH] CRM-18483: Paypal Std transaction failure fix --- CRM/Core/Payment/BaseIPN.php | 6 ++++++ CRM/Core/Payment/PayPalIPN.php | 2 +- CRM/Core/Payment/PayPalImpl.php | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 49e3c70480..0b298b94d4 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -75,6 +75,12 @@ class CRM_Core_Payment_BaseIPN { if (!is_array($parameters)) { throw new CRM_Core_Exception('Invalid input parameters'); } + // some times the essential GET parameters got lost in IPN response, + // so fetch those variable from json encoded 'custom' parameter to provide data integritiy + elseif (CRM_Utils_Array::value('custom', $parameters)) { + $customParams = (array) json_decode($parameters['custom']); + $params = array_merge($customParams, $params); + } $this->_inputParameters = $parameters; } diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index b5bbcbe0af..6bdc0e4623 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -334,7 +334,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { } $paymentProcessorID = $this->retrieve('processor_id', 'Integer', FALSE); - if (!empty($paymentProcessorID)) { + if (empty($paymentProcessorID)) { $processorParams = array( 'user_name' => $this->retrieve('receiver_email', 'String', FALSE), 'payment_processor_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'PayPal_Standard', 'id', 'name'), diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 1634c93f1a..c996175f39 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -829,6 +829,9 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { TRUE, NULL, FALSE ); + $customParams = array_merge($notifyParameters, array( + 'accountingCode' => CRM_Utils_Array::value('accountingCode', $params), + )); $paypalParams = array( 'business' => $this->_paymentProcessor['user_name'], 'notify_url' => $notifyURL, @@ -844,7 +847,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 'invoice' => $params['invoiceID'], 'lc' => substr($config->lcMessages, -2), 'charset' => function_exists('mb_internal_encoding') ? mb_internal_encoding() : 'UTF-8', - 'custom' => CRM_Utils_Array::value('accountingCode', $params), + 'custom' => json_encode($customParams), 'bn' => 'CiviCRM_SP', ); -- 2.25.1