The PaymentIntent State Machine
Why the Charges API Broke
The original Charges API was one synchronous call: send a card token, get back succeeded or a decline, in one HTTP round trip. That shape cannot express "the issuer wants the cardholder to complete a challenge in a browser and come back later" — there is no field in a single request/response pair to hold a pause. Before PSD2's Strong Customer Authentication (SCA) requirement took effect in Europe in September 2019, that pause was the exception (a rare "verify your identity" prompt). After SCA, a 3D Secure challenge is the normal path for a large share of European card payments, not an edge case a merchant could route around.
Without a durable object, the merchant has to invent the missing state machine itself: a table tracking "redirected to issuer, awaiting return," a webhook or polling loop to notice the customer never came back, and a way to correlate the eventual redirect with the original cart. Every integration reinvented a slightly different, slightly buggy version of the same thing. A PaymentIntent moves that state machine into Stripe, gives it a stable ID, and gives the merchant one thing to store: that ID, on the order, the moment it exists.
The Full Lifecycle
A PaymentIntent's status field takes exactly seven values. Get the exact strings right — they appear verbatim in webhook payloads, Dashboard filters, and Radar rules. (If you're reading an account still pinned to an API version before 2019-02-11, the same two states show up as requires_source and requires_source_action — a naming fossil from before PaymentIntents existed at all, when the object was still keyed around a raw source rather than a payment_method.)
| Status | Means | Moves forward on | Moves backward on | Terminal? |
|---|---|---|---|---|
requires_payment_method | Created, no attached and confirmed payment method yet — or the last attempt failed | Attach a payment method and confirm | — (entry point and failure landing pad) | No |
requires_confirmation | Payment method attached, ready for an explicit /confirm call | POST /confirm | Rarely used — most integrations confirm immediately on attach | No |
requires_action | Issuer or regulation demands customer interaction — usually 3DS | Customer completes the challenge | Challenge fails or times out → requires_payment_method | No |
processing | Action handled, payment method is asynchronous (bank debit, some wallets) | Async settlement completes | Async settlement declines → requires_payment_method | No |
requires_capture | Authorized, funds held, capture_method: manual (see Authorize vs capture) | POST /capture | Authorization window expires or is canceled → canceled | No |
succeeded | Funds are in your Stripe balance | — | Never — refunds and disputes act on the Charge, not the PaymentIntent | Yes |
canceled | Invalidated — by you, or automatically after too many failed confirmations | — | — | Yes |
That survival is the whole point for reconciliation: one PaymentIntent, N confirmation attempts, at most one Charge per attempt, at most one successful Charge overall. Every attempt — declined or not — creates a Charge object underneath (more on that below), so a customer who fails with card A and succeeds with card B leaves two Charges and one PaymentIntent behind, and your ledger has a single ID to hang the whole story off of instead of reconstructing it from a pile of independent charge attempts with no shared parent.
| Distinct status values | 7 |
|---|---|
| Terminal states | succeeded, canceled |
| client_secret shape | pi_xxx_secret_yyy |
| Charges per PaymentIntent | 0.N created, ≤1 ever succeeds |
client_secret: The Client's Half of the Handshake
A PaymentIntent's client_secret is a second, weaker key derived from the PaymentIntent's ID. Your server's secret key can do anything to your Stripe account; the client_secret can only complete or inspect this one PaymentIntent, using a publishable key, from a browser or mobile client that has no other Stripe credentials at all. That's the entire reason it exists: it lets Stripe.js call confirmPayment and handleNextAction from untrusted client code without your secret key ever leaving the server.
What it authorizes: reading the PaymentIntent's status, amount, and currency, and driving it through confirmation and any required next action. What it explicitly does not authorize: creating PaymentIntents, capturing, canceling, refunding, or reading anything else in your account. The docs state the handling rule in one sentence, and it is load-bearing: don't log it, embed it in URLs, or expose it to anyone other than the customer — and serve any page that carries it over TLS. A client_secret in an access log or an error-tracking payload is a credential leak with the same blast radius as leaking a session token for that one payment.
Confirmation Models
Two independent fields decide who is allowed to advance the PaymentIntent, and how. Get the field names exactly right — they show up in support tickets and in your own config:
| Field | Values | Meaning |
|---|---|---|
confirmation_method | automatic (default) / manual | automatic: confirmed client-side with a publishable key, via Stripe.js — the shape the Payment Element uses. manual: every confirmation must come from your server with a secret key; after handling a next_action, the PaymentIntent falls back to requires_confirmation and your server must explicitly re-confirm rather than the client auto-continuing. |
automatic_payment_methods | {enabled: true} | Lets Stripe pick eligible payment methods dynamically based on currency, amount, and Dashboard configuration, instead of you hardcoding a payment_method_types list. |
capture_method | automatic_async (default) / automatic / manual | Orthogonal to confirmation — governs when funds move after authorization. Covered in full in the Authorize vs capture part. |
The docs describe these as supported shapes for different integration needs, not one canonical path: server-side confirmation suits saved-card and off-session charges where no client is present to call Stripe.js; client-side automatic confirmation suits the common on-session checkout, and is what the Payment Element does by default. Most new integrations skip requires_confirmation entirely because they submit the payment method and confirm in the same client call.
The PaymentIntent as an Idempotency Mechanism in Its Own Right
This is the connective tissue back to the Idempotency: the contract part and Idempotency: the machinery. The idempotency key you send on POST /v1/payment_intents protects exactly one call: the creation call. It guarantees that a retried create returns the same object instead of a second one. It says nothing about anything that happens afterward — confirmation, 3DS, capture — because those are separate calls, potentially with their own idempotency keys, potentially made by a different client than the one that created the intent.
The PaymentIntent's ID is what protects everything after creation. Once it exists, "did my payment go through?" stops being a guess reconstructed from logs and becomes GET /v1/payment_intents/pi_xxx — a read, not a retry. That only works if the ID reached durable storage before the process that requested it died. The idempotency key that protected the create call can itself be lost — kept only in a local variable, never written anywhere — and a client in that state cannot recover by retrying, because it no longer knows what key it used. It can still recover, but only through the PaymentIntent's ID, and only if that ID was persisted.
✗ Random key, id-after ordering — a crash orphans the payment
idem_key = uuid4() # lives only in memory
intent = stripe.PaymentIntent.create(
amount=order.total, currency="usd",
idempotency_key=idem_key,
)
order.payment_intent_id = intent.id
order.save()
# crash right here: idem_key is gone forever.
# retry generates a NEW random key ->
# Stripe creates a SECOND live PaymentIntent.
# order row still has no id to recover with.✓ Derived key, order-row-first ordering — a crash is always recoverable
order = Order.objects.create(
cart_id=cart.id, total=cart.total,
) # order.id is durable now
intent = stripe.PaymentIntent.create(
amount=order.total, currency="usd",
idempotency_key=f"pi-create-order-{order.id}",
)
order.payment_intent_id = intent.id
order.save()
# crash right here: retry re-derives the SAME
# key from order.id -> Stripe returns the
# cached PaymentIntent, not a new one.PaymentIntent, Charge, and latest_charge
Confirming a PaymentIntent creates a Charge object underneath it — one per confirmation attempt, successful or not. latest_charge on the PaymentIntent is a single string ID pointing at the most recent one; it is null until confirmation is first attempted. As of the current docs there is no indication Stripe is deprecating or replacing the Charge object for PaymentIntent-created payments — it remains where dispute, refund, and outcome detail live.
| Myth | Reality |
|---|---|
| PaymentIntent replaced Charge; you never need to look at a Charge object again. | latest_charge only ever points at the most recent attempt. A customer who declined twice before succeeding has three Charges and one PaymentIntent. To see every declined attempt and its decline code for reconciliation or fraud analysis, list Charges filtered by payment_intent — don't infer the full history from latest_charge alone. |
A canceled PaymentIntent's cancellation_reason is a fixed enum, not free text — worth knowing before wiring up detection for the traps below:
| Value | Set by | What it tells you |
|---|---|---|
requested_by_customer | You, explicit cancel | Deliberate — the customer backed out before paying |
duplicate | You, explicit cancel | The value you set when cleaning up a second live intent for the same cart — the exact trap below, made queryable |
fraudulent | You, explicit cancel | Radar or manual review rejected it (see Radar) |
abandoned | You, explicit cancel | Checkout was started but never completed |
automatic | Stripe | The authorization window expired on its own — this is the Authorize vs capture part's trap, not a merchant decision |
failed_invoice / void_invoice | Stripe | Driven by Billing/Invoicing, not a direct API caller |
The Invariants
- Guarantees: A PaymentIntent's status transitions follow the documented state machine only — a declined attempt returns it to
requires_payment_methodrather than terminating it, so the same ID and amount can be retried with a new payment method. At most one Charge on a PaymentIntent can ever besucceeded. The client_secret authorizes only confirmation and inspection of that one PaymentIntent, never account-wide actions. - Does not guarantee: That a client-side redirect back to your
return_urlmeans the payment succeeded — only thepayment_intent.succeededwebhook (see Webhooks) is authoritative. That reusing a PaymentIntent is automatic — your integration has to choose to store and reuse the ID; nothing in the API prevents you from creating duplicates. Thatlatest_chargeshows the full attempt history — it shows only the most recent Charge.