diff --git a/app/Exceptions/PaymentFailed.php b/app/Exceptions/PaymentFailed.php new file mode 100644 index 000000000000..06d3f9dda5cb --- /dev/null +++ b/app/Exceptions/PaymentFailed.php @@ -0,0 +1,21 @@ + $this->getMessage(), + 'code' => $this->getCode(), + ]); + } +} diff --git a/app/PaymentDrivers/CheckoutCom/Utilities.php b/app/PaymentDrivers/CheckoutCom/Utilities.php index 1deaf8b70840..8b7ce1135918 100644 --- a/app/PaymentDrivers/CheckoutCom/Utilities.php +++ b/app/PaymentDrivers/CheckoutCom/Utilities.php @@ -12,6 +12,7 @@ namespace App\PaymentDrivers\CheckoutCom; +use App\Exceptions\PaymentFailed; use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; use App\Models\PaymentType; @@ -92,10 +93,7 @@ trait Utilities $this->checkout->client ); - return render('gateways.unsuccessful', [ - 'code' => $_payment->http_code, - 'message' => $_payment->status, - ]); + throw new PaymentFailed($_payment->status, $_payment->http_code); } private function processPendingPayment(\Checkout\Models\Payments\Payment $_payment) @@ -148,9 +146,6 @@ trait Utilities $this->checkout->client, ); - return render('gateways.unsuccessful', [ - 'error' => $e->getCode(), - 'message' => $error, - ]); + throw new PaymentFailed($error, $e->getCode()); } }