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/invoice_paid.rb, line 9
def events
  ["invoice.paid"]
end

new(event)

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

Instance Public methods

call()

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

  clear_pending_payment_intent_subscriptions if invoice.payment_intent
  ::Api::FailedPaymentRecorder.new(invoice).recover!
  ::Api::PaymentsUpdatorJob.set(wait: 1.minute).perform_later(subscription_id: invoice.subscription)
  ::Api::FreeInvoiceCreator.new(stripe_invoice: invoice).create
end

clear_pending_payment_intent_subscriptions()

# File app/lib/stripe/event_handlers/invoice_paid.rb, line 27
def clear_pending_payment_intent_subscriptions
  DB::Subscription.where(pending_intent_id: invoice.payment_intent).update_all(pending_intent_id: nil)
end