diff options
Diffstat (limited to 'billing')
-rw-r--r-- | billing/app/controllers/payments_controller.rb | 15 | ||||
-rw-r--r-- | billing/app/views/customer/_customer_data.html.haml (renamed from billing/app/views/payments/_customer_data.html.haml) | 0 | ||||
-rw-r--r-- | billing/app/views/customer/show.html.haml | 8 | ||||
-rw-r--r-- | billing/app/views/payments/_non_customer_fields.html.haml | 2 | ||||
-rw-r--r-- | billing/app/views/payments/_transaction_details.html.haml | 2 | ||||
-rw-r--r-- | billing/app/views/payments/confirm.html.haml | 7 | ||||
-rw-r--r-- | billing/app/views/payments/new.html.haml | 13 | ||||
-rw-r--r-- | billing/config/locales/en.yml | 3 | ||||
-rw-r--r-- | billing/test/functional/payments_controller_test.rb | 15 |
9 files changed, 17 insertions, 48 deletions
diff --git a/billing/app/controllers/payments_controller.rb b/billing/app/controllers/payments_controller.rb index 17ac0f3..0b5abe7 100644 --- a/billing/app/controllers/payments_controller.rb +++ b/billing/app/controllers/payments_controller.rb @@ -27,21 +27,8 @@ class PaymentsController < BillingBaseController def fetch_transparent_redirect - if logged_in? - if @customer = Customer.find_by_user_id(@user.id) - @customer.with_braintree_data! - braintree_customer_id = @customer.braintree_customer_id - @default_cc = @customer.default_credit_card - else - # TODO: this requires user to add self to vault before making payment. Is that desired functionality? - redirect_to new_customer_path, :notice => 'Before making payment, please add your customer data' - end - end - - # TODO: What is this supposed to do if braintree_customer_id was not set yet? - # Response: it can be used to make a payment that is not attributed to any customer (ie, a donation) @tr_data = Braintree::TransparentRedirect.transaction_data redirect_url: confirm_payment_url, - transaction: { type: "sale", customer_id: braintree_customer_id, options: {submit_for_settlement: true } } + transaction: { type: "sale", options: {submit_for_settlement: true } } end end diff --git a/billing/app/views/payments/_customer_data.html.haml b/billing/app/views/customer/_customer_data.html.haml index e9df040..e9df040 100644 --- a/billing/app/views/payments/_customer_data.html.haml +++ b/billing/app/views/customer/_customer_data.html.haml diff --git a/billing/app/views/customer/show.html.haml b/billing/app/views/customer/show.html.haml index 243bd3b..d91a4e7 100644 --- a/billing/app/views/customer/show.html.haml +++ b/billing/app/views/customer/show.html.haml @@ -1,10 +1,7 @@ - if admin? and !@customer = t(:no_saved_customer) - else - - if current_user == @user - .form-actions - = link_to t(:make_payment), new_payment_path, :class => 'btn btn-primary' - = render :partial => 'payments/customer_data' + = render :partial => 'customer_data' %legend= t(:last_three_transactions) - counter = 0 = # these will be ordered with most recently created first, per http://stackoverflow.com/questions/16425475/ @@ -25,3 +22,6 @@ = link_to t(:subscribe_to_plan), new_subscription_path, :class => :btn %p = link_to t(:all_subscriptions), user_subscriptions_path(@user) + +.form-actions + = link_to t(:make_donation), new_payment_path, :class => 'btn btn-primary' diff --git a/billing/app/views/payments/_non_customer_fields.html.haml b/billing/app/views/payments/_non_customer_fields.html.haml index 99b420d..77cfe95 100644 --- a/billing/app/views/payments/_non_customer_fields.html.haml +++ b/billing/app/views/payments/_non_customer_fields.html.haml @@ -1,4 +1,4 @@ -= field_set_tag "Customer" do += field_set_tag "Personal Information" do = f.fields_for :customer do |c| %div= c.label :first_name, "First Name" %div= c.text_field :first_name diff --git a/billing/app/views/payments/_transaction_details.html.haml b/billing/app/views/payments/_transaction_details.html.haml index 030639e..85e4f6a 100644 --- a/billing/app/views/payments/_transaction_details.html.haml +++ b/billing/app/views/payments/_transaction_details.html.haml @@ -11,5 +11,5 @@ - if sub_start = transaction.subscription_details.billing_period_start_date From subscription which started = sub_start - - else + - else # should not have any of these Not paid as part of subscription
\ No newline at end of file diff --git a/billing/app/views/payments/confirm.html.haml b/billing/app/views/payments/confirm.html.haml index 640c30a..45af3c9 100644 --- a/billing/app/views/payments/confirm.html.haml +++ b/billing/app/views/payments/confirm.html.haml @@ -1,5 +1,5 @@ %h1 Payment Result -%div Thank you for your payment. +%div Thank you for your donation. %h2 Transaction Details %table %tr @@ -23,7 +23,4 @@ %td= h @result.transaction.credit_card_details.masked_number %tr %td Card Type: - %td= h @result.transaction.credit_card_details.card_type -- if logged_in? - - customer = Customer.find_by_user_id(@user.id) - = link_to 'View Customer Info', show_customer_path(@user.id), :class=> :btn
\ No newline at end of file + %td= h @result.transaction.credit_card_details.card_type
\ 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 4523e13..e9a8273 100644 --- a/billing/app/views/payments/new.html.haml +++ b/billing/app/views/payments/new.html.haml @@ -1,18 +1,17 @@ %h1 - = t(:payment) + = t(:Donation) +- if logged_in? + = t(:donation_not_payment) - if @result and @result.errors.size > 0 %div{:style => "color: red;"} = h @result.errors.size error(s) -- if @result and @result.transaction and @result.transaction.status == 'processor_declined' +- if @result and @result.transaction and @result.transaction.status != 'success' %div{:style => "color: red;"} = t(:processor_declined) = braintree_form_for :transaction, :html => {:autocomplete => "off"} do |f| = f.label :amount, t(:amount) = f.text_field :amount - - if !@customer - = render :partial => 'non_customer_fields', :locals => {:f => f} - - else - = render :partial => 'customer_data' + = render :partial => 'non_customer_fields', :locals => {:f => f} = hidden_field_tag :tr_data, @tr_data - = f.submit "Submit Payment", :class => 'btn btn-primary' + = f.submit "Submit Donation", :class => 'btn btn-primary' diff --git a/billing/config/locales/en.yml b/billing/config/locales/en.yml index 5245b17..eda7da2 100644 --- a/billing/config/locales/en.yml +++ b/billing/config/locales/en.yml @@ -2,4 +2,5 @@ en: create_new_customer: "Create a new Braintree Customer" must_create_customer: "You must store a customer in braintree before subscribing to a plan" subscribe: "Subscribe" - save_customer_info: "Save Customer Information"
\ No newline at end of file + save_customer_info: "Save Customer Information" + donation_not_payment: "Note: This is a donation, and will not be applied towards your account."
\ No newline at end of file diff --git a/billing/test/functional/payments_controller_test.rb b/billing/test/functional/payments_controller_test.rb index 655aa16..90b7582 100644 --- a/billing/test/functional/payments_controller_test.rb +++ b/billing/test/functional/payments_controller_test.rb @@ -10,21 +10,6 @@ class PaymentsControllerTest < ActionController::TestCase assert_response :success end - test "authenticated user must create account before making payment" do - login - get :new - assert_response :redirect - assert_equal new_customer_url, response.header['Location'] - end - - test "payment when authenticated as customer" do - customer = stub_customer - login customer.user - get :new - assert_not_nil assigns(:tr_data) - assert_response :success - end - test "successful confirmation renders confirm" do Braintree::TransparentRedirect.expects(:confirm).returns(success_response) get :confirm |