From c5cf3602b065b8421648ae8585c3b9933d6df2cf Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Thu, 26 Apr 2018 08:30:47 +0530 Subject: [PATCH] core/issues/78 - Incorrect Payment Processor for Recurring Payments --- CRM/Core/Payment/AuthorizeNetIPN.php | 34 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index ae1e750530..6c46bd721f 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -67,20 +67,26 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { // load post ids in $ids $this->getIDs($ids, $input); - // 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', - 'AuthNet', 'id', 'name' - ); - $paymentProcessorID = (int) civicrm_api3('PaymentProcessor', 'getvalue', array( - 'is_test' => 0, - 'options' => array('limit' => 1), - 'payment_processor_type_id' => $paymentProcessorTypeID, - 'return' => 'id', - )); + // Attempt to get payment processor ID from URL + if (!empty($this->_inputParameters['processor_id'])) { + $paymentProcessorID = $this->_inputParameters['processor_id']; + } + else { + // 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', + 'AuthNet', '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; -- 2.25.1