summaryrefslogtreecommitdiff
path: root/billing/app/controllers/customer_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'billing/app/controllers/customer_controller.rb')
-rw-r--r--billing/app/controllers/customer_controller.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/billing/app/controllers/customer_controller.rb b/billing/app/controllers/customer_controller.rb
index 505aa6e..1fa19c9 100644
--- a/billing/app/controllers/customer_controller.rb
+++ b/billing/app/controllers/customer_controller.rb
@@ -10,16 +10,12 @@ class CustomerController < BillingBaseController
if customer = Customer.find_by_user_id(current_user.id)
redirect_to edit_customer_path(customer.braintree_customer_id), :notice => 'Here is your saved customer data'
else
- @tr_data = Braintree::TransparentRedirect.
- # create_customer_data(:redirect_url => confirm_customer_url(-1)) # trial
- create_customer_data(:redirect_url => confirm_customer_url)
+ fetch_new_transparent_redirect_data
end
end
def edit
- @tr_data = Braintree::TransparentRedirect.
- update_customer_data(:redirect_url => confirm_customer_url,
- :customer_id => params[:id])
+ fetch_edit_transparent_redirect_data
end
def confirm
@@ -35,8 +31,10 @@ class CustomerController < BillingBaseController
#elsif current_user.has_payment_info?
elsif (customer = Customer.find_by_user_id(current_user.id)) and customer.has_payment_info?
#customer.with_braintree_data!
+ fetch_edit_transparent_redirect_data
render :action => "edit"
else
+ fetch_new_transparent_redirect_data
render :action => "new"
end
end
@@ -54,4 +52,16 @@ class CustomerController < BillingBaseController
end
end
+ def fetch_new_transparent_redirect_data
+ @tr_data = Braintree::TransparentRedirect.
+ create_customer_data(:redirect_url => confirm_customer_url)
+ end
+
+ def fetch_edit_transparent_redirect_data
+ @tr_data = Braintree::TransparentRedirect.
+ update_customer_data(:redirect_url => confirm_customer_url,
+ :customer_id => params[:id]) ##??
+
+ end
+
end