Stripe behaviour on this page is from Stripe's documentation, checked on 14 November 2026. Authorization windows are set by the card networks and change; read capture_before on the charge rather than hard-coding them.
A double charge (or duplicate payment) is one purchase that shows up twice on the customer's statement. Sometimes you really took the money twice. Sometimes one of the two lines is a temporary hold that will disappear. The first thing to do with a complaint is find out which, because the fixes have nothing in common.
| # | Cause | Is it real money? | Where to look | The fix |
|---|---|---|---|---|
| 1 | Double-click or client retry creates two payments | Yes | Two PaymentIntents for one order | One payment object per order, created with an idempotency key derived from the order |
| 2 | Server retries after a timeout with a fresh key | Yes | Two charges a few seconds apart, same amount | Retry with the same key and parameters, and reconcile anything still unknown |
| 3 | Duplicate webhook runs the handler twice | Sometimes: it ships twice, credits twice, or bills again if the handler charges | One charge, two fulfilments | Dedupe on the event ID and guard the state change |
| 4 | A pending authorization next to the real charge | No | One captured charge, plus a hold or a canceled payment | Capture or cancel promptly, and teach support the difference |
1. Double-clicks and client retries
The customer clicks Pay, nothing visibly happens, so they click again. Or the browser, or your mobile client's HTTP library, retries a request that had already reached your server. If each request creates a new payment, you've got two.
The fix is structural, not a disabled button (though keep the disabled button). Create one PaymentIntent per order on the server, store its ID on the order, and return the stored one on every later call. Create it with an idempotency key derived from the order ID, so two requests that race past the "already have one?" check still produce one intent. Stripe lists deriving the key "from a user-attached object, like the ID of a shopping cart" as one of its two recommended strategies, precisely to protect against double submissions (Stripe).
2. Server retries after a timeout
Your server calls the payment API, and the connection drops before the response arrives. Did the charge happen? Stripe's answer: you can't tell from the network error, so retry "with the same idempotency key and parameters within the first 24 hours after the original request" (Stripe). If the first request landed, Stripe saves its status code and body and returns them to the retry instead of charging again, 500 errors included (Stripe API).
The double charge comes from a retry wrapper that generates a fresh key per attempt, or no key at all. To the API, that's a new request. Two more rules from the same page:
- A
500is indeterminate. The operation might have happened. Don't retry it with a new key until you've retrieved the object or checked your webhooks. - Past 24 hours, stop. Keys can be pruned once they're at least 24 hours old, and a reused key after that is a new request. If the outcome is still unknown then, reconcile, don't retry.
Changing the amount and reusing the key gets you an error, not a second charge, because Stripe compares the parameters with the original request (Stripe API). If the cart changed, update the existing PaymentIntent rather than creating a new one.
Here are causes 1 and 2 closed in one function:
import time
import stripe
def get_or_create_payment_intent(order):
"""One PaymentIntent per order, however many times checkout calls this."""
if order.payment_intent_id:
return stripe.PaymentIntent.retrieve(order.payment_intent_id)
# Derived from the order, never minted per call: a double-click, a
# browser retry and a restarted worker all send the same key.
key = f"order-{order.id}-payment-intent"
for attempt in range(3):
try:
intent = stripe.PaymentIntent.create(
amount=order.total_cents,
currency=order.currency,
metadata={"order_id": str(order.id)},
idempotency_key=key,
)
break
except stripe.APIConnectionError:
# Outcome unknown. Same key and same parameters: if the first
# request landed, Stripe replays its response instead of
# creating a second intent.
if attempt == 2:
raise
time.sleep(2 ** attempt)
order.payment_intent_id = intent.id
order.save()
return intent
The idempotency keys guide has the full key rules and why a UUID per retry is the classic version of this bug.
3. Duplicate webhooks
Stripe says a webhook endpoint "might occasionally receive the same event more than once", retries live deliveries for up to three days, and doesn't guarantee order (Stripe). A handler that fulfils on every payment_intent.succeeded it receives will, eventually, fulfil twice. That's not a second card charge by itself. It becomes one when the handler moves money: billing a usage add-on on invoice.paid, topping up a wallet, or paying out a seller.
Stripe's fix is to log the event IDs you've processed and skip the ones you've seen. It also warns that sometimes two separate Event objects are sent for one change, which an event-ID check can't catch; for those, use the ID in data.object together with the event type (Stripe). The handler below does both, the second as a conditional update on the order's status:
import os
import sqlite3
import stripe
from flask import Flask, request
app = Flask(__name__)
WEBHOOK_SECRET = os.environ["STRIPE_WEBHOOK_SECRET"]
db = sqlite3.connect("payments.db", check_same_thread=False)
# CREATE TABLE processed_events (event_id TEXT PRIMARY KEY);
@app.post("/webhooks/stripe")
def stripe_webhook():
payload = request.get_data() # the raw bytes Stripe signed
try:
event = stripe.Webhook.construct_event(
payload, request.headers.get("Stripe-Signature"), WEBHOOK_SECRET
)
except (ValueError, stripe.SignatureVerificationError):
return "", 400
if event.type != "payment_intent.succeeded":
return "", 200
try:
with db: # one transaction: the claim and the state change commit together
db.execute("INSERT INTO processed_events (event_id) VALUES (?)",
(event.id,))
order_id = event.data.object.metadata["order_id"]
# Second guard: two distinct events for one payment both pass
# the event-ID check, but only one can move the order.
moved = db.execute(
"UPDATE orders SET status = 'paid' "
"WHERE id = ? AND status = 'pending'",
(order_id,),
).rowcount
if moved:
enqueue_fulfilment(order_id) # once per order, not per delivery
except sqlite3.IntegrityError:
pass # a duplicate delivery: already handled, still a 200
return "", 200
The signature check comes first and runs on the raw bytes; webhook idempotency explains why request.json breaks it, and Stripe webhook duplicates covers ordering and retries.
4. The pending authorization that isn't a charge
The customer's card was authorized, which puts a hold on the funds, and then either captured (the real charge) or released. Banking apps show holds too, and Stripe itself notes that "card statements from some issuers and interfaces from payment methods don't always distinguish between authorizations and captured (settled) payments, which can sometimes confuse customers" (Stripe). A customer who saw a decline, tried again, and now sees two lines may be looking at one charge and one hold.
How long an uncaptured authorization lasts on Stripe depends on who started the payment and the card brand. For online payments (Stripe):
| Card brand | Customer-initiated | Merchant-initiated |
|---|---|---|
| Visa | 7 days | 5 days (exactly 4 days 18 hours) |
| Mastercard, American Express, Discover | 7 days | 7 days |
If you don't capture in time, the funds are released and the payment moves to canceled. The fixes:
- Cancel what you won't capture. Canceling a PaymentIntent in
requires_capturereleases the hold now instead of whenever it expires (Stripe). - Capture the right amount. A partial capture releases the rest automatically, and for most payments you get one capture only (Stripe). Capturing less beats capturing everything and refunding the difference.
- Give support a script. Look up the payment: one
succeededand onecanceled(or stillrequires_capture) means one charge and one hold. Tell the customer which line is the hold and that it's been released. Stripe doesn't promise how fast the customer's bank drops it from the app, so don't promise a date either.
Why authorization and capture are separate steps, with the expiry windows as a fallback table. From chapter 5.
Authorization vs Capture
The authorization/capture split is essential for certain business models. Hotels authorize at check-in, capture at checkout. Marketplaces authorize buyer payment, capture when seller ships. This pattern prevents charging customers for services not yet delivered.
Many payment flows separate authorization from capture:
class AuthCapturePayment:
# Authorization validity for online (card-not-present) payments, per
# Stripe's "Place a hold on a payment method" docs (November 2026):
# - Most brands: 7 days
# - Visa merchant-initiated (MIT): 5 days, which Stripe treats as
# 4 days 18 hours to leave room for clearing
# - Extended authorization: up to 30 days where the network allows it
# (on Stripe: Visa lodging, vehicle rental and cruise, plus other
# categories for customer-initiated payments at an extra 0.08%;
# Mastercard all categories; Amex lodging and vehicle rental;
# Discover travel and lodging)
# Networks change these rules. In production, read the expiry your
# processor returns (Stripe: charge.payment_method_details.card.capture_before)
# and treat this table as a fallback.
def __init__(self, amount, merchant_category='default'):
self.amount = amount
self.status = 'created'
self.authorized_amount = 0
self.captured_amount = 0
self.auth_expiry = None
self.merchant_category = merchant_category
def authorize(self, amount, card_network='visa', merchant_initiated=False,
extended=False):
"""Reserve funds without capturing"""
self.status = 'authorized'
self.authorized_amount = amount
# Set expiry based on network, initiator and extended-auth status
validity = self._get_auth_validity(card_network, merchant_initiated, extended)
self.auth_expiry = datetime.now() + validity
def _get_auth_validity(self, card_network, merchant_initiated, extended):
"""Fallback authorization window when the processor doesn't tell you"""
if extended:
# Visa's extended window is 30 days; Stripe uses 29 days 18 hours
return timedelta(days=29, hours=18)
if card_network == 'visa' and merchant_initiated:
return timedelta(days=4, hours=18)
return timedelta(days=7)
def capture(self, amount=None):
"""Capture previously authorized funds"""
capture_amount = amount or self.authorized_amount
if capture_amount > self.authorized_amount:
raise PaymentError("Cannot capture more than authorized")
if datetime.now() > self.auth_expiry:
raise PaymentError("Authorization expired - must re-authorize")
self.captured_amount += capture_amount
self.authorized_amount -= capture_amount
if self.authorized_amount == 0:
self.status = 'captured'
else:
self.status = 'partially_captured'
Authorizations expire, and not on a single schedule. Stripe's documentation puts most online card authorizations at 7 days, but a merchant-initiated Visa authorization at 5 days (4 days 18 hours in Stripe's terms), and extended authorizations at up to 30 days where the network and merchant category allow it. The networks revise these rules, so store the expiry your processor returns for each authorization (Stripe's capture_before) rather than hard-coding a table, and capture before it. An expired authorization can't be captured: you have to re-authorize with the customer, and that can fail if their available credit has changed.
Use cases:
- Hotels: Authorize full amount, capture actual charges at checkout.
- Marketplaces: Authorize buyer payment, capture when seller ships, within the authorization window (7 days for most online card payments on Stripe).
- Variable pricing: Reserve maximum, capture actual amount.
The design behind cause 3: what the key is, two layers of storage, failing closed, and the race an atomic claim closes. From chapter 39.
Idempotency Store Design
The key is the provider's stable event ID with the provider name in front, provider:event_id. Never a hash of the payload, because re-serialization changes the bytes and you'd stop catching duplicates without noticing. Never the payment or subscription ID either, because one payment intent produces several events and you'd drop all but the first. The prefix keeps two providers' ID spaces apart and makes the row readable when you're querying the table by hand at 3 AM.
The store has two layers because they fail differently. Redis is the fast path and expires keys after 48 hours; the database is slower and keeps rows for 30 days. A duplicate inside 48 hours never touches the database. A retry on day three, which Stripe, PayPal, and Paddle all still send, misses Redis and hits the database row instead.
If Redis is flushed, evicted, or replaced during a deploy, nothing is lost, only slowed. If the database check itself errors, fail closed: return a 500 so the provider retries later, and don't process. The one thing you must not do is treat "couldn't check" as "not seen".
The check-then-act in already_processed and mark_processed has a gap. Two deliveries of the same event at the same moment, on two workers, both pass the check and both process. Close it with an atomic claim: Redis SETNX so the first writer wins, and the primary key on the idempotency key in the database so the second insert fails instead of succeeding twice. Chapter 9's Stripe handler does this with event_store.claim(). Stripe's own guidance goes one further and records two marks, processing and then processed, so a crash mid-handler leaves a visible half-finished row rather than a silently lost event.
What happens at expiry is the design decision most teams never make. After 30 days the cleanup task deletes the database row, and the same event arriving after that is processed as new. For Stripe, PayPal, Paddle, and Square that can't be an automatic retry, because their schedules end at three days or less. It can be a manual resend from a dashboard, or an Adyen retry on its last day. Decide which you want: handlers that are safe to re-run, which Chapter 5 covers, or retention that outlasts the longest retry window you accept, with margin.
Finding double charges before the customer does
Run this query daily, not after the complaint: orders with more than one succeeded payment, and customers with two succeeded payments of the same amount within a few minutes. Every hit is one of causes 1 to 3, and refunding it before the customer notices is cheaper than the dispute that follows if they don't. Chargeback vs refund has the arithmetic on that, and payment reconciliation is where duplicates that slipped through turn up in the numbers.
Questions
Why was I charged twice for the same purchase?
There are four causes: a double-click or client retry that creates two payments, a server retry after a timeout that uses a fresh idempotency key, a duplicate webhook that runs a handler twice, or a pending authorization showing next to the real charge. The first three are real money; the fourth is a hold that gets released.
How do I prevent duplicate payments on Stripe?
Create one PaymentIntent per order on the server and store its ID on the order. Create it with an idempotency key derived from the order ID, and retry network failures with the same key and parameters within 24 hours. Dedupe webhooks on the event ID and guard the state change, so a duplicate delivery can't fulfil twice.
Is a pending charge a double charge?
Not necessarily. An authorization puts a hold on the funds, and Stripe notes that some card statements don't distinguish authorizations from captured payments. If one payment succeeded and the other was canceled or never captured, the customer was charged once and the other line is a hold.
How long does a card authorization hold last on Stripe?
For online payments, 7 days for most brands. A merchant-initiated Visa authorization lasts 5 days, exactly 4 days 18 hours. If it isn't captured in time, the funds are released and the payment moves to canceled. Canceling the PaymentIntent releases the hold sooner.
Can a duplicate webhook charge a customer twice?
A duplicate payment_intent.succeeded doesn't create a second card charge by itself, because the payment already happened. It fulfils twice. It becomes a second charge when the handler moves money, such as billing an add-on or paying out a seller, which is why handlers dedupe on the event ID.