Stripe · Guide

Why Stripe sends your webhook twice (and how to process it once)

Updated 22 Nov 2026.

Hamichi the hamster stamping ONCE on one of two identical envelopes

Stripe will send you the same event twice. Your endpoint timed out. You returned a 5xx. The process died after the work but before the 200. In live mode, Stripe retries for up to 3 days and does not promise a single delivery, or a tidy order. The second POST is not a bug in Stripe. It is the contract.

Count event ids first

The unique key for a delivery is event.id. Store it atomically before you grant anything. The second delivery should return 200 and do nothing. If two requests run at the same moment and both think they are first, a unique constraint (or a SET key NX lease) is what stops a double license, not a flag you read and then write.

Return 200 for a duplicate. A 500 makes Stripe retry a delivery you already handled.

One change can still be two Event objects

Sometimes Stripe sends two separate Event objects for one customer action. Deduping only on event.id will not catch that. Key fulfillment by the Checkout Session id, or by the invoice or subscription you actually fulfill, not only by the event id.

Do not sort by created and call it order

event.created is in seconds. Two distinct events can share a value. If you apply whichever update has the later timestamp, a tie is a guess. Re-fetch the subscription (or the Checkout Session) and trust the live object. Acknowledge stale and tied events so Stripe stops retrying.

A handler that already does this

import { handleStripeWebhook } from "hamichi-webhook-kit";

const result = await handleStripeWebhook({
  rawBody,              // exact bytes; see the raw-body note below
  signatureHeader: req.headers.get("stripe-signature"),
  secrets: [process.env.STRIPE_WEBHOOK_SECRET],
  store,
  idempotency,          // Postgres or Redis example in the kit
  onFulfill: grantLicense,
});

return Response.json(
  { received: result.httpStatus === 200, kind: result.outcome.kind },
  { status: result.httpStatus },
);

The kit verifies the signature, records event.id, and keys fulfillment so a second Event object for the same Checkout Session does not grant twice. Your database still does the remembering.

The Hamichi Webhook Kit is the copy of this handler Hamichi ships, with Express, Next.js, and NestJS examples. If you already sell files on Gumroad, the same at-least-once, any-order problem shows up as a ping: Gumroad ping arrived after the refund. The signature check has to see the raw body first: Stripe signature verification fails in production.