Skip to content

Instantly share code, notes, and snippets.

@marcamillion
Created April 15, 2011 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marcamillion/922141 to your computer and use it in GitHub Desktop.
Save marcamillion/922141 to your computer and use it in GitHub Desktop.
new.html.erb
<div class="settings_form">
<h2>Checkout</h2>
<%= form_for :transaction,
:params => @result && @result.params[:transaction],
:errors => @result && @result.errors.for(:transaction),
:builder => ApplicationHelper::BraintreeFormBuilder,
:url => Braintree::TransparentRedirect.url,
:html => {:autocomplete => "off"} do |f| -%>
<%#= field_set_tag "Customer" do -%>
<%= f.fields_for :customer, @user do |c| -%>
<div><%= c.text_field :first_name, :placeholder => :first_name %></div>
<div><%= c.text_field :last_name, :placeholder => :last_name %></div>
<div><%= c.text_field :email, :placeholder => :email %></div>
<% end -%>
<br /><br />
<%# end -%>
<%#= field_set_tag "Credit Card" do -%>
<%= f.fields_for :credit_card do |c| -%>
<div><%= c.text_field :number, :placeholder => "Credit Card Number" %></div>
<div><%= c.text_field :expiration_date, :placeholder => "Expiration Date (MM/YY)" %></div>
<div><%= c.text_field :cvv, :placeholder => "CVV" %></div>
<% end -%>
<%# end -%>
<%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.create_customer_data(
:redirect_url => confirm_payment_url,
:customer => {
:id => @user.id }
) %>
<%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.create_credit_card_data(
:redirect_url => confirm_payment_url,
:credit_card => {
:customer_id => @user.id }
) %>
<%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.transaction_data(
:redirect_url => confirm_payment_url,
:transaction => {:type => "sale", :amount => @amount}
) %>
<%= f.submit "Submit", :class => "primary button" %>
<% end -%>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment