diff options
author | jessib <jessib@leap.se> | 2013-04-01 11:35:10 -0700 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-07-17 10:47:12 +0200 |
commit | bee5c4a93f6bf664609673d7e703476f15147fe3 (patch) | |
tree | ff57a2267399dc22636eb2e328de7a56d4d123ae /billing/app/models/customer.rb | |
parent | c436fce774573d090ab77617dbf55b25b2da4ea2 (diff) |
Some tweaks to optimize number of requests to braintree API.
Diffstat (limited to 'billing/app/models/customer.rb')
-rw-r--r-- | billing/app/models/customer.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/billing/app/models/customer.rb b/billing/app/models/customer.rb index 0fc3751..8085d32 100644 --- a/billing/app/models/customer.rb +++ b/billing/app/models/customer.rb @@ -16,21 +16,22 @@ class Customer < CouchRest::Model::Base end # from braintree_ruby_examples/rails3_tr_devise and should be tweaked +=begin def with_braintree_data! return self unless has_payment_info? braintree_data = Braintree::Customer.find(braintree_customer_id) - debugger #FIELDS.each do |field| # send(:"#{field}=", braintree_data.send(field)) #end self end +=end - ##?? - def default_credit_card + #slow to get Braintree Customer data, so pass it if have already retrieved it + def default_credit_card(braintree_data = nil) return unless has_payment_info? - braintree_data = Braintree::Customer.find(braintree_customer_id) + braintree_data = braintree_data || Braintree::Customer.find(braintree_customer_id) braintree_data.credit_cards.find { |cc| cc.default? } end |