Stripe · server log
No such price / No such customer (test and live mixed)
verified on · stripe-node 23.0.0 · Next.js 16.4.5 App Router
Check yours: npm ls stripe next · On a different version? Paste your package.json into the free Doctor and it checks your versions against these fixes.
StripeInvalidRequestError: No such price: 'price_1Abc...'; a similar object exists in test mode, but a live mode key was used to make this request.
code: resource_missingWhat it means
Stripe keeps test mode (sandboxes) and live mode apart: each has its own keys, and objects made in one don't exist in the other. Your server sent a price_ or cus_ id that doesn't exist for the secret key it used. When the id exists in the other mode of the same account, Stripe adds "a similar object exists in test mode, but a live mode key was used" (or the reverse). With no hint, the id belongs to another account, another sandbox, or is a typo or an unset env var.
Common causes
- You switched to sk_live_ keys but STRIPE_PRICE_ID still holds the test price id
- A test price id is hardcoded in the code or saved in the database, so changing env vars didn't change it
- stripeCustomerId values saved while testing are reused with live keys
- A prod_ product id is passed where Checkout expects a price_ id
- New env vars were added on the host but the app wasn't redeployed
How to fix it
- Check the secret key your server uses: sk_test_ or rk_test_ is test mode, sk_live_ or rk_live_ is live mode. Open the Dashboard in that same mode and search for the id
- Going live? Open the product and click Copy to live mode. The live copy gets new price_ ids, so put the live price id in your production env vars next to the live secret key, then redeploy
- Customers saved while testing don't exist in live mode. Clear those stripeCustomerId values before launch, or make a new customer when Stripe can't find the saved one (code below)
- Keep the publishable key, secret key, webhook secret and price ids from the same mode in each environment: live in Production, test in Preview and local
import Stripe from "stripe";
import { db } from "@/lib/db";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// Reuse the saved customer, or make a new one if Stripe can't find it
// (a cus_ id saved while testing doesn't exist in live mode)
export async function customerFor(user: { id: string; email: string; stripeCustomerId: string | null }) {
if (user.stripeCustomerId) {
try {
const c = await stripe.customers.retrieve(user.stripeCustomerId);
if (!c.deleted) return c.id;
} catch (err) {
if (!(err instanceof Stripe.errors.StripeError) || err.code !== "resource_missing") throw err;
}
}
const c = await stripe.customers.create({ email: user.email, metadata: { userId: user.id } });
await db.user.update({ where: { id: user.id }, data: { stripeCustomerId: c.id } });
return c.id;
}stripe prices retrieve price_... # with the same key your server uses; add --live for a live key
stripe customers retrieve cus_... # a saved stripeCustomerId
pass if Both return the object instead of resource_missing, and a checkout started from your deployed app opens the Stripe page.
Prompt for Cursor or Claude Code
My Stripe checkout fails with 'No such price' or 'No such customer' (code resource_missing). Find every place this repo reads a Stripe key, a price id (price_) or a saved customer id (cus_, stripeCustomerId). Tell me which ids are hardcoded or stored in the database instead of coming from env vars, and give me a checklist so each environment uses keys, price ids and the webhook secret from one mode only (live in Production, test everywhere else). Where we reuse a saved customer id, make a new customer when Stripe returns resource_missing and save the new id. Never log or hardcode a secret key.Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Stripe webhook fixer.
Check your whole repo from the terminal: npx github:vibeboot/vibeboot-doctor (free, offline).
next: skip the next one
Skip the setup. The VibeBoot SaaS Starter ships Stripe Checkout, the billing portal and a signature-verified webhook already wired, plus auth and a database on Next.js 16. $49, one-time.
14-day money-back guarantee · lifetime updates
Other Stripe webhook errors
$ fixed it? get the next one first
New fixes for what AI agents break, by email.
When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.