Commit ce6554d8 authored by capo's avatar capo Committed by mattwire

Implements setExceptionMode to allow skipping the exit on exception policy

parent f90b4065
......@@ -34,6 +34,11 @@ trait CRM_Core_Payment_MJWIPNTrait {
*/
protected $event_type = NULL;
/**
* Exit on exceptions (TRUE), or just throw them (FALSE).
*/
protected $exitOnException = TRUE;
/**
* Set the value of is_email_receipt to use when a new contribution is received for a recurring contribution
* If not set, we respect the value set on the ContributionRecur entity.
......@@ -311,6 +316,17 @@ trait CRM_Core_Payment_MJWIPNTrait {
]);
}
/**
* Switch between "exit on exception" mode and "regular exception handling".
*
* @param bool $exitOnException Switch between:
* - TRUE (default): Exit with HTTP response code 400 when an exception occurs
* - FALSE: Just throw the exception regularly
*/
public function setExceptionMode($exitOnException) {
$this->exitOnException = $exitOnException;
}
/**
* Log and throw an IPN exception
*
......@@ -319,7 +335,11 @@ trait CRM_Core_Payment_MJWIPNTrait {
protected function exception($message) {
$errorMessage = $this->_paymentProcessor->getPaymentProcessorLabel() . ' Exception: Event: ' . $this->event_type . ' Error: ' . $message;
Civi::log()->debug($errorMessage);
http_response_code(400);
exit(1);
if ($this->exitOnException) {
http_response_code(400);
exit(1);
} else {
throw new Exception($message);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment