Module: Koudoku::Subscription
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/concerns/koudoku/subscription.rb
Instance Method Summary collapse
- #card_was_declined ⇒ Object
- #changing_plans? ⇒ Boolean
- #charge_disputed ⇒ Object
- #charge_failed ⇒ Object
-
#coupon_code=(new_code) ⇒ Object
Set a Stripe coupon code that will be used when a new Stripe customer (a.k.a. Koudoku subscription) is created.
- #describe_difference(plan_to_describe) ⇒ Object
- #downgrading? ⇒ Boolean
- #finalize_cancelation! ⇒ Object
- #finalize_card_update! ⇒ Object
- #finalize_downgrade! ⇒ Object
- #finalize_new_customer!(customer_id, amount) ⇒ Object
- #finalize_new_subscription! ⇒ Object
- #finalize_plan_change! ⇒ Object
- #finalize_upgrade! ⇒ Object
-
#payment_succeeded(amount) ⇒ Object
stripe web-hook callbacks.
- #prepare_for_cancelation ⇒ Object
- #prepare_for_card_update ⇒ Object
- #prepare_for_downgrade ⇒ Object
- #prepare_for_new_subscription ⇒ Object
-
#prepare_for_plan_change ⇒ Object
Template methods.
- #prepare_for_upgrade ⇒ Object
-
#subscription_owner ⇒ Object
Pretty sure this wouldn’t conflict with anything someone would put in their model.
- #subscription_owner=(owner) ⇒ Object
- #subscription_owner_description ⇒ Object
- #subscription_owner_email ⇒ Object
- #upgrading? ⇒ Boolean
Instance Method Details
#card_was_declined ⇒ Object
240 241 |
# File 'app/concerns/koudoku/subscription.rb', line 240 def card_was_declined end |
#changing_plans? ⇒ Boolean
188 189 190 |
# File 'app/concerns/koudoku/subscription.rb', line 188 def changing_plans? plan_id_changed? end |
#charge_disputed ⇒ Object
250 251 |
# File 'app/concerns/koudoku/subscription.rb', line 250 def charge_disputed end |
#charge_failed ⇒ Object
247 248 |
# File 'app/concerns/koudoku/subscription.rb', line 247 def charge_failed end |
#coupon_code=(new_code) ⇒ Object
Set a Stripe coupon code that will be used when a new Stripe customer (a.k.a. Koudoku subscription) is created
162 163 164 |
# File 'app/concerns/koudoku/subscription.rb', line 162 def coupon_code=(new_code) @coupon_code = new_code end |
#describe_difference(plan_to_describe) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'app/concerns/koudoku/subscription.rb', line 140 def describe_difference(plan_to_describe) if plan.nil? if persisted? "Upgrade" else if Koudoku.free_trial? "Start Trial" else "Upgrade" end end else if plan_to_describe.is_upgrade_from?(plan) "Upgrade" else "Downgrade" end end end |
#downgrading? ⇒ Boolean
192 193 194 |
# File 'app/concerns/koudoku/subscription.rb', line 192 def downgrading? plan.present? and plan_id_was.present? and plan_id_was > self.plan_id end |
#finalize_cancelation! ⇒ Object
234 235 |
# File 'app/concerns/koudoku/subscription.rb', line 234 def finalize_cancelation! end |
#finalize_card_update! ⇒ Object
237 238 |
# File 'app/concerns/koudoku/subscription.rb', line 237 def finalize_card_update! end |
#finalize_downgrade! ⇒ Object
231 232 |
# File 'app/concerns/koudoku/subscription.rb', line 231 def finalize_downgrade! end |
#finalize_new_customer!(customer_id, amount) ⇒ Object
225 226 |
# File 'app/concerns/koudoku/subscription.rb', line 225 def finalize_new_customer!(customer_id, amount) end |
#finalize_new_subscription! ⇒ Object
222 223 |
# File 'app/concerns/koudoku/subscription.rb', line 222 def finalize_new_subscription! end |
#finalize_plan_change! ⇒ Object
219 220 |
# File 'app/concerns/koudoku/subscription.rb', line 219 def finalize_plan_change! end |
#finalize_upgrade! ⇒ Object
228 229 |
# File 'app/concerns/koudoku/subscription.rb', line 228 def finalize_upgrade! end |
#payment_succeeded(amount) ⇒ Object
stripe web-hook callbacks.
244 245 |
# File 'app/concerns/koudoku/subscription.rb', line 244 def payment_succeeded(amount) end |
#prepare_for_cancelation ⇒ Object
213 214 |
# File 'app/concerns/koudoku/subscription.rb', line 213 def prepare_for_cancelation end |
#prepare_for_card_update ⇒ Object
216 217 |
# File 'app/concerns/koudoku/subscription.rb', line 216 def prepare_for_card_update end |
#prepare_for_downgrade ⇒ Object
210 211 |
# File 'app/concerns/koudoku/subscription.rb', line 210 def prepare_for_downgrade end |
#prepare_for_new_subscription ⇒ Object
204 205 |
# File 'app/concerns/koudoku/subscription.rb', line 204 def prepare_for_new_subscription end |
#prepare_for_plan_change ⇒ Object
Template methods.
201 202 |
# File 'app/concerns/koudoku/subscription.rb', line 201 def prepare_for_plan_change end |
#prepare_for_upgrade ⇒ Object
207 208 |
# File 'app/concerns/koudoku/subscription.rb', line 207 def prepare_for_upgrade end |
#subscription_owner ⇒ Object
Pretty sure this wouldn’t conflict with anything someone would put in their model
167 168 169 170 171 |
# File 'app/concerns/koudoku/subscription.rb', line 167 def subscription_owner # Return whatever we belong to. # If this object doesn't respond to 'name', please update owner_description. send Koudoku.subscriptions_owned_by end |
#subscription_owner=(owner) ⇒ Object
173 174 175 176 |
# File 'app/concerns/koudoku/subscription.rb', line 173 def subscription_owner=(owner) # e.g. @subscription.user = @owner send Koudoku.owner_assignment_sym, owner end |
#subscription_owner_description ⇒ Object
178 179 180 181 182 |
# File 'app/concerns/koudoku/subscription.rb', line 178 def subscription_owner_description # assuming owner responds to name. # we should check for whether it responds to this or not. "#{subscription_owner.try(:name) || subscription_owner.try(:id)}" end |
#subscription_owner_email ⇒ Object
184 185 186 |
# File 'app/concerns/koudoku/subscription.rb', line 184 def subscription_owner_email "#{subscription_owner.try(:email)}" end |
#upgrading? ⇒ Boolean
196 197 198 |
# File 'app/concerns/koudoku/subscription.rb', line 196 def upgrading? (plan_id_was.present? and plan_id_was < plan_id) or plan_id_was.nil? end |