#acffaria91 - Checkout redirect

1 messages · Page 1 of 1 (latest)

proud flower
#

Hello, do you have the ID of a Checkout Session that you created that this happened with?

copper zephyr
#

Hi, yes: "cs_live_b1AiyJqaT3UweLt4xSkdGqiZ7mDZhLeu9VlUhY2tVULKb239C9oot3b47w"

proud flower
#

And what is the URL that your user got redirected to instead of the one you provided?

copper zephyr
#

I get a page with "cannot GET /pay/cs/..."

#

The thing is that because I'm on a POST method instead of replacing the url, the session url is added after my website's url

proud flower
#

What POST method are you trying to replace the URL with?

#

Or are you saying you want a POST to happen as the redirect?

copper zephyr
#

when I press the button the page should appear, but instead of getting the checkout page I get an error

proud flower
#

Ah, have you checked your server's code for the create-checkout-session endpoint?

#

Oh wait that is that code

copper zephyr
#

yes

#

that's why I don't understand how it can work, I followed stripe's docs

proud flower
#

Still looking in to this, the URL on the Session object itself definitely has the checkout URL rather than the one for your site

copper zephyr
#

yes, that part is correct

proud flower
#

And does the browser try to redirect to the checkout.stripe.com URL initially and then redirect to your site or does it just go to your site?

#

I don't see a custom domain on your account which was my initial guess as to what might be happening. Trying to think of what else would do this.

copper zephyr
#

yes, I don't have custom checkout, I can have the normal stripe checkout

#

on localhost everything is fine but I don't know why in live the first part of the url get's "lost"

copper zephyr
#

any idea of what this could be?

sturdy pendant
#

Hello! Taking over and catching up...

#

Can you share both your frontend code that sends people to Checkout and a screenshot of what you're seeing that's unexpected?

copper zephyr
#

Hi, thank you!

sturdy pendant
#

The error is coming from your own server because you don't have a GET route handler set up for that URL, which makes sense because I don't think you would be expected to have a URL like that. Do you have any JavaScript that's intercepting the <form> submit and running custom code/logic? Or are you running anything like Turbolinks?

copper zephyr
#

That is hard for me to answer, because I'm just re-doing the stripe checkout and the rest of the site was developed by someone else. There was some js that used to provide the info for the payments using the old api version, I added the form and the endpoint on the server. I made the click event that would unleash the other js commented

#

how can I have a get route handler for that url? I'm sorry, but I'm quite new to this

sturdy pendant
#

Can you search your code for preventDefault to see if you can find client-side JavaScript somewhere that's overriding the form submission?

copper zephyr
#

I found one on a checkout page, I commented it but no change in the result

sturdy pendant
#

Is this online somewhere where I can take a look?

copper zephyr
#

can you access it?

#

the server has some countries restrictions

sturdy pendant
#

Yep, that loads.

#

How do I get from here to Checkout/the error?

copper zephyr
#

you press the button on the bottom of the page

sturdy pendant
#

I'm getting an error about not being logged in.

copper zephyr
sturdy pendant
#

Looking now...

#

Alright, looks like something on your server is replacing https://checkout.stripe.com/ with https://www.ibasim.com/ in the Checkout Session's URL before redirecting to it. You can see in the creation request for the Checkout Session that the URL coming from Stripe is different: https://dashboard.stripe.com/logs/req_uDwYsZlkf61Dz0

#

Maybe there's some middleware or something doing that?

copper zephyr
#

yes, I noticed in the logs it was good. I'm not able to discover what is making that change

sturdy pendant
#

It's something on your server for sure, and that's what's causing the problem.

#

I can't give you any more specific guidance than that, unfortunately.

copper zephyr
#

do you think if I try to redirect on the client side it might solve it?

sturdy pendant
#

It could be a possible solution. You would need to change the server-side code to send the URL back to the client-side code instead of redirecting to it, then you can use window.location to navigate to that URL.

#

That's a bit more fragile than the current approach, but it's something a lot of people do.

copper zephyr
#

Ok, I'll try it

#

Thanks a lot for your help!

sturdy pendant
#

No problem, good luck with it! If there's anything else we can do to help let us know!