From fcb2691938c317e13f6f25be8ddbb34efac8f655 Mon Sep 17 00:00:00 2001 From: Seif Ghezala Date: Wed, 23 Oct 2024 18:53:31 +0400 Subject: [PATCH] Check for redirect before catching error --- .../checkout/_parts/checkout-form/payment/button/stripe.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storefront/app/[countryCode]/(checkout)/checkout/_parts/checkout-form/payment/button/stripe.tsx b/storefront/app/[countryCode]/(checkout)/checkout/_parts/checkout-form/payment/button/stripe.tsx index 40b9b62..0727c11 100644 --- a/storefront/app/[countryCode]/(checkout)/checkout/_parts/checkout-form/payment/button/stripe.tsx +++ b/storefront/app/[countryCode]/(checkout)/checkout/_parts/checkout-form/payment/button/stripe.tsx @@ -5,6 +5,7 @@ import {Cta} from "@/components/shared/button"; import Body from "@/components/shared/typography/body"; import {useElements, useStripe} from "@stripe/react-stripe-js"; import {track} from "@vercel/analytics"; +import {isRedirectError} from "next/dist/client/components/redirect"; import {useState, useTransition} from "react"; export default function StripePaymentButton({ @@ -23,6 +24,10 @@ export default function StripePaymentButton({ await placeOrder(); track("checkout-completed"); } catch (err: any) { + if (isRedirectError(err)) { + throw err; + } + setErrorMessage(err.message); } });