Created
January 15, 2023 23:45
-
-
Save dipeshhkc/e0789d24c68c07dee0d090060c73fcf4 to your computer and use it in GitHub Desktop.
Revisions
-
dipeshhkc created this gist
Jan 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ export const handleStripeEvent = async ( type: string, data: Stripe.Event.Data, id: string ) => { try { const isTestEvent = id === 'evt_00000000000000'; if (isTestEvent) { return; } switch (type) { case 'checkout.session.completed': await handleCheckoutSessionCompleted(data.object); break; case 'customer.subscription.updated': await handleCustomerSubscriptionUpdated(data.object); break; case 'invoice.paid': await handleInvoicePaid(data.object); break; case 'invoice.payment_failed': await handleInvoicePaymentFailed(data.object); break; case 'customer.subscription.deleted': await handleCustomerSubscriptionDeleted(data.object); break; } return true; } catch (e) { console.log({ message: e }); } };