in packages/fxa-auth-server/lib/routes/subscriptions/stripe-webhook.ts [147:227]
private async dispatchEventToHandler(
request: AuthRequest,
event: Stripe.Event,
firestoreHandled: boolean
) {
switch (event.type as Stripe.WebhookEndpointUpdateParams.EnabledEvent) {
case 'credit_note.created':
if (this.paypalHelper) {
await this.handleCreditNoteEvent(request, event);
}
break;
case 'coupon.created':
case 'coupon.updated':
await this.handleCouponEvent(request, event);
break;
case 'customer.created':
// We don't need to setup the local customer if it happened via API
// because we already set this up during creation.
if (event.request?.id) {
break;
}
await this.handleCustomerCreatedEvent(request, event);
break;
case 'customer.subscription.created':
await this.handleSubscriptionCreatedEvent(request, event);
break;
case 'customer.subscription.updated':
await this.handleSubscriptionUpdatedEvent(request, event);
break;
case 'customer.subscription.deleted':
await this.handleSubscriptionDeletedEvent(request, event);
break;
case 'customer.source.expiring':
await this.handleCustomerSourceExpiringEvent(request, event);
break;
case 'customer.updated':
await this.handleCustomerUpdatedEvent(request, event);
break;
case 'invoice.created':
await this.handleInvoiceCreatedEvent(request, event);
break;
case 'invoice.paid':
await this.handleInvoicePaidEvent(request, event);
break;
case 'invoice.payment_failed':
await this.handleInvoicePaymentFailedEvent(request, event);
break;
case 'invoice.upcoming':
await this.handleInvoiceUpcomingEvent(request, event);
break;
case 'product.created':
case 'product.updated':
case 'product.deleted':
await this.handleProductWebhookEvent(request, event);
break;
case 'plan.created':
case 'plan.updated':
await this.handlePlanCreatedOrUpdatedEvent(request, event);
break;
case 'plan.deleted':
await this.handlePlanDeletedEvent(request, event);
break;
case 'tax_rate.created':
case 'tax_rate.updated':
await this.handleTaxRateCreatedOrUpdatedEvent(request, event);
break;
default:
if (!firestoreHandled) {
Sentry.withScope((scope) => {
scope.setContext('stripeEvent', {
event: { id: event.id, type: event.type },
});
reportSentryMessage(
'Unhandled Stripe event received.',
'info' as SeverityLevel
);
});
}
break;
}
}