diff options
author | jessib <jessib@riseup.net> | 2013-10-17 13:58:54 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-10-17 13:58:54 -0700 |
commit | 92cb054d53aaac6864a6a805d9cdd3919f4a38bc (patch) | |
tree | 5751471169043c1b1867d9640551ae5cd2c8380e /billing/app/helpers/billing_helper.rb | |
parent | a6f32017f5c7802798f10e2f4041037fb5684def (diff) |
Some cleanup of code to deal with past due subscriptions.
Diffstat (limited to 'billing/app/helpers/billing_helper.rb')
-rw-r--r-- | billing/app/helpers/billing_helper.rb | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/billing/app/helpers/billing_helper.rb b/billing/app/helpers/billing_helper.rb index 68ed5b8..b9e5e2e 100644 --- a/billing/app/helpers/billing_helper.rb +++ b/billing/app/helpers/billing_helper.rb @@ -33,30 +33,19 @@ module BillingHelper if (transaction = subscription.transactions.first) # much quicker, but will only work if there is already a transaction associated with subscription (should generally be) - braintree_customer = transaction.customer_details + braintree_customer_id = transaction.customer_details.id else - search_results = Braintree::Customer.search do |search| - search.payment_method_token.is subscription.payment_method_token - end - braintree_customer = search_results.first + credit_card = Braintree::CreditCard.find(subscription.payment_method_token) + braintree_customer_id = credit_card.customer_id end - customer = Customer.find_by_braintree_customer_id(braintree_customer.id) + customer = Customer.find_by_braintree_customer_id(braintree_customer_id) user = User.find(customer.user_id) end - def show_set_user_subscriptions(set) - if set.empty? - return t(:none) - else - subscriptions_to_display = '' - set.each do |past_due_subscription| - subscriptions_to_display += render :partial => "subscriptions/subscription_details", :locals => {:subscription => past_due_subscription, :show_user => user_for_subscription(past_due_subscription)} - end - subscriptions_to_display.html_safe - end + def allow_cancel_subscription(subscription) + ['Active', 'Pending'].include? subscription.status or (admin? and subscription.status == 'Past Due') end - end |