Lovable·FixpaymentsStripeintermediate

Lovable Stripe Checkout Session Returning 400

Quick Answer

Lovable is sending Stripe a malformed Checkout request. The most common causes are the wrong price ID, using subscription mode for a one-time price, or passing relative success and cancel URLs instead of absolute URLs. Start with "Verify the Stripe price ID and mode" before making broader code changes.

You're in the right place if...

  • !Stripe checkout creation fails with a 400 error
  • !The buy button spins and never redirects
  • !Stripe logs show an invalid price, mode, or URL

Why this happens

Lovable is sending Stripe a malformed Checkout request. The most common causes are the wrong price ID, using subscription mode for a one-time price, or passing relative success and cancel URLs instead of absolute URLs.

Fix

1

Verify the Stripe price ID and mode

Check that the price ID exists in the same Stripe mode you are testing and that the Checkout session mode matches the product type.

2

Make Lovable regenerate the server-side checkout function

Use a precise prompt instead of trying to patch the Stripe call manually.

Copy this prompt

Stripe checkout is returning a 400 error.
Please rebuild the checkout session server function so it:
1. uses the correct Stripe price ID
2. uses mode 'payment' for one-time purchases or 'subscription' for recurring plans
3. sends absolute success and cancel URLs
4. returns the Stripe checkout URL cleanly to the frontend
3

Check the redirect URLs

Stripe requires absolute URLs in production. Do not send '/success' or '/pricing' by themselves.

success_url: `${process.env.NEXT_PUBLIC_APP_URL}/payment-success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/pricing`

Prevent this next time

Keep Stripe price IDs in one configuration file or table. Hardcoding different values in multiple places is the fastest way to create 400 errors.

Frequently Asked Questions

Checkout sessions require absolute return URLs so Stripe knows exactly where to send the user after payment.

No. Test and live mode objects are completely separate in Stripe.

Related fixes

Weekly Newsletter

Get next week's fix before you need it.

Join developers getting weekly vibe coding tips, error fixes, and tool updates.

Subscribe on Substack →