diff --git a/app/Exceptions/PaymentFailed.php b/app/Exceptions/PaymentFailed.php index 06d3f9dda5..55762f03fd 100644 --- a/app/Exceptions/PaymentFailed.php +++ b/app/Exceptions/PaymentFailed.php @@ -13,7 +13,14 @@ class PaymentFailed extends Exception public function render($request) { - return render('gateways.unsuccessful', [ + if (auth()->user()) { + return render('gateways.unsuccessful', [ + 'message' => $this->getMessage(), + 'code' => $this->getCode(), + ]); + } + + return response([ 'message' => $this->getMessage(), 'code' => $this->getCode(), ]);