Sha256: 4c1f1ece8dbdf7143b920f2e902d60d9f4f5824861a8f364b6c472677f54195a

Contents?: true

Size: 669 Bytes

Versions: 10

Compression:

Stored size: 669 Bytes

Contents

module Pay
  module Stripe
    module Webhooks

      class SubscriptionRenewing
        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
          )
          notify_user(subscription.owner, subscription) if subscription.present?
        end

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

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pay-1.0.2 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.1 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.rc3 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.rc2 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.rc1 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.beta5 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.beta4 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.beta3 lib/pay/stripe/webhooks/subscription_renewing.rb
pay-1.0.0.beta2 lib/pay/stripe/webhooks/subscription_renewing.rb