Lovable·FixpaymentsStripeintermediate

Lovable Checkout Button Throws a Stripe Session 400 Error

Quick Answer

How do I fix Lovable Checkout Button Throws a Stripe Session 400 Error?

The checkout session request is usually missing a required field like a valid price ID, success URL, cancel URL, or customer email. In Lovable projects the hidden problem is often stale environment variables or test data copied into production. Start with "Read the exact failing field" before making broader code changes.

Fix signals

What this answers
Why lovable checkout button throws a stripe session 400 error happens and what to change first.
Fastest move
Read the exact failing field
Use this page if
The checkout button throws a 400 error

If this keeps happening

Open the next decision, not just the patch

Use these when the current fix is helpful, but the real answer is a better tool choice, a cleaner workflow layer, or a more trustworthy launch path.

Quick Fix Summary

Most likely causeThe checkout session request is usually missing a required field like a valid price ID, success URL, cancel URL, or customer email. In Lovable projects the hidden problem is often stale environment variables or test data copied into production.
Fastest fixRead the exact failing field
Use this page ifThe checkout button throws a 400 error

Exact errors people search for

If one of these matches what you are seeing, you are likely on the right fix page.

The checkout button throws a Stripe session 400 error
Stripe rejects the session before checkout even opens
Checkout route runs but Stripe says the request is invalid

You're in the right place if...

  • !The checkout button throws a 400 error
  • !Stripe session creation fails before redirecting
  • !The app reaches your API route but Stripe rejects the request

Why this happens

The checkout session request is usually missing a required field like a valid price ID, success URL, cancel URL, or customer email. In Lovable projects the hidden problem is often stale environment variables or test data copied into production.

Fix

1

Read the exact failing field

Open the server log or Vercel function log and read the first Stripe error line. Stripe usually tells you whether the missing piece is a bad price ID, malformed URL, or wrong mode.

2

Verify every checkout input

Check that the request sends a real price ID from the same Stripe mode, plus valid redirect URLs.

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: process.env.STRIPE_PRICE_ID, quantity: 1 }],
  success_url: `${process.env.NEXT_PUBLIC_SITE_URL}/billing/success`,
  cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL}/billing/cancelled`,
  customer_email: user.email,
});
3

Patch the generated payment route

Tell Lovable to validate the Stripe inputs before calling Stripe so the route fails with a useful app-level error instead of an opaque 400.

Copy this prompt

Audit the Stripe checkout session route in this app. Validate that the price ID, mode, success URL, cancel URL, and customer email are all present and in the correct Stripe mode before creating the session. If anything is missing, return a clear error instead of letting Stripe throw a generic 400.

Prevent this next time

Treat checkout session creation like an integration boundary. Validate mode, price IDs, and redirect URLs before calling Stripe.

Frequently Asked Questions

Because the request reaches Stripe but fails validation. The fastest fix is to read the first Stripe error line and verify each field in the session payload.

Yes. It often happens when production is using a live key with a test-mode price ID, or when the deployed site URL is missing from the environment variables.

Related fixes