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.
This commit is contained in:
@@ -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<unknown>,
|
||||
) {
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user