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
17
# 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

  user = event.data.object.customer

  subscription = Pay.subscription_model.find_by(
    processor: :stripe,
    processor_id: event.data.object.subscription
  )

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

#notify_user(user, payment_intent_id, subscription) ⇒ Object



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

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