Sha256: 6c7e049f4a664b2edc0bd61dbe1b5c015174de13e9ae5b36af2c5b906d633037

Contents?: true

Size: 830 Bytes

Versions: 17

Compression:

Stored size: 830 Bytes

Contents

module Pay
  module Stripe
    module Webhooks
      class PaymentActionRequired
        def call(event)
          # Event is of type "invoice" see:
          # https://stripe.com/docs/api/invoices/object

          object = event.data.object

          subscription = Pay::Subscription.find_by_processor_and_id(:stripe, object.subscription)
          return if subscription.nil?
          billable = subscription.customer.owner

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

        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
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pay-3.0.17 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.16 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.15 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.14 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.13 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.12 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.11 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.10 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.9 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.8 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.7 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.6 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.5 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.4 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.2 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.1 lib/pay/stripe/webhooks/payment_action_required.rb
pay-3.0.0 lib/pay/stripe/webhooks/payment_action_required.rb