From 390e01535be0c7578db2d6b7bf5ea52ad6f41a0e Mon Sep 17 00:00:00 2001 From: giancarlo Date: Fri, 7 Jun 2024 01:46:36 +0700 Subject: [PATCH] Remove 'invoice.paid' event handler in Stripe webhook service The 'invoice.paid' event has been removed from the Stripe webhook handler service. The corresponding method handleInvoicePaid and the case in the switch statement have been deleted. --- .../stripe-webhook-handler.service.ts | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/packages/billing/stripe/src/services/stripe-webhook-handler.service.ts b/packages/billing/stripe/src/services/stripe-webhook-handler.service.ts index 816740e7f..c90568e97 100644 --- a/packages/billing/stripe/src/services/stripe-webhook-handler.service.ts +++ b/packages/billing/stripe/src/services/stripe-webhook-handler.service.ts @@ -100,10 +100,6 @@ export class StripeWebhookHandlerService return this.handleAsyncPaymentFailed(event, params.onPaymentFailed); } - case 'invoice.paid': { - return this.handleInvoicePaid(event, params.onInvoicePaid); - } - case 'checkout.session.async_payment_succeeded': { return this.handleAsyncPaymentSucceeded( event, @@ -320,34 +316,6 @@ export class StripeWebhookHandlerService }; } - private async handleInvoicePaid( - event: Stripe.InvoicePaidEvent, - onInvoicePaid: (params: UpsertSubscriptionParams) => Promise, - ) { - const stripe = await this.loadStripe(); - - const subscriptionId = event.data.object.subscription as string; - const subscription = await stripe.subscriptions.retrieve(subscriptionId); - - const accountId = subscription.metadata.accountId as string; - - const payload = this.buildSubscriptionPayload({ - customerId: subscription.customer as string, - id: subscriptionId, - accountId, - lineItems: subscription.items.data, - status: subscription.status, - currency: subscription.currency, - periodStartsAt: subscription.current_period_start, - periodEndsAt: subscription.current_period_end, - cancelAtPeriodEnd: subscription.cancel_at_period_end, - trialStartsAt: subscription.trial_start, - trialEndsAt: subscription.trial_end, - }); - - return onInvoicePaid(payload); - } - private async loadStripe() { if (!this.stripe) { this.stripe = await createStripeClient();