#tomconolly - checkout & rails
1 messages · Page 1 of 1 (latest)
I'm creating a customer & price, then using them immediately to request the checkout page.
Sure, but what is the mechanism of the request from your client app t your server?
You might want to instead return the session url to the client and redirect client-side, this would eliminate these CORS issue
(whether you can configure the request to work with the server redirect depends on exactly how its made)
Not sure how to answer that. I'm using a controller in Rails to send the request to Stripe.
What triggers this back end controller to operate?
A "pay" button on the front end
Pay button triggers the controller to assemble price, etc and redirect to fetch the url.
Right, so whatever that Pay button does, instead you may need to return the session url to the client JS to redirect, eg with window.location
All works well but the browser refuses to display the checkout page.
Zero javascript on my end (except for the Stripe.js, of course)
Right, the issue is that your server isn't returning CORS headers that the browser is able to use to control the flow, similar to this:
https://stackoverflow.com/questions/65008084/javascript-response-to-preflight-request-doesnt-pass-access-control-check/65008317
(it's a node server here, though)
Hmm interesting. How is the customer info send to the server then?
Rails turbo is behind-the-scenes.
Customer can't send info to stripe server because of the cors issue. Otherwise customer would merely fill in the checkout form and hit "pay." I presume Stripe is using js at this point, as they construct the form.
I saw that SO post but couldn't translate it to Rails.
Hello! I'm taking over... can you share the code that's producing the error you're seeing?
If you're using Turbo it looks like you need to add data-turbo="false" to the Checkout link.