Stripe payment intent

I got this error message and am unsure with it means

‘price_########’; a similar object exists in live mode, but a test mode key was used to make this request.

it means that you are trying to retrieve a live price, but you are using the test key, which can only access prices created in test mode.
To ease development Stripe has a separated environment, the test mode, where you can try any operation without actually charging a user. If you save Stripe resources in your database for later use you need to keep track of this difference. If you manually created a price in the Stripe dashboard you need to create another one in the test mode dashboard and use one or the other depending on wheter youo are developing in the editor or using the live app.
You can use the browser environment variable from the context to dynamically select the right value:

It can be one of editor, staging, preview, production.

1 Like