@coursebuilder/core
Version:
Core package for Course Builder
1 lines • 3.27 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/inngest/stripe/event-invoice-payment-succeeded.ts"],"sourcesContent":["import { InvoicePaymentSucceededEvent } from 'src/schemas/stripe/invoice-payment-succeeded'\n\nimport {\n\tCoreInngestFunctionInput,\n\tCoreInngestHandler,\n\tCoreInngestTrigger,\n} from '../create-inngest-middleware'\n\nexport const STRIPE_INVOICE_PAYMENT_SUCCEEDED_EVENT =\n\t'stripe/invoice-payment-succeeded'\n\nexport type StripeInvoicePaymentSucceeded = {\n\tname: typeof STRIPE_INVOICE_PAYMENT_SUCCEEDED_EVENT\n\tdata: {\n\t\tstripeEvent: InvoicePaymentSucceededEvent\n\t}\n}\n\nexport const stripeInvoicePaymentSucceededConfig = {\n\tid: 'stripe-invoice-payment-succeeded',\n\tname: 'Stripe Invoice Payment Succeeded',\n}\n\nexport const stripeInvoicePaymentSucceededTrigger: CoreInngestTrigger = {\n\tevent: STRIPE_INVOICE_PAYMENT_SUCCEEDED_EVENT,\n}\n\nexport const stripeInvoicePaymentSucceededHandler: CoreInngestHandler = async ({\n\tevent,\n\tstep,\n\tdb,\n}: CoreInngestFunctionInput) => {\n\tconst invoice = event.data.stripeEvent.data.object\n\n\t// Common payment processing for all invoice types\n\tawait step.run('record payment', async () => {\n\t\t// TODO: Record payment in our database\n\t\t// TODO: Send receipt/confirmation email\n\t\t// TODO: Update billing history\n\t})\n\n\t// Handle subscription-specific invoice\n\tif (invoice.subscription) {\n\t\tawait step.run('process subscription payment', async () => {\n\t\t\t// TODO: Update subscription payment status\n\t\t\t// TODO: Update subscription renewal date if applicable\n\t\t\t// TODO: Handle subscription-specific notifications\n\t\t})\n\t\treturn\n\t}\n\n\t// Handle one-time payment invoice\n\tif (invoice.charge) {\n\t\tawait step.run('process one-time payment', async () => {\n\t\t\t// TODO: Update purchase status if applicable\n\t\t\t// TODO: Handle one-time purchase fulfillment\n\t\t\t// TODO: Send purchase-specific notifications\n\t\t})\n\t\treturn\n\t}\n\n\t// Handle other invoice types (if any)\n\tawait step.run('process other payment type', async () => {\n\t\t// TODO: Handle edge cases or unknown payment types\n\t\t// TODO: Log for monitoring\n\t})\n}\n\nexport const stripeInvoicePaymentSucceeded = {\n\tconfig: stripeInvoicePaymentSucceededConfig,\n\ttrigger: stripeInvoicePaymentSucceededTrigger,\n\thandler: stripeInvoicePaymentSucceededHandler,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;AAAO,IAAMA,yCACZ;AASM,IAAMC,sCAAsC;EAClDC,IAAI;EACJC,MAAM;AACP;AAEO,IAAMC,uCAA2D;EACvEC,OAAOL;AACR;AAEO,IAAMM,uCAA2D,8BAAO,EAC9ED,OACAE,MACAC,GAAE,MACwB;AAC1B,QAAMC,UAAUJ,MAAMK,KAAKC,YAAYD,KAAKE;AAG5C,QAAML,KAAKM,IAAI,kBAAkB,YAAA;EAIjC,CAAA;AAGA,MAAIJ,QAAQK,cAAc;AACzB,UAAMP,KAAKM,IAAI,gCAAgC,YAAA;IAI/C,CAAA;AACA;EACD;AAGA,MAAIJ,QAAQM,QAAQ;AACnB,UAAMR,KAAKM,IAAI,4BAA4B,YAAA;IAI3C,CAAA;AACA;EACD;AAGA,QAAMN,KAAKM,IAAI,8BAA8B,YAAA;EAG7C,CAAA;AACD,GAvCwE;AAyCjE,IAAMG,gCAAgC;EAC5CC,QAAQhB;EACRiB,SAASd;EACTe,SAASb;AACV;","names":["STRIPE_INVOICE_PAYMENT_SUCCEEDED_EVENT","stripeInvoicePaymentSucceededConfig","id","name","stripeInvoicePaymentSucceededTrigger","event","stripeInvoicePaymentSucceededHandler","step","db","invoice","data","stripeEvent","object","run","subscription","charge","stripeInvoicePaymentSucceeded","config","trigger","handler"]}