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.
-
#stripe_token ⇒ Object
This is a convenience method so we have a place to store StripeConnect temporary access tokens.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#stripe_customer ⇒ Object
Returns the value of attribute stripe_customer.
6 7 8 |
# File 'app/models/effective/customer.rb', line 6 def stripe_customer @stripe_customer end |
#stripe_subscription ⇒ Object
Returns the value of attribute stripe_subscription.
6 7 8 |
# File 'app/models/effective/customer.rb', line 6 def stripe_subscription @stripe_subscription end |
#stripe_token ⇒ Object
This is a convenience method so we have a place to store StripeConnect temporary access tokens
5 6 7 |
# File 'app/models/effective/customer.rb', line 5 def stripe_token @stripe_token end |
Class Method Details
Instance Method Details
#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 active_card.present? && token_required? 'Please update or confirm your card details to continue.' elsif active_card.present? 'Thanks for your support! The card we have on file is' else 'No credit card on file. Please add a card.' end.html_safe end |
#to_s ⇒ Object
39 40 41 |
# File 'app/models/effective/customer.rb', line 39 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 UPCOMING INVOICE RETRIEVE: #{stripe_customer_id}" ::Stripe::Invoice.upcoming(customer: stripe_customer_id) rescue nil end end |