CRM-18483: Paypal Std transaction failure fix
authordeb.monish <monish.deb@webaccessglobal.com>
Mon, 26 Sep 2016 21:46:29 +0000 (03:16 +0530)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 9 Oct 2016 20:39:41 +0000 (07:39 +1100)
CRM/Core/Payment/BaseIPN.php
CRM/Core/Payment/PayPalIPN.php
CRM/Core/Payment/PayPalImpl.php

index 49e3c704809383e3787210e90a22975bf6a87ad9..0b298b94d4ac6cc689696d276123027c40aa4618 100644 (file)
@@ -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;
   }
 
index b5bbcbe0af4a8595a1039d9d7409157d8ae08de5..6bdc0e4623e5d59c5a197e64b6bda4e93980b30b 100644 (file)
@@ -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'),
index 1634c93f1ab308ab9355f1a2f160b60f2bd74b6c..c996175f390cb9c3f721d8f930cce7c2b729ce8f 100644 (file)
@@ -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',
     );