Skip to content Skip to sidebar Skip to footer

Stripe And Tax_percent In My Rails App

So I've got my rails app selling subscriptions to access content. I'm temporarily inserting a hidden field in the check-out form to pass tax_percent to Stripe's API, but it keeps

Solution 1:

Why is your f.hidden_field inside the subscription object while your manual <input> is not, you ask? It’s because your manual input doesn’t use the naming convention for form fields that hidden_field automatically applies.

As the docs for #hidden_field show, your hidden field plan_id actually has a name attribute of subscription[plan_id], not plan_id. Another hidden field has to use the same subscription[…] convention for its value to be automatically put inside the hash at params["subscription"].

You can automatically make your tax_percent hidden field adhere to this naming convention by using the standalone form helper hidden_field:

<%= hidden_field :subscription, :tax_percent %>
<%= f.hidden_field :plan_id %>

Post a Comment for "Stripe And Tax_percent In My Rails App"