All packsSaaS Billing + Tax CoreSolve
stripe webhook idempotency nextjs redeploy
Webhook idempotency that survives a redeploy
In-memory dedup sets for Stripe webhooks reset on every redeploy or cold start; the pack enforces idempotency with a DB unique constraint instead (D4).
This is one of the things SaaS Billing + Tax Core already handles. Charge per-seat subscriptions: upgrades, downgrades, failed cards, invoices and sales tax.
Is this you?
Stripe retries webhook deliveries, so the same event can arrive more than once. A dedup strategy built on a process-memory Set of seen event IDs passes a quick manual test, then silently stops working the moment the app redeploys, autoscales to a second instance, or cold-starts -- exactly the conditions under which a real retry is most likely to fire.
Why this one is easy to get wrong
An in-memory Set is the shortest code that visibly works: send the same webhook twice locally, watch it dedupe. There's no failure signal until a real deploy cycle happens in production, by which point a duplicate application of a cancellation or plan-change event has probably already landed.
What you get instead
D4 makes the Postgres WebhookEvent table's primary key -- the Stripe event id -- the entire idempotency mechanism, applied inside one interactive transaction: create the event row first; if that specific insert throws a unique-violation, return early with no side effects; otherwise apply the mutation in the same transaction. The catch is scoped to just that one insert, so an unrelated constraint violation in the business mutation still surfaces as a 500 instead of being silently swallowed.
Source: ARCHITECTURE.md D4 — checkable in the pack you receive
How you actually use this
You don’t install a library or wire up an SDK. Your own coding agent builds the code in your project, and you keep it — no runtime dependency on us.
Step 1
Download and unzip
You get a folder: the docs that tell an agent what to build, a starting skeleton, and the test suite that decides when it's done.
Step 2
Open it in Claude Code or Cursor
Point your coding agent at the folder. Nothing to install, no account with us, no API key.
Step 3
Paste one prompt
The pack contains the exact prompt. Paste it as your first message and leave it alone — it works through the build itself, choosing a cheaper or stronger model per task.
Step 4
Run ./verify.sh
One command. It prints a pass or fail for every check. Green means the build is done — the same script we ran to produce the receipt on this page.
Typical build: about 18 minutes of your agent working, mostly unattended. Then you integrate the working module into your app the way you would any code you’d written yourself.
Why you can believe this
3 of 3 runs passedWe ran this pack from an empty folder 3 times and published exactly what happened — every check, the model, the token cost, the wall time. Not a testimonial, and not our opinion: the same verify.sh you run yourself. Read the full receipt →