Class: Pay::Stripe::Webhooks::SubscriptionRenewing
- Inherits:
-
Object
- Object
- Pay::Stripe::Webhooks::SubscriptionRenewing
- Defined in:
- lib/pay/stripe/webhooks/subscription_renewing.rb
Instance Method Summary collapse
Instance Method Details
#call(event) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/pay/stripe/webhooks/subscription_renewing.rb', line 5 def call(event) # Event is of type "invoice" see: # https://stripe.com/docs/api/invoices/object subscription = Pay.subscription_model.find_by(processor: :stripe, processor_id: event.data.object.subscription) return unless subscription notify_user(subscription.owner, subscription, Time.zone.at(event.data.object.next_payment_attempt)) end |
#notify_user(billable, subscription, date) ⇒ Object
14 15 16 17 18 |
# File 'lib/pay/stripe/webhooks/subscription_renewing.rb', line 14 def notify_user(billable, subscription, date) if Pay.send_emails Pay::UserMailer.with(billable: billable, subscription: subscription, date: date).subscription_renewing.deliver_later end end |