#tomconolly - checkout & rails

1 messages · Page 1 of 1 (latest)

knotty wolf
#

Are you redirecting server-side after a fetch to your back end?

rigid lily
#

I'm creating a customer & price, then using them immediately to request the checkout page.

knotty wolf
#

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)

rigid lily
#

Not sure how to answer that. I'm using a controller in Rails to send the request to Stripe.

knotty wolf
#

What triggers this back end controller to operate?

rigid lily
#

A "pay" button on the front end

#

Pay button triggers the controller to assemble price, etc and redirect to fetch the url.

knotty wolf
#

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

rigid lily
#

All works well but the browser refuses to display the checkout page.

#

Zero javascript on my end (except for the Stripe.js, of course)

knotty wolf
#

Hmm interesting. How is the customer info send to the server then?

rigid lily
#

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.

teal maple
#

Hello! I'm taking over... can you share the code that's producing the error you're seeing?

teal maple
#

If you're using Turbo it looks like you need to add data-turbo="false" to the Checkout link.

rigid lily
#

OK. I'm trying that. Thanks

#

data: { turbo: 'false' }, because I'm inside a Rails helper. This did the trick! Thank you Rubeus!