#Anil
1 messages · Page 1 of 1 (latest)
Hi there, what's the details of the error?
This is the error.
Actually i have a button and when i click on button i want to open the checkout page
Ok, basically in your button click handler, you create a request to your backend and the backend responds with a 30x redirect response code, am I right?
Yes, in backend i have created a api and inside api i am using stripe.checkout.sessions.crete
OK, the easiest way to fix this problem is using a form submission. -> Create a form and put your button inside, set the form's action to your backend endpoint that create a checkout session
Okay but on button click why is not working.
It's a limitation of browser implementation.
There's another way.
Instead of redirecting (i.e., 30x response code), your backend can respond a 200 to your frontend, where you need to call window.href.location=CHECKOUT_URL to manually redirect to the checkout page.
Okay, yes when i try to return res as 303, i am getting error as api key is not defined.
Now i do as you say
Check your code and see if the API key is set properly.
Yes i have set the api key
How about your backend code?
This is the backend code
Can you check if the values are set in the .env file?
Yes values are set
OK, can you share with me the full error message?
This is showing in console.
Where do you see this error? in your own page or checkout page?
In my own page.
Can do you know which line of your code cause the error?