#Anil

1 messages · Page 1 of 1 (latest)

open cargoBOT
runic halo
#

Hi there, what's the details of the error?

vale acorn
#

This is the error.

#

Actually i have a button and when i click on button i want to open the checkout page

runic halo
#

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?

vale acorn
#

Yes, in backend i have created a api and inside api i am using stripe.checkout.sessions.crete

runic halo
#

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

vale acorn
#

Okay but on button click why is not working.

runic halo
#

It's a limitation of browser implementation.

vale acorn
#

Okay.

#

So basically without form action we can't use it right?

runic halo
#

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.

vale acorn
#

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

runic halo
#

Check your code and see if the API key is set properly.

vale acorn
#

Yes i have set the api key

runic halo
#

How about your backend code?

vale acorn
#

This is the backend code

runic halo
#

Can you check if the values are set in the .env file?

vale acorn
#

Yes values are set

runic halo
#

OK, can you share with me the full error message?

vale acorn
#

This is showing in console.

runic halo
#

Where do you see this error? in your own page or checkout page?

vale acorn
#

In my own page.

runic halo
#

Can do you know which line of your code cause the error?