fix: only use client secrets if there's no providerMethodId set

This commit is contained in:
Arman authored and Torsten Dittmann committed 2024-02-21 10:32:40 +01:00
1 parent 979073bdf7
commit 2e7426a882
1 file changed
+6 -1
+6 -1
View File
@@ -19,7 +19,12 @@ export async function initializeStripe() {
isStripeInitialized.set(true);
const methods = await sdk.forConsole.billing.listPaymentMethods();
clientSecret = methods.paymentMethods[0]?.clientSecret;
// Get the client secret from empty payment method if available
clientSecret = methods.paymentMethods?.filter(
(method) => !!method?.clientSecret && !method?.providerMethodId
)[0]?.clientSecret;
// If there is no payment method, create an empty one and get the client secret
if (!clientSecret) {
paymentMethod = await sdk.forConsole.billing.createPaymentMethod();