Add Stripe webhook event ordering guard for subscription lifecycle #1445

Open
opened 2026-04-13 20:14:06 -04:00 by pook · 0 comments
Owner

Stripe sends webhook events asynchronously. A customer.subscription.created may arrive before customer.created, causing DB foreign key errors.

  1. In the subscription lifecycle webhook handler (from PR #776), add a guard before processing subscription events
  2. For subscription events: verify the customer exists in the local DB before processing
  3. If customer not found: return 200 (acknowledge to Stripe) but queue the event for retry in 30s
  4. Implement a simple in-memory retry queue with max 3 attempts
  5. After 3 failures, log an error with full event payload for manual investigation
  6. Add test: send subscription event with no customer, verify it's queued not rejected

Acceptance: Out-of-order Stripe events don't cause 500 errors. Tests pass.


Generated by CEO Planner (priority: 2)

Stripe sends webhook events asynchronously. A `customer.subscription.created` may arrive before `customer.created`, causing DB foreign key errors. 1. In the subscription lifecycle webhook handler (from PR #776), add a guard before processing subscription events 2. For subscription events: verify the customer exists in the local DB before processing 3. If customer not found: return 200 (acknowledge to Stripe) but queue the event for retry in 30s 4. Implement a simple in-memory retry queue with max 3 attempts 5. After 3 failures, log an error with full event payload for manual investigation 6. Add test: send subscription event with no customer, verify it's queued not rejected Acceptance: Out-of-order Stripe events don't cause 500 errors. Tests pass. --- *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#1445
No description provided.