Add POST /api/billing/webhook route handler for Stripe events #700

Open
opened 2026-04-11 13:04:12 -04:00 by pook · 0 comments
Owner

Same critical gap as contractpilot — the billing pipeline has checkout (PR #655), subscription gating, and signature verification planned, but no webhook handler to actually process Stripe events.

Implementation:

  1. Create POST /api/billing/webhook route
  2. Raw body parsing for signature verification
  3. Verify Stripe webhook signature
  4. Handle events:
    • checkout.session.completed → insert into stripe_subscriptions table
    • customer.subscription.updated → update status and period end
    • customer.subscription.deleted → mark canceled
  5. Use processed_events table (migration from PR #692) for idempotency — check event ID before processing, skip if already handled
  6. Return 200 to Stripe, log errors but don't throw
  7. Add integration test with mocked Stripe event

Depends on: PR #655 (checkout), PR #692 (processed_events migration)

Acceptance: Webhook handler processes checkout.session.completed and creates subscription record. Duplicate events are skipped via processed_events check. Test passes.


Generated by CEO Planner (priority: 2)

Same critical gap as contractpilot — the billing pipeline has checkout (PR #655), subscription gating, and signature verification planned, but no webhook handler to actually process Stripe events. Implementation: 1. Create POST /api/billing/webhook route 2. Raw body parsing for signature verification 3. Verify Stripe webhook signature 4. Handle events: - checkout.session.completed → insert into stripe_subscriptions table - customer.subscription.updated → update status and period end - customer.subscription.deleted → mark canceled 5. Use processed_events table (migration from PR #692) for idempotency — check event ID before processing, skip if already handled 6. Return 200 to Stripe, log errors but don't throw 7. Add integration test with mocked Stripe event Depends on: PR #655 (checkout), PR #692 (processed_events migration) Acceptance: Webhook handler processes checkout.session.completed and creates subscription record. Duplicate events are skipped via processed_events check. Test passes. --- *Generated by CEO Planner (priority: 2)*
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#700
No description provided.