Class: Pay::Stripe::Webhooks::PaymentActionRequired

Inherits:
Object
  • Object
show all
Defined in:
lib/pay/stripe/webhooks/payment_action_required.rb

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pay/stripe/webhooks/payment_action_required.rb', line 5

def call(event)
  # Event is of type "invoice" see:
  # https://stripe.com/docs/api/invoices/object

  object = event.data.object

  subscription = Pay.subscription_model.find_by(processor: :stripe, processor_id: object.subscription)
  return if subscription.nil?
  billable = subscription.owner

  notify_user(billable, event.data.object.payment_intent, subscription)
end

#notify_user(billable, payment_intent_id, subscription) ⇒ Object



18
19
20
21
22
# File 'lib/pay/stripe/webhooks/payment_action_required.rb', line 18

def notify_user(billable, payment_intent_id, subscription)
  if Pay.send_emails
    Pay::UserMailer.with(billable: billable, payment_intent_id: payment_intent_id, subscription: subscription).payment_action_required.deliver_later
  end
end