diff --git a/app/Exceptions/PaymentFailed.php b/app/Exceptions/PaymentFailed.php index 55762f03fd8a..7c0f2cb67711 100644 --- a/app/Exceptions/PaymentFailed.php +++ b/app/Exceptions/PaymentFailed.php @@ -13,7 +13,7 @@ class PaymentFailed extends Exception public function render($request) { - if (auth()->user()) { + if (auth()->user() || ($request->has('cko-session-id') && $request->query('cko-session-id') )) { return render('gateways.unsuccessful', [ 'message' => $this->getMessage(), 'code' => $this->getCode(), diff --git a/app/PaymentDrivers/CheckoutCom/Utilities.php b/app/PaymentDrivers/CheckoutCom/Utilities.php index 85b7bf0c5da9..eddc38495eba 100644 --- a/app/PaymentDrivers/CheckoutCom/Utilities.php +++ b/app/PaymentDrivers/CheckoutCom/Utilities.php @@ -84,8 +84,15 @@ trait Utilities public function processUnsuccessfulPayment(Payment $_payment, $throw_exception = true) { - $this->getParent()->sendFailureMail($_payment->response_summary); - // $this->getParent()->clientPaymentFailureMailer($_payment->status); + + $error_message = ''; + + if(property_exists($_payment, 'server_response')) + $error_message = $_payment->response_summary; + elseif(property_exists($_payment, 'status')) + $error_message = $_payment->status; + + $this->getParent()->sendFailureMail($error_message); $message = [ 'server_response' => $_payment, @@ -102,7 +109,8 @@ trait Utilities ); if ($throw_exception) { - throw new PaymentFailed($_payment->status . " " . optional($_payment)->response_summary, $_payment->http_code); + + throw new PaymentFailed($_payment->status . " " . $error_message, $_payment->http_code); } }