From 8f741ea7ae1d94403908928757dcfef99fe4d513 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 2 Jul 2024 09:59:30 +0200 Subject: [PATCH] :rewind: Revert checkout session update existing customer An email should not be tied to a Stripe customer Closes #1615 --- .../billing/api/createCheckoutSession.ts | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/ee/packages/billing/api/createCheckoutSession.ts b/ee/packages/billing/api/createCheckoutSession.ts index 8dd560fd90..8c3f570a86 100644 --- a/ee/packages/billing/api/createCheckoutSession.ts +++ b/ee/packages/billing/api/createCheckoutSession.ts @@ -74,31 +74,14 @@ export const createCheckoutSession = async ({ }, }) - const existingCustomer = await stripe.customers.list({ - email, - }) - - if ( - existingCustomer.data.length > 0 && - user.email !== existingCustomer.data.at(0)?.email - ) - throw new TRPCError({ - code: 'BAD_REQUEST', - message: 'Make sure to log in with the same email as the one provided', - }) - - const customerData = { + const customer = await stripe.customers.create({ email, name: company, metadata: { workspaceId }, tax_id_data: vat ? [vat as Stripe.CustomerCreateParams.TaxIdDatum] : undefined, - } - const customer = - existingCustomer.data.length > 0 - ? await stripe.customers.update(existingCustomer.data[0].id, customerData) - : await stripe.customers.create(customerData) + }) const checkoutUrl = await createCheckoutSessionUrl(stripe)({ customerId: customer.id,