From 79a620cd584cfbf099a79a81df98f335106f6d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Tue, 30 Jul 2024 13:20:02 +0200 Subject: [PATCH] handle error --- src/StripeDriver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/StripeDriver.php b/src/StripeDriver.php index 47afc25..92f178a 100644 --- a/src/StripeDriver.php +++ b/src/StripeDriver.php @@ -14,6 +14,7 @@ use Stripe\Event; use Stripe\StripeClient; use Stripe\Webhook; +use Throwable; class StripeDriver extends Driver { @@ -87,7 +88,11 @@ protected function createSession(Order $order): Session */ public function handleCheckout(Request $request, Order $order): Response { - $session = $this->createSession($order); + try { + $session = $this->createSession($order); + } catch (Throwable $exception) { + return new Response($this->getFailureUrl($order), $order->toArray()); + } $response = parent::handleCheckout($request, $order);