From 04288c2a2179d7aa71a2fa21267e6f02fb0400e2 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 21 Mar 2013 13:51:58 -0700 Subject: Unauthenticated users can make single payments (like donations), but payments from authenticated users will be as a Braintree Customer stored in the braintree vault. --- .../app/views/payments/_customer_data.html.haml | 15 +++++++++++++++ .../views/payments/_non_customer_fields.html.haml | 16 ++++++++++++++++ billing/app/views/payments/new.html.haml | 22 +++++----------------- 3 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 billing/app/views/payments/_customer_data.html.haml create mode 100644 billing/app/views/payments/_non_customer_fields.html.haml (limited to 'billing/app/views/payments') diff --git a/billing/app/views/payments/_customer_data.html.haml b/billing/app/views/payments/_customer_data.html.haml new file mode 100644 index 0000000..900fbd8 --- /dev/null +++ b/billing/app/views/payments/_customer_data.html.haml @@ -0,0 +1,15 @@ +%h2 Customer Information +%dl + %dt First Name + %dd= @braintree_data.first_name + %dt Last Name + %dd= @braintree_data.last_name + %dt Phone + %dd= @braintree_data.phone +%h2 Credit Card Information +%dl + %dt Number + %dd= @default_cc.masked_number + %dt Expiration Date + %dd= @default_cc.expiration_date += link_to 'edit saved data', edit_customer_path(@customer.braintree_customer_id), :class => :btn diff --git a/billing/app/views/payments/_non_customer_fields.html.haml b/billing/app/views/payments/_non_customer_fields.html.haml new file mode 100644 index 0000000..99b420d --- /dev/null +++ b/billing/app/views/payments/_non_customer_fields.html.haml @@ -0,0 +1,16 @@ += field_set_tag "Customer" do + = f.fields_for :customer do |c| + %div= c.label :first_name, "First Name" + %div= c.text_field :first_name + %div= c.label :last_name, "Last Name" + %div= c.text_field :last_name + %div= c.label :email, "Email" + %div= c.text_field :email += field_set_tag "Credit Card" do + = f.fields_for :credit_card do |c| + %div= c.label :number, "Number" + %div= c.text_field :number + %div= c.label :expiration_date, "Expiration Date (MM/YY)" + %div= c.text_field :expiration_date + %div= c.label :cvv, "CVV" + %div= c.text_field :cvv \ No newline at end of file diff --git a/billing/app/views/payments/new.html.haml b/billing/app/views/payments/new.html.haml index b6dd713..d9c41ce 100644 --- a/billing/app/views/payments/new.html.haml +++ b/billing/app/views/payments/new.html.haml @@ -5,21 +5,9 @@ = h @result.errors.size error(s) = 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| - %div= c.label :first_name, "First Name" - %div= c.text_field :first_name - %div= c.label :last_name, "Last Name" - %div= c.text_field :last_name - %div= c.label :email, "Email" - %div= c.text_field :email - = field_set_tag "Credit Card" do - = f.fields_for :credit_card do |c| - %div= c.label :number, "Number" - %div= c.text_field :number - %div= c.label :expiration_date, "Expiration Date (MM/YY)" - %div= c.text_field :expiration_date - %div= c.label :cvv, "CVV" - %div= c.text_field :cvv - = hidden_field_tag :tr_data, Braintree::TransparentRedirect.transaction_data(:redirect_url => confirm_payment_url,:transaction => {:type => "sale", :amount => @amount, :options => {:submit_for_settlement => true } }) + - if !@customer + = render :partial => 'non_customer_fields', :locals => {:f => f} + - else + = render :partial => 'customer_data' + = hidden_field_tag :tr_data, @tr_data = f.submit "Submit" \ No newline at end of file -- cgit v1.2.3