switch (event.type) {
case 'checkout.session.completed':
// The user paid successfully and the subscription was created (if any exists)
// Here you should provide access to your customer and send him an email.
// You can use UpgradeEmail.
await checkoutSessionCompleted(event);
break;
case 'checkout.session.expired':
// The user didn't completed the transaction
// You can optionally send an email to track the reasons behind it.
await checkoutSessionExpired(event);
break;
case 'customer.subscription.updated':
// The user updated it subscription for some reason, upgraded the plan, changed the quota, his payment method, etc.
// You should check if something changed between your database and Stripe.
await customerSubscriptionUpdated(event);
break;
case 'customer.subscription.deleted':
// The subscription was canceled.
// You should revoke the access.
await customerSubscriptionDeleted(event);
break;
case 'invoice.paid':
// A payment was made, triggered from a recurring subscription or a order payment.
// You should provide acess to your customer and or emit a custom invoice.
await invoicePaid(event);
break;
case 'invoice.payment_failed':
// A payment failed, triggered from a recurring subscription or a order payment.
// You should:
// Revoke Access based on some criteria (3 failed attemps)
// Send the user an email to update his payment method and wait the 'customer.subscription.deleted' event.
await invoicePaymentFailed(event);
break;
}