Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Payments and webhooks

Stripe says No such checkout.session when you retrieve a session

ErrorNo such checkout.session

Short answer

A resource_missing error means the ID is not visible to the key you used. The usual reasons: the session was created in test mode and you retrieve it with a live key (or the other way round), it lives on a connected account and the Stripe-Account header is missing, or the string you pass is another object's ID or has been cut.

  • Applies to Stripe API 2026-10-28, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Retrieve the session with the exact ID and key from your app, from a terminal. Compare the key prefix (sk_test_ or sk_live_) with the ID prefix (cs_test_ or cs_live_).

    curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:"
  2. 2Match what you see, then jump to its fix

    1. 1The session ID starts with cs_test_ but the key starts with sk_live_ (or cs_live_ with sk_test_).Test and live mode are mixedFix
    2. 2The same ID is visible in the Dashboard of the connected account, but not for your platform key.The session belongs to a connected accountFix
    3. 3The ID starts with something other than cs_, such as pi_ or evt_, or it has a trailing space, quote or newline.The ID is not a Checkout Session ID, or it is damagedFix

What does the error look like?

  • No such checkout.session
  • resource_missing

Cause 1 of 3

Test and live mode are mixed

1Check

Each mode has its own keys and objects. An object from one mode is not accessible from the other, and Stripe documents the livemode_mismatch error code for this.

echo "$STRIPE_SECRET_KEY" | cut -c1-8

2Fix

Use the key of the mode that created the session on the server that retrieves it. Check which key your deployed environment really has: a test key left in the live environment, or the reverse, is the common slip.

# .env of the server that retrieves the session
STRIPE_SECRET_KEY=sk_test_...   # same mode as the cs_test_ session

3Verify

Run the first-step command again with the corrected key; it returns the session.

curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:" | head -5

Confirmed by docs.stripe.com

Did this fix it?

Cause 2 of 3

The session belongs to a connected account

1Check

With Stripe Connect, server calls for a connected account carry that account's ID (acct_...) in the Stripe-Account header. Without it the request is made on your own account, where the session does not exist.

grep -rn "stripe_account\|Stripe-Account" src/ app/

2Fix

Send the connected account ID with the retrieve request, the same way you sent it when you created the session.

curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME \
  -u "$STRIPE_SECRET_KEY:" \
  -H "Stripe-Account: acct_REPLACE_ME"

3Verify

The response now contains the session.

curl -s https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:" -H "Stripe-Account: acct_REPLACE_ME" | head -3

Confirmed by docs.stripe.com

Did this fix it?

Cause 3 of 3

The ID is not a Checkout Session ID, or it is damaged

1Check

Stripe describes resource_missing as an ID that is not valid: the resource does not exist, or the ID of a different resource was given. A copy that is cut or has an extra character fails the same way. Log the value and its length.

var_dump($sessionId, strlen($sessionId));

2Fix

Pass the session id (cs_...) from the object you created, or from session.id in the event, and trim it. Never use the PaymentIntent id here.

$sessionId = trim($_GET['session_id']);

3Verify

Retrieve it from a terminal with the same value.

curl https://api.stripe.com/v1/checkout/sessions/$SESSION_ID -u "$STRIPE_SECRET_KEY:"

Confirmed by docs.stripe.com

Did this fix it?

How do I stop it coming back?

  • Keep test and live keys in separate environment files, and print the key prefix in your startup log (never the whole key).
  • Store the session id you created next to the order, and read it back from there instead of from the URL when you can.
  • Do the same for connected accounts: save the acct_ id with the order.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Payments

Stripe Elements shows console warnings or errors in a Next.js checkout

Could not find Elements context; You need to wrap the part of your app that calls useElements() in an <Elements> provider.

Most React Stripe.js warnings come from four mistakes: calling loadStripe inside a component, using useStripe or useElements outside the Elements provider, using the objects before they have loaded, and a Content Security Policy that blocks js.stripe.com.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.