From 4346da4bc874633c318edbdfbdd3d9e6d4601522 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 23 Nov 2015 11:39:03 +1300 Subject: [PATCH] CRM-17610 replace exits with exceptions in IPN processing --- CRM/Core/Payment/AuthorizeNetIPN.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index 97f35ba2ec..d0d59dac13 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -272,10 +272,10 @@ INNER JOIN civicrm_contribution co ON co.contribution_recur_id = cr.id $ids['contact'] = $contRecur->contact_id; } if (!$ids['contributionRecur']) { - $message = ts("Could not find contributionRecur id: %1", array(1 => htmlspecialchars(print_r($input, TRUE)))); - CRM_Core_Error::debug_log_message($message); - echo "Failure: $message

"; - exit(); + $message = ts("Could not find contributionRecur id"); + $log = new CRM_Utils_SystemLogger(); + $log->error('payment_notification', array('message' => $message, 'ids' => $ids, 'input' => $input)); + throw new CRM_Core_Exception($message); } // get page id based on contribution id @@ -331,10 +331,14 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr } /** - * @param $ids - * @param $input + * Check that the MDs is valid. * - * @return bool + * Note that this only checks if it is provided. + * + * @param array $ids + * @param array $input + * + * @throws CRM_Core_Exception */ public function checkMD5($ids, $input) { $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ids['paymentProcessor'], @@ -343,11 +347,11 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr $paymentObject = CRM_Core_Payment::singleton($input['is_test'] ? 'test' : 'live', $paymentProcessor); if (!$paymentObject->checkMD5($input['MD5_Hash'], $input['trxn_id'], $input['amount'], TRUE)) { - CRM_Core_Error::debug_log_message("MD5 Verification failed."); - echo "Failure: Security verification failed

"; - exit(); + $message = "Failure: Security verification failed"; + $log = new CRM_Utils_SystemLogger(); + $log->error('payment_notification', array('message' => $message, 'ids' => $ids, 'input' => $input)); + throw new CRM_Core_Exception($message); } - return TRUE; } } -- 2.25.1