From 08e6409d596423e072163749b2111bcff3e0dec6 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Tue, 6 Mar 2018 22:38:57 -0600 Subject: [PATCH] Fix for CRM-20608: IPN thinks Paypal Pro is Standard. --- CRM/Core/Payment/PayPalImpl.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index ae9ea60a24..1f8c5db76e 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -702,15 +702,30 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { if (is_numeric($lastParam)) { $params['processor_id'] = $lastParam; } - if (civicrm_api3('PaymentProcessor', 'getvalue', array( - 'id' => $params['processor_id'], - 'return' => 'class_name') - ) == 'Payment_PayPalImpl') { - $paypalIPN = new CRM_Core_Payment_PayPalIPN($params); - } - else { - $paypalIPN = new CRM_Core_Payment_PayPalProIPN($params); + $result = civicrm_api3('PaymentProcessor', 'get', array( + 'sequential' => 1, + 'id' => $params['processor_id'], + 'api.PaymentProcessorType.getvalue' => array('return' => "name"), + )); + switch ($result['values'][0]['api.PaymentProcessorType.getvalue']) { + case 'PayPal': + // "PayPal - Website Payments Pro" + $paypalIPN = new CRM_Core_Payment_PayPalProIPN($params); + break; + + case 'PayPal_Standard': + // "PayPal - Website Payments Standard" + $paypalIPN = new CRM_Core_Payment_PayPalIPN($params); + break; + + default: + // If we don't have PayPal Standard or PayPal Pro, something's wrong. + // Log an error and exit. + CRM_Core_Error::debug_log_message("The processor_id value '{$params['processor_id']}' is for a processor of type '{$result['values'][0]['api.PaymentProcessorType.getvalue']}', which is invalid in this context."); + echo "Failure: Invalid processor: " . CRM_Utils_Type::escape($params['processor_id'], 'String'); + exit(); } + $paypalIPN->main(); } -- 2.25.1