Skip to content

Commit 46054bb

Browse files
committed
fix(clerk-js): Better Stripe Elements error handling
1 parent a2b466a commit 46054bb

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.changeset/petite-sites-see.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Fix Stripe Elements error handling

packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,18 @@ const AddPaymentSourceForm = ({ children }: PropsWithChildren) => {
246246
card.setLoading();
247247
card.setError(undefined);
248248

249-
try {
250-
const { setupIntent, error } = await stripe.confirmSetup({
251-
elements,
252-
confirmParams: {
253-
return_url: '', // TODO(@COMMERCE): need to figure this out
254-
},
255-
redirect: 'if_required',
256-
});
257-
if (error) {
258-
return; // just return, since stripe will handle the error
259-
}
249+
const { setupIntent, error } = await stripe.confirmSetup({
250+
elements,
251+
confirmParams: {
252+
return_url: '', // TODO(@COMMERCE): need to figure this out
253+
},
254+
redirect: 'if_required',
255+
});
256+
if (error) {
257+
return; // just return, since stripe will handle the error
258+
}
260259

260+
try {
261261
await onSuccess({ stripeSetupIntent: setupIntent });
262262
} catch (error) {
263263
void handleError(error, [], card.setError);

0 commit comments

Comments
 (0)