Sha256: 27da1943fe6d00eff0c88dca0f0199234246d29ff92928e50a0b02225a9e0899

Contents?: true

Size: 536 Bytes

Versions: 44

Compression:

Stored size: 536 Bytes

Contents

# A subscription reaches the specified number of billing cycles and expires.

module Pay
  module Braintree
    module Webhooks
      class SubscriptionExpired
        def call(event)
          subscription = event.subscription
          return if subscription.nil?

          pay_subscription = Pay::Subscription.find_by_processor_and_id(:braintree, subscription.id)
          return unless pay_subscription.present?

          pay_subscription.update!(ends_at: Time.current, status: :canceled)
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
pay-6.1.2 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.1.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.1.0 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.0.3 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.0.2 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.0.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-6.0.0 lib/pay/braintree/webhooks/subscription_expired.rb
pay-5.0.4 lib/pay/braintree/webhooks/subscription_expired.rb
pay-5.0.3 lib/pay/braintree/webhooks/subscription_expired.rb
pay-5.0.2 lib/pay/braintree/webhooks/subscription_expired.rb
pay-5.0.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-5.0.0 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.2.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.2.0 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.1.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.1.0 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.0.4 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.0.2 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.0.1 lib/pay/braintree/webhooks/subscription_expired.rb
pay-4.0.0 lib/pay/braintree/webhooks/subscription_expired.rb