Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

Stripe "No such price": why it happens and how to fix it without trusting the browser

Your Stripe checkout fails with: No such price: 'price_1ABC...' What it means Your server asked Stripe for a price ID that does not exist for the account and mode the request used. Stripe is not saying the price

Your Stripe checkout fails with:

No such price: 'price_1ABC...'

What it means
Your server asked Stripe for a price ID that does not exist for the account and mode the request used. Stripe is not saying the price is invalid. It is saying it cannot find it where it looked.

Common causes

  1. The price ID was copied from test mode but the server uses live keys, or the other way around.
  2. The ID comes from a different Stripe account, or from a connected account.
  3. The price was deleted or archived, or never created in this environment.
  4. An old ID is hard-coded or sits in a stale environment variable.

How to fix it

  1. Find the price ID your server resolves for the product the user picked.
  2. Confirm it exists in the intended Stripe account, in the same test or live mode as your secret key.
  3. Update the server configuration and redeploy if needed.
  4. Run a test-mode checkout end to end to confirm the amount.

The fix to avoid
Do not "repair" a price lookup by accepting an amount or price ID from the browser. Keep the mapping from product to price on the server, so a visitor cannot pay less by editing a request.

One more check while you are here
Your Stripe secret key (sk_live_ or sk_test_) must never be in browser code. Open your deployed JavaScript and search for sk_. If it is there, rotate the key.

Same steps with the FAQ: https://proofforge.live/errors/stripe-no-such-price . To check whether your live app ships any secret keys, run the free outside check at https://proofforge.live

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.