From be28d9d96a2954271fa55ab0a4520f632b3956e5 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 27 Jun 2024 19:20:37 +0200 Subject: [PATCH] :ambulance: (billing) Fix checkout session email check --- ee/packages/billing/api/createCheckoutSession.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ee/packages/billing/api/createCheckoutSession.ts b/ee/packages/billing/api/createCheckoutSession.ts index ff2aee8f8..8dd560fd9 100644 --- a/ee/packages/billing/api/createCheckoutSession.ts +++ b/ee/packages/billing/api/createCheckoutSession.ts @@ -78,7 +78,10 @@ export const createCheckoutSession = async ({ email, }) - if (existingCustomer && email !== existingCustomer.data[0].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',