From 3ffac4e77a118ee6ec7d369b0250c11830c2f7e0 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 12 Mar 2013 13:32:46 -0700 Subject: Basic functionality for one time transactions using Braintree's transparent redirect API based from https://github.com/braintree/braintree_ruby_examples/tree/master/rails3_tr_checkout (very little changes were required) --- billing/app/views/payments/confirm.html.erb | 16 ++++++++++++ billing/app/views/payments/new.html.erb | 38 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 billing/app/views/payments/confirm.html.erb create mode 100644 billing/app/views/payments/new.html.erb (limited to 'billing/app/views/payments') diff --git a/billing/app/views/payments/confirm.html.erb b/billing/app/views/payments/confirm.html.erb new file mode 100644 index 0000000..5ab851e --- /dev/null +++ b/billing/app/views/payments/confirm.html.erb @@ -0,0 +1,16 @@ +

Payment Result

+ +
Thank you for your payment.
+ +

Transaction Details

+ + + + + + + + + +
Amount$<%= @result.transaction.amount %>
Transaction ID:<%= @result.transaction.id %>
First Name:<%= h @result.transaction.customer_details.first_name %>
Last Name:<%= h @result.transaction.customer_details.last_name %>
Email:<%= h @result.transaction.customer_details.email %>
Credit Card:<%= h @result.transaction.credit_card_details.masked_number %>
Card Type:<%= h @result.transaction.credit_card_details.card_type %>
+ diff --git a/billing/app/views/payments/new.html.erb b/billing/app/views/payments/new.html.erb new file mode 100644 index 0000000..092c518 --- /dev/null +++ b/billing/app/views/payments/new.html.erb @@ -0,0 +1,38 @@ +

Payment: $<%= h @amount %>

+ +<% if @result -%> +
<%= h @result.errors.size %> error(s)
+<% end -%> + +<%= form_for :transaction, + :params => @result && @result.params[:transaction], + :errors => @result && @result.errors.for(:transaction), + :builder => BraintreeHelper::BraintreeFormBuilder, + :url => Braintree::TransparentRedirect.url, + :html => {:autocomplete => "off"} do |f| -%> + <%= field_set_tag "Customer" do -%> + <%= f.fields_for :customer do |c| -%> +
<%= c.label :first_name, "First Name" %>
+
<%= c.text_field :first_name %>
+
<%= c.label :last_name, "Last Name" %>
+
<%= c.text_field :last_name %>
+
<%= c.label :email, "Email" %>
+
<%= c.text_field :email %>
+ <% end -%> + <% end -%> + <%= field_set_tag "Credit Card" do -%> + <%= f.fields_for :credit_card do |c| -%> +
<%= c.label :number, "Number" %>
+
<%= c.text_field :number %>
+
<%= c.label :expiration_date, "Expiration Date (MM/YY)" %>
+
<%= c.text_field :expiration_date %>
+
<%= c.label :cvv, "CVV" %>
+
<%= c.text_field :cvv %>
+ <% end -%> + <% end -%> + <%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.transaction_data( + :redirect_url => confirm_payment_url, + :transaction => {:type => "sale", :amount => @amount} + ) %> + <%= f.submit "Submit" %> +<% end -%> -- cgit v1.2.3