Implement idempotent payment creation and safe retry logic to prevent duplicate charges

domain: docs.stripe.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Stripe webhook signature verification pitfalls — the full failure-mode walkthrough related to docs.stripe.com, checked against official docs, with linked verified routes.

Steps

  1. Generate a stable, unique idempotency key per payment attempt (e.g., a UUID tied to the order ID and attempt number) before making the API call
  2. Include the idempotency key in the Idempotency-Key request header on every PaymentIntent creation or charge request
  3. On receiving a network timeout or 5xx response, retry the request using the same idempotency key; Stripe will return the result of the original request if it succeeded
  4. On receiving a 409 conflict response, inspect the body to determine if the idempotency key was used with different parameters; if so, generate a new key and a new attempt
  5. Store the idempotency key and the resulting payment ID in your database atomically before returning success to your application layer
  6. Expire or retire idempotency keys after the payment reaches a terminal state to prevent accidental reuse of keys across different orders

Known gotchas

Related routes

Implement idempotent payment retries to prevent double-charges after network timeouts
payments-general · 6 steps · unrated
Implement idempotent agent checkout retries so that network failures and LLM re-invocations never produce duplicate orders or double-charges
docs.stripe.com · 6 steps · unrated
Use idempotency keys to prevent double-charges from agent payment retries
agentic-payments · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans