From 4d485940eaa01ac93d7fb49d508806af588182d3 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 19 Sep 2023 15:30:58 +1000 Subject: [PATCH] fix: stripe customer fetch logic --- .../settings/billing/create-billing-portal.action.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts b/apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts index 98c3d2a96..331943648 100644 --- a/apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts +++ b/apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts @@ -26,8 +26,10 @@ export const createBillingPortal = async () => { } } - // Fallback to check if a Stripe customer already exists for the current user. - stripeCustomer = await getStripeCustomerByEmail(user.email); + // Fallback to check if a Stripe customer already exists for the current user email. + if (!stripeCustomer) { + stripeCustomer = await getStripeCustomerByEmail(user.email); + } // Create a Stripe customer if it does not exist for the current user. if (!stripeCustomer) {