Class: Effective::Subscription

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
EffectiveStripeHelper
Defined in:
app/models/effective/subscription.rb

Constant Summary

Constants included from EffectiveStripeHelper

EffectiveStripeHelper::STRIPE_CONNECT_AUTHORIZE_URL, EffectiveStripeHelper::STRIPE_CONNECT_TOKEN_URL

Instance Method Summary collapse

Methods included from EffectiveStripeHelper

#is_stripe_connect_seller?, #link_to_new_stripe_connect_customer, #stripe_coupon_description, #stripe_plan_description, #stripe_plans_collection

Instance Method Details

#stripe_couponObject



60
61
62
63
64
# File 'app/models/effective/subscription.rb', line 60

def stripe_coupon
  if stripe_coupon_id.present?
    @stripe_coupon ||= (Stripe::Coupon.retrieve(stripe_coupon_id) rescue nil)
  end
end

#stripe_coupon_id=(coupon_id) ⇒ Object



45
46
47
48
49
50
51
52
# File 'app/models/effective/subscription.rb', line 45

def stripe_coupon_id=(coupon_id)
  unless self[:stripe_coupon_id] == coupon_id
    self[:stripe_coupon_id] = coupon_id
    @stripe_coupon = nil   # Remove any memoization

    assign_price_and_title()
  end
end

#stripe_planObject



54
55
56
57
58
# File 'app/models/effective/subscription.rb', line 54

def stripe_plan
  if stripe_plan_id.present?
    @stripe_plan ||= (Stripe::Plan.retrieve(stripe_plan_id) rescue nil)
  end
end

#stripe_plan_id=(plan_id) ⇒ Object



36
37
38
39
40
41
42
43
# File 'app/models/effective/subscription.rb', line 36

def stripe_plan_id=(plan_id)
  unless self[:stripe_plan_id] == plan_id
    self[:stripe_plan_id] = plan_id
    @stripe_plan = nil   # Remove any memoization

    assign_price_and_title()
  end
end

#stripe_subscriptionObject



66
67
68
69
70
# File 'app/models/effective/subscription.rb', line 66

def stripe_subscription
  if stripe_subscription_id.present?
    @stripe_subscription ||= (customer.stripe_customer.subscriptions.retrieve(stripe_subscription_id) rescue nil)
  end
end

#tax_exemptObject



32
33
34
# File 'app/models/effective/subscription.rb', line 32

def tax_exempt
  true
end