Class: Effective::Customer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Customer
- Defined in:
- app/models/effective/customer.rb
Instance Attribute Summary collapse
-
#stripe_customer ⇒ Object
Returns the value of attribute stripe_customer.
-
#stripe_subscription ⇒ Object
Returns the value of attribute stripe_subscription.
Class Method Summary collapse
Instance Method Summary collapse
- #email ⇒ Object
- #payment_status ⇒ Object
- #to_s ⇒ Object
- #token_required? ⇒ Boolean
- #upcoming_invoice ⇒ Object
Instance Attribute Details
#stripe_customer ⇒ Object
Returns the value of attribute stripe_customer.
5 6 7 |
# File 'app/models/effective/customer.rb', line 5 def stripe_customer @stripe_customer end |
#stripe_subscription ⇒ Object
Returns the value of attribute stripe_subscription.
5 6 7 |
# File 'app/models/effective/customer.rb', line 5 def stripe_subscription @stripe_subscription end |
Class Method Details
Instance Method Details
#email ⇒ Object
39 40 41 |
# File 'app/models/effective/customer.rb', line 39 def email user.email if user end |
#payment_status ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/effective/customer.rb', line 68 def payment_status if status == 'past_due' 'We ran into an error processing your last payment. Please update or confirm your card details to continue.' elsif status == 'active' "Your payment is in good standing. Thanks so much for your support!" elsif active_card.blank? 'No credit card on file. Please add a card.' else 'Please update or confirm your card details to continue.' end.html_safe end |
#to_s ⇒ Object
35 36 37 |
# File 'app/models/effective/customer.rb', line 35 def to_s user.to_s.presence || 'New Customer' end |
#token_required? ⇒ Boolean
64 65 66 |
# File 'app/models/effective/customer.rb', line 64 def token_required? active_card.blank? || (active_card.present? && stripe_subscription_id.present? && status != 'active') end |
#upcoming_invoice ⇒ Object
57 58 59 60 61 62 |
# File 'app/models/effective/customer.rb', line 57 def upcoming_invoice @upcoming_invoice ||= if stripe_customer_id.present? && stripe_subscription_id.present? Rails.logger.info "[STRIPE] get upcoming invoice: #{stripe_customer_id}" ::Stripe::Invoice.upcoming(customer: stripe_customer_id) rescue nil end end |