From f45cd81b5f239fa3009493df238c3eecb9e3faf4 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Mon, 18 Sep 2023 22:47:46 +1000 Subject: [PATCH] feat: wip --- .../settings/billing/create-billing-portal.action.ts | 4 ++-- apps/web/src/pages/api/stripe/webhook/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 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 f235cb846..d42d1e97e 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 @@ -40,10 +40,10 @@ export const createBillingPortal = async () => { }); } - const stripeCustomerSubsriptions = stripeCustomer.subscriptions?.data ?? []; + const stripeCustomerSubscriptions = stripeCustomer.subscriptions?.data ?? []; // Create a free subscription for user if it does not exist. - if (!existingSubscription && stripeCustomerSubsriptions.length === 0) { + if (!existingSubscription && stripeCustomerSubscriptions.length === 0) { const newSubscription = await stripe.subscriptions.create({ customer: stripeCustomer.id, items: [ diff --git a/apps/web/src/pages/api/stripe/webhook/index.ts b/apps/web/src/pages/api/stripe/webhook/index.ts index 06f63e293..9f1a6937a 100644 --- a/apps/web/src/pages/api/stripe/webhook/index.ts +++ b/apps/web/src/pages/api/stripe/webhook/index.ts @@ -212,7 +212,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const handleCustomerSubscriptionUpdated = async (subscription: Stripe.Subscription) => { // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - const plan = (subscription as unknown as Stripe.SubscriptionItem).plan; + const { plan } = subscription as unknown as Stripe.SubscriptionItem; const customerId = typeof subscription.customer === 'string' ? subscription.customer : subscription.customer.id;