perf: move stripe to billing service out of app store (#20376)
* add more methods to billingService * update profile handler * stripe customer handler * verify email * move imports + move generic methods to billing service * move to strip ebilling service class * push changes to mocks * fix enum * fix typo * correctly update customer metadata * fix userId type to number * fix types on billing services * fix type errors due to return methods differing * fix return types
This commit is contained in:
1 parent
f15d347804
commit
5cd2ba1362
17 files changed
+116
-58
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import stripe from "@calcom/app-store/stripepayment/lib/server";
|
||||
import { StripeBillingService } from "@calcom/features/ee/billing/stripe-billling-service";
|
||||
|
||||
export async function getCustomerAndCheckoutSession(checkoutSessionId: string) {
|
||||
const checkoutSession = await stripe.checkout.sessions.retrieve(checkoutSessionId);
|
||||
const billingService = new StripeBillingService();
|
||||
const checkoutSession = await billingService.getCheckoutSession(checkoutSessionId);
|
||||
const customerOrCustomerId = checkoutSession.customer;
|
||||
let customerId = null;
|
||||
|
||||
@@ -16,7 +17,7 @@ export async function getCustomerAndCheckoutSession(checkoutSessionId: string) {
|
||||
} else {
|
||||
customerId = customerOrCustomerId.id;
|
||||
}
|
||||
const stripeCustomer = await stripe.customers.retrieve(customerId);
|
||||
const stripeCustomer = await billingService.getCustomer(customerId);
|
||||
if (stripeCustomer.deleted) {
|
||||
return { checkoutSession, stripeCustomer: null };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user