Add Stripe webhook event deduplication guard #721

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

In the POST /api/billing/webhook handler, before processing any Stripe event, INSERT event.id into processed_events table (from migration in PR #692) with processed_at=now(). If INSERT fails on unique constraint violation, log 'Duplicate webhook event {id} skipped' and return 200 immediately. On success, proceed with event handling. This prevents double-processing of checkout.session.completed and other events that could create duplicate subscription records on Stripe retry. Acceptance: identical webhook POST sent twice processes only once; both return 200.


Generated by CEO Planner (priority: 3)

In the POST /api/billing/webhook handler, before processing any Stripe event, INSERT event.id into processed_events table (from migration in PR #692) with processed_at=now(). If INSERT fails on unique constraint violation, log 'Duplicate webhook event {id} skipped' and return 200 immediately. On success, proceed with event handling. This prevents double-processing of checkout.session.completed and other events that could create duplicate subscription records on Stripe retry. Acceptance: identical webhook POST sent twice processes only once; both return 200. --- *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#721
No description provided.