From 1e4245907ca17d1d6afbeca82b25c35c970ba499 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 2 Jul 2013 17:14:32 +0200 Subject: billing: functional test for payments controller --- billing/app/controllers/payments_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'billing/app/controllers') diff --git a/billing/app/controllers/payments_controller.rb b/billing/app/controllers/payments_controller.rb index 97e0353..99b7af8 100644 --- a/billing/app/controllers/payments_controller.rb +++ b/billing/app/controllers/payments_controller.rb @@ -1,4 +1,4 @@ -class PaymentsController < ApplicationController +class PaymentsController < BillingBaseController before_filter :authorize, :only => [:index] def new @@ -28,17 +28,18 @@ class PaymentsController < ApplicationController def fetch_transparent_redirect if current_user if @customer = Customer.find_by_user_id(current_user.id) - @braintree_data = Braintree::Customer.find(@customer.braintree_customer_id) - @default_cc = @customer.default_credit_card(@braintree_data) + @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 - @tr_data = Braintree::TransparentRedirect.transaction_data(:redirect_url => confirm_payment_url, - :transaction => {:type => "sale", :customer_id => braintree_customer_id, :options => {:submit_for_settlement => true } }) + # TODO: What is this supposed to do if braintree_customer_id was not set yet? + @tr_data = Braintree::TransparentRedirect.transaction_data redirect_url: confirm_payment_url, + transaction: { type: "sale", customer_id: braintree_customer_id, options: {submit_for_settlement: true } } end end -- cgit v1.2.3