diff options
author | jessib <jessib@riseup.net> | 2013-07-23 13:41:01 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-07-23 13:41:01 -0700 |
commit | 16128d6eb8bb8c7e467c263c3c4f79cf9869ed31 (patch) | |
tree | 69af795ece64fa7a79690b081a680175f0b774eb | |
parent | f757a6d519bfa27ef8d70f9bf1745626120225f1 (diff) |
Maybe not optimized, but gets working.
-rw-r--r-- | billing/app/controllers/customer_controller.rb | 3 | ||||
-rw-r--r-- | billing/app/models/customer.rb | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/billing/app/controllers/customer_controller.rb b/billing/app/controllers/customer_controller.rb index 887dbfd..c6cabe6 100644 --- a/billing/app/controllers/customer_controller.rb +++ b/billing/app/controllers/customer_controller.rb @@ -1,7 +1,10 @@ class CustomerController < BillingBaseController before_filter :authorize def show + customer.with_braintree_data! + @default_cc = customer.default_credit_card #TODO not actually right way @active_subscription = customer.subscriptions + @transactions = Braintree::Customer.find(customer.braintree_customer_id).transactions #TODO not actually right way end def new diff --git a/billing/app/models/customer.rb b/billing/app/models/customer.rb index 515e204..f01c300 100644 --- a/billing/app/models/customer.rb +++ b/billing/app/models/customer.rb @@ -41,10 +41,11 @@ class Customer < CouchRest::Model::Base # based on 2nd parameter, either returns the single active subscription (or nil if there isn't one), or an array of all subsciptions def subscriptions(braintree_data=nil, only_active=true) + self.with_braintree_data! return unless has_payment_info? subscriptions = [] - credit_cards.first.subscriptions.each do |sub| + self.default_credit_card.subscriptions.each do |sub| if only_active and sub.status == 'Active' return sub else |