Skip to content

Commit

Permalink
Catch payment processor exceptions, log, hide, do not return 500 error
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 9, 2019
1 parent 7aa9abe commit 26c3374
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1288,14 +1288,23 @@ public static function paypalRedirect(&$paymentProcessor) {
* Page callback for civicrm/payment/ipn
*/
public static function handleIPN() {
self::handlePaymentMethod(
'PaymentNotification',
array(
'processor_name' => @$_GET['processor_name'],
'processor_id' => @$_GET['processor_id'],
'mode' => @$_GET['mode'],
)
);
try {
self::handlePaymentMethod(
'PaymentNotification',
[
'processor_name' => CRM_Utils_Request::retrieveValue('processor_name', 'String'),
'processor_id' => CRM_Utils_Request::retrieveValue('processor_id', 'Integer'),
'mode' => CRM_Utils_Request::retrieveValue('mode', 'Alphanumeric'),
]
);
}
catch (CRM_Core_Exception $e) {
Civi::log()->error('payment_callback_exception', [
'context' => [
'backtrace' => CRM_Core_Error::formatBacktrace(debug_backtrace()),
]
]);
}
CRM_Utils_System::civiExit();
}

Expand Down Expand Up @@ -1357,7 +1366,7 @@ public static function handlePaymentMethod($method, $params = array()) {

// Check whether we found anything at all.
if (!$dao->N) {
CRM_Core_Error::fatal($notFound);
throw new CRM_Core_Exception($notFound);
}

$method = 'handle' . $method;
Expand Down Expand Up @@ -1401,7 +1410,7 @@ public static function handlePaymentMethod($method, $params = array()) {
if (!$extension_instance_found) {
$message = "No extension instances of the '%1' payment processor were found.<br />" .
"%2 method is unsupported in legacy payment processors.";
CRM_Core_Error::fatal(ts($message, array(1 => $params['processor_name'], 2 => $method)));
throw new CRM_Core_Exception(ts($message, array(1 => $params['processor_name'], 2 => $method)));
}
}

Expand Down

0 comments on commit 26c3374

Please sign in to comment.