I am attempting to add parameters to Stripe Checkout.
new.html.erb
<%= form_for @user do |f| %>
    <%= f.label :first_name %>
    <%= f.text_field :first_name %>
    <%= f.label :last_name %>
    <%= f.text_field :last_name %>
<% end %>
<%= form_tag charges_path, class: 'stripeform' do %>
    <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
            data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
            data-description="Beautiful"
            data-amount="<%= @price*100 %>"
            data-image="<%= image_tag "logo.png" %>"></script>
<% end %>
Considering Stripe has its own "submit" button, how would one pass additional parameters?
You can just add extra <input> fields inside the form you use for Checkout. They will get posted along with the Stripe token
<form action="/charge" method="POST">
  <input type="text" name="extraParam">
  <input type="text" name="extraParam2">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_XXX"
    data-image="/square-image.png"
    data-name="Demo Site"
    data-description="2 widgets ($20.00)"
    data-amount="2000">
  </script>
</form>
The other solution would be to use Custom Checkout to retrieve the token in the token() callback and then add it as a hidden input in your own form and submit that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With