Two Stripe webhook deliveries arrived 90ms apart before the first transaction committed. Wrapping the entitlement grant in a single Postgres transaction keyed on stripe_session_id with ON CONFLICT DO NOTHING ensures duplicate retries return 200 without re-issuing seats.
checkout-route.ts
Should we also alert when Stripe signature verification rejects a spike of webhook retries?
Yes — emit a structured billing.webhook.invalid_signature counter and trigger an ops alert if more than 5 Stripe signature failures happen within a 5-minute window.