Class: Effective::Subscripter
- Inherits:
-
Object
- Object
- Effective::Subscripter
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/effective/subscripter.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#stripe_plan_id ⇒ Object
Returns the value of attribute stripe_plan_id.
-
#stripe_token ⇒ Object
Returns the value of attribute stripe_token.
-
#subscribable ⇒ Object
Returns the value of attribute subscribable.
-
#subscribable_global_id ⇒ Object
Returns the value of attribute subscribable_global_id.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
7 8 9 |
# File 'app/models/effective/subscripter.rb', line 7 def current_user @current_user end |
#customer ⇒ Object
Returns the value of attribute customer.
7 8 9 |
# File 'app/models/effective/subscripter.rb', line 7 def customer @customer end |
#quantity ⇒ Object
Returns the value of attribute quantity.
8 9 10 |
# File 'app/models/effective/subscripter.rb', line 8 def quantity @quantity end |
#stripe_plan_id ⇒ Object
Returns the value of attribute stripe_plan_id.
8 9 10 |
# File 'app/models/effective/subscripter.rb', line 8 def stripe_plan_id @stripe_plan_id end |
#stripe_token ⇒ Object
Returns the value of attribute stripe_token.
8 9 10 |
# File 'app/models/effective/subscripter.rb', line 8 def stripe_token @stripe_token end |
#subscribable ⇒ Object
Returns the value of attribute subscribable.
7 8 9 |
# File 'app/models/effective/subscripter.rb', line 7 def subscribable @subscribable end |
#subscribable_global_id ⇒ Object
Returns the value of attribute subscribable_global_id.
8 9 10 |
# File 'app/models/effective/subscripter.rb', line 8 def subscribable_global_id @subscribable_global_id end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'app/models/effective/subscripter.rb', line 7 def user @user end |
Instance Method Details
#destroy! ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/models/effective/subscripter.rb', line 68 def destroy! subscription = subscribable.subscription return true if subscription.blank? Rails.logger.info " -> [STRIPE] delete subscription" subscription.stripe_subscription.delete subscription.destroy! end |
#plan ⇒ Object
47 48 49 |
# File 'app/models/effective/subscripter.rb', line 47 def plan EffectiveOrders.stripe_plans.find { |plan| plan[:id] == stripe_plan_id } end |
#save! ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/models/effective/subscripter.rb', line 59 def save! raise 'is invalid' unless valid? create_customer! create_stripe_token! save_subscription! true end |
#to_s ⇒ Object
27 28 29 |
# File 'app/models/effective/subscripter.rb', line 27 def to_s 'Your Plan' end |
#token_required? ⇒ Boolean
55 56 57 |
# File 'app/models/effective/subscripter.rb', line 55 def token_required? customer.token_required? end |