Sha256: b776018157b4f89f5cbbe837fbb1f01098a121e855fd96c9bb209181935a69c1

Contents?: true

Size: 702 Bytes

Versions: 10

Compression:

Stored size: 702 Bytes

Contents

module Pay
  module Stripe
    module Webhooks

      class CustomerDeleted
        def call(event)
          object = event.data.object
          user = Pay.user_model.find_by(processor: :stripe, processor_id: object.id)

          # Couldn't find user, we can skip
          return unless user.present?

          user.update(
            processor_id:   nil,
            trial_ends_at:  nil,
            card_type:      nil,
            card_last4:     nil,
            card_exp_month: nil,
            card_exp_year:  nil,
          )

          user.subscriptions.update_all(
            trial_ends_at: nil,
            ends_at: Time.zone.now,
          )
        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/customer_deleted.rb
pay-1.0.1 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.rc3 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.rc2 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.rc1 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.beta5 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.beta4 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.beta3 lib/pay/stripe/webhooks/customer_deleted.rb
pay-1.0.0.beta2 lib/pay/stripe/webhooks/customer_deleted.rb