From theviews/plans/new.html.erb
I get the plan_id and price params with the following:
<%= link_to "Sign up", new_store_registration_path(:plan_id => plan.id, :price => plan.price) %>
Then the app redirects to the sign-up page and with the following I keep the previous params and add the email as well:
registrations_controller.rb
def after_sign_up_path_for(resource)
new_transaction_path(session[:registration_params].merge(email: resource.email))
end
def after_inactive_sign_up_path_for(resource)
new_transaction_path(session[:registration_params].merge(email: resource.email))
end
Finally after sign-up, the app redirects to the views/transcation/new.html.erb, which has the plan_id
, price
and email
params.
Parameters: {"email"=>"example@gmail.com", "plan_id"=>"bs96", "price"=>"150.0"}
At this point I'm trying to pass the email param to the transaction with <%= hidden_field_tag(:email, params["email"]) %>
But not getting an email as you can see in the following:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"KeS2xK7NIJZwFQvW2kJKupcpURnQweq+yoRgk9AJ1aaOgFIIym4RKadI4jc6vYynMo4vKR4eLmdIynfBG+EusQ==", "email"=>"", "plan_id"=>"bs96", "amount"=>"150.0", "payment_method_nonce"=>"0c22f2fa-e212-0ad3-753b-0d183d02522b"}
Any ideas on what I'm doing wrong???
Update1
Inside the views/transcation/new.html.erb there is the braintree drop in ui and the script along with the three hidden fields:
<div class="form-container radius-box glassy-bg small-10 small-centered medium-8 large-6 columns">
<%= form_tag transactions_path do%>
<div id="dropin"></div>
<%= hidden_field_tag(:email, params["email"]) %>
<%= hidden_field_tag(:plan_id, params["plan_id"]) %>
<%= hidden_field_tag(:amount, params["price"]) %>
<%=submit_tag "Pay #{params["price"]}$", class: "button mt1" %>
<%end%>
</div>
<script>
braintree.setup("<%=@client_token%>", 'dropin', {
container: 'dropin'
});
</script>