Class: Pay::Braintree::Webhooks::SubscriptionExpired

Inherits:
Object
  • Object
show all
Defined in:
lib/pay/braintree/webhooks/subscription_expired.rb

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object


7
8
9
10
11
12
13
14
15
# File 'lib/pay/braintree/webhooks/subscription_expired.rb', line 7

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