diff --git a/.changeset/petite-sites-see.md b/.changeset/petite-sites-see.md new file mode 100644 index 00000000000..16acfce61b5 --- /dev/null +++ b/.changeset/petite-sites-see.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Fix Stripe Elements error handling diff --git a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx index 90354c6d39c..1c5c3dfee56 100644 --- a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx +++ b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx @@ -246,18 +246,18 @@ const AddPaymentSourceForm = ({ children }: PropsWithChildren) => { card.setLoading(); card.setError(undefined); - try { - const { setupIntent, error } = await stripe.confirmSetup({ - elements, - confirmParams: { - return_url: '', // TODO(@COMMERCE): need to figure this out - }, - redirect: 'if_required', - }); - if (error) { - return; // just return, since stripe will handle the error - } + const { setupIntent, error } = await stripe.confirmSetup({ + elements, + confirmParams: { + return_url: '', // TODO(@COMMERCE): need to figure this out + }, + redirect: 'if_required', + }); + if (error) { + return; // just return, since stripe will handle the error + } + try { await onSuccess({ stripeSetupIntent: setupIntent }); } catch (error) { void handleError(error, [], card.setError);