Created
January 15, 2023 23:45
-
-
Save dipeshhkc/e0789d24c68c07dee0d090060c73fcf4 to your computer and use it in GitHub Desktop.
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 characters
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 }); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment