#Ese
1 messages · Page 1 of 1 (latest)
How are you making your request to your server that creates the checkout session? Are you doing a form submit or are you doing a fetch request?
form submit
Can you show me a small snippet of what your client-side code looks like?
Ok, I have a page that currently only has a button so I know that stripe is working before moving forward. Here is the code:
<%= form_with url: checkout_path, method: :post, class:"" do |f| %>
<%= f.submit "Checkout", class:"btn btn-success" %>
<% end %>
Are you possible using the turbo plugin (https://github.com/hotwired/turbo-rails) ?
Or do you have data-remote enabled?
No, I will take a look at the turbo plugin
I don't think I have data-remote enabled unless it is enabled by default
Yeah I think the details may have changed depending on your rails version - try setting local: true with your form_with (https://dev.to/notapatch/formwith-option-change-from-local-false-to-local-true-1pmb)
Changing the local: to true or false did not change anything
And I am using the turbo-rails plugin because it comes there by default with rails 7
Ah, that's the issue then - you'll need to disable turbo for your form
Disabling turbo did not change anything unless I am disabling it wrong
How are you disabling it?
This is my new code:
<%= form_with url: checkout_path, method: :post, class:"", turbo: false do |f| %>
<%= f.submit "Checkout", class:"btn btn-success" %>
<% end %>
Try this:
<%= form_with url: checkout_path, method: :post, class:"", local: true, data: { turbo:false } do |f| %>
That worked.
Thank you
awesome! glad to hear it 🙂
Ah, I got another issue, It does not stop stripe from working but in the Stripe CLI I am getting a 422 POST instead of a 202 or 200 ok POST
You need to be more specific - what request specifically are you getting the 422 post for?
When I go through the form and proceed with the checkout. The payment gets processed and on the webhooks that is listening to the transactions I get this data:
--> charge.succeeded [evt_stuff1]
--> payment_intent.succeeded [evt_stuff2]
--> checkout.session.completed [evt_stuff3]
--> payment_intent.created [evt_stuff4]
<-- [422] POST http:// localhost:3000/checkout [evt_stuff1]
<-- [422] POST http:// localhost:3000/checkout [evt_stuff2]
<-- [422] POST http:// localhost:3000/checkout [evt_stuff3]
<-- [422] POST http:// localhost:3000/checkout [evt_stuff4]
That's your localhost server returned 422 to our Webhook events. You have your server log, you can see where it stucked and which logic it ran through