Skip to Content Skip to Search
Methods
C
E
N
Included Modules

Attributes

[R] event

Class Public methods

events()

# File app/lib/stripe/event_handlers/customer_subscription_updated.rb, line 9
def events
  ["customer.subscription.updated"]
end

new(event)

# File app/lib/stripe/event_handlers/customer_subscription_updated.rb, line 14
def initialize(event)
  @event = event
end

Instance Public methods

call()

# File app/lib/stripe/event_handlers/customer_subscription_updated.rb, line 18
def call
  return unless self.class.events.include?(event.type) && subscription.present?

  if incomplete_or_canceled?
    subscription.update_attribute(:pending_intent_id, nil)
  end

  if previously_incomplete? && subscription.incomplete_status?
    ::Api::AsyncIncompletePlanProvisionerJob
      .set(wait: 1.minute)
      .perform_later(event.id, event.try(:account))
  end

  subscription.update_attribute(:status, new_status)

  if cancel_at_period_end?
    subscription.update_attribute(:cancels_on, subscription_cancels_on)
  else
    subscription.update_attribute(:cancels_on, nil)
  end

  if previous_status?
    ::EventBus.publish("member.updated", member:)
  end
end