From abbbb4b928da94d8813ea4ee934c55da1cc84096 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 2 Sep 2025 23:02:01 +0100 Subject: [PATCH] chore(cloud): remove stripe customer creation from auth hook --- .../api/stripe/create_checkout_session.ts | 2 +- packages/auth/src/auth.ts | 22 +------------------ turbo.json | 6 ++++- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/apps/web/src/pages/api/stripe/create_checkout_session.ts b/apps/web/src/pages/api/stripe/create_checkout_session.ts index d4c7c0cd..8f8b9104 100644 --- a/apps/web/src/pages/api/stripe/create_checkout_session.ts +++ b/apps/web/src/pages/api/stripe/create_checkout_session.ts @@ -70,7 +70,7 @@ export default async function handler( mode: "subscription", line_items: [ { - price: process.env.STRIPE_PRO_PLAN_PRICE_ID, + price: process.env.STRIPE_PRO_PLAN_MONTHLY_PRICE_ID, quantity: 1, }, ], diff --git a/packages/auth/src/auth.ts b/packages/auth/src/auth.ts index 389b826f..f972f48a 100644 --- a/packages/auth/src/auth.ts +++ b/packages/auth/src/auth.ts @@ -317,27 +317,7 @@ export const initAuth = (db: dbClient) => { }, hooks: { after: createAuthMiddleware(async (ctx) => { - if (ctx.path.startsWith("/get-session")) { - const user = ctx.context.session?.user; - - if ( - env("NEXT_PUBLIC_KAN_ENV") === "cloud" && - user && - !user.stripeCustomerId - ) { - const stripe = createStripeClient(); - const stripeCustomer = await stripe.customers.create({ - email: user.email, - metadata: { - userId: user.id, - }, - }); - - await userRepo.update(db, user.id, { - stripeCustomerId: stripeCustomer.id, - }); - } - } else if ( + if ( ctx.path === "/magic-link/verify" && (ctx.query?.callbackURL as string | undefined)?.includes( "type=invite", diff --git a/turbo.json b/turbo.json index 7427220b..cdd708c2 100644 --- a/turbo.json +++ b/turbo.json @@ -99,7 +99,11 @@ "NEXT_PUBLIC_WHITE_LABEL_HIDE_POWERED_BY", "STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET", - "STRIPE_PRO_PLAN_PRICE_ID", + "STRIPE_WEBHOOK_SECRET_LEGACY", + "STRIPE_PRO_PLAN_MONTHLY_PRICE_ID", + "STRIPE_PRO_PLAN_YEARLY_PRICE_ID", + "STRIPE_TEAM_PLAN_MONTHLY_PRICE_ID", + "STRIPE_TEAM_PLAN_YEARLY_PRICE_ID", "NEXT_PUBLIC_STORAGE_DOMAIN", "NEXT_PUBLIC_STORAGE_URL", "NEXT_PUBLIC_AVATAR_BUCKET_NAME",