Sha256: 72ed735f8bf682806307db2ecc8961ff7ba599c44c45f638449110d0056191df

Contents?: true

Size: 661 Bytes

Versions: 27

Compression:

Stored size: 661 Bytes

Contents

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

          object = event.data.object

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

          if Pay.send_email?(:payment_failed, pay_subscription)
            Pay.mailer.with(
              pay_customer: pay_subscription.customer,
              stripe_invoice: object
            ).payment_failed.deliver_now
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
pay-8.2.2 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.2.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.2.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.1.3 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.1.2 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.1.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.1.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-8.0.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-7.3.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-7.2.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-7.1.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-7.1.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-7.0.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.8.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.8.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.7.2 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.7.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.7.0 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.6.1 lib/pay/stripe/webhooks/payment_failed.rb
pay-6.6.0 lib/pay/stripe/webhooks/payment_failed.rb