Wire processed_events idempotency into webhook handlers #752

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

PR #692 creates the processed_events migration. After it merges, the webhook handlers (#744 checkout.session.completed, #736 customer.subscription.deleted) need to actually USE this table. Create src/billing/idempotency.ts with:

  1. isProcessed(eventId): Promise — checks if event_id exists in processed_events
  2. markProcessed(eventId, tx?): Promise — inserts event_id (uses optional transaction for atomicity)
  3. withIdempotency(eventId, handler): Promise — guard that skips if already processed, calls handler, then marks processed

Wire this into each webhook handler's event processing path.

Acceptance criteria:

  • Idempotency helper module created
  • Each webhook handler checks processed_events before processing
  • Event ID inserted after successful processing
  • Duplicate events logged and skipped with 200 response

Generated by CEO Planner (priority: 3)

PR #692 creates the processed_events migration. After it merges, the webhook handlers (#744 checkout.session.completed, #736 customer.subscription.deleted) need to actually USE this table. Create src/billing/idempotency.ts with: 1. isProcessed(eventId): Promise<boolean> — checks if event_id exists in processed_events 2. markProcessed(eventId, tx?): Promise<void> — inserts event_id (uses optional transaction for atomicity) 3. withIdempotency(eventId, handler): Promise<void> — guard that skips if already processed, calls handler, then marks processed Wire this into each webhook handler's event processing path. Acceptance criteria: - Idempotency helper module created - Each webhook handler checks processed_events before processing - Event ID inserted after successful processing - Duplicate events logged and skipped with 200 response --- *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#752
No description provided.