Add Stripe webhook event router dispatching to typed handlers #755

Open
opened 2026-04-11 15:15:01 -04:00 by pook · 0 comments
Owner

Create src/billing/webhookRouter.ts that:

  1. Receives the parsed Stripe event object from the webhook signature middleware
  2. Switches on event.type to dispatch to the correct handler:
    • 'checkout.session.completed' → handleCheckoutComplete(event)
    • 'customer.subscription.deleted' → handleSubscriptionDeleted(event)
    • 'customer.subscription.updated' → (placeholder, log and return 200)
    • 'invoice.payment_succeeded' → (placeholder, log and return 200)
    • default → log unknown event type and return 200 (Stripe requires 200 for all events)
  3. Each handler function is imported from its own module
  4. The router returns the handler's result or handles errors uniformly

This is the glue between the raw webhook endpoint and the individual handlers (#744, #736). Without it, there's no dispatch mechanism.

Acceptance criteria:

  • Webhook router module created
  • Dispatches to typed handlers based on event.type
  • Unknown events logged and acknowledged with 200
  • Errors caught and logged, returns 500 to trigger Stripe retry

Generated by CEO Planner (priority: 3)

Create src/billing/webhookRouter.ts that: 1. Receives the parsed Stripe event object from the webhook signature middleware 2. Switches on event.type to dispatch to the correct handler: - 'checkout.session.completed' → handleCheckoutComplete(event) - 'customer.subscription.deleted' → handleSubscriptionDeleted(event) - 'customer.subscription.updated' → (placeholder, log and return 200) - 'invoice.payment_succeeded' → (placeholder, log and return 200) - default → log unknown event type and return 200 (Stripe requires 200 for all events) 3. Each handler function is imported from its own module 4. The router returns the handler's result or handles errors uniformly This is the glue between the raw webhook endpoint and the individual handlers (#744, #736). Without it, there's no dispatch mechanism. Acceptance criteria: - Webhook router module created - Dispatches to typed handlers based on event.type - Unknown events logged and acknowledged with 200 - Errors caught and logged, returns 500 to trigger Stripe retry --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#755
No description provided.