CRM-16923 fix passing on incorrect value for payment processor id frompaypal
authoreileenmcnaughton <eileen@fuzion.co.nz>
Thu, 30 Jul 2015 00:04:23 +0000 (00:04 +0000)
committereileenmcnaughton <eileen@fuzion.co.nz>
Thu, 30 Jul 2015 00:04:23 +0000 (00:04 +0000)
CRM/Core/Payment/PayPalProIPN.php

index 9676338f81f84fa71cbc0d78d482c0170ac37a6a..cd1c2a6cf53a0e19bdfef047a45757b373a2502c 100644 (file)
@@ -441,9 +441,20 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr
       }
     }
 
-    $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
+    // This is an unreliable method as there could be more than one instance.
+    // Recommended approach is to use the civicrm/payment/ipn/xx url where xx is the payment
+    // processor id & the handleNotification function (which should call the completetransaction api & by-pass this
+    // entirely). The only thing the IPN class should really do is extract data from the request, validate it
+    // & call completetransaction or call fail? (which may not exist yet).
+    $paymentProcessorTypeID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
       'PayPal', 'id', 'name'
     );
+    $paymentProcessorID = (int) civicrm_api3('PaymentProcessor', 'getvalue', array(
+      'is_test' => 0,
+      'options' => array('limit' => 1),
+      'payment_processor_type_id' => $paymentProcessorTypeID,
+      'return' => 'id',
+    ));
 
     if (!$this->validateData($input, $ids, $objects, TRUE, $paymentProcessorID)) {
       return FALSE;