7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/subscribers/invoice/capture_funds_handler.rb', line 7
def perform(event)
invoice = Invoice.find_by(id: event.data[:invoice_id])
return unless invoice
return if invoice.paid?
return unless invoice.unpaid?
invoice.capture_funds?
logger.info "Invoice::CaptureFundsHandler finished for invoice #{invoice.id}, state: #{invoice.state}"
rescue StateMachines::InvalidTransition => e
logger.warn "Invoice #{invoice&.id} state transition failed: #{e.message}"
ErrorReporting.warning(e, source: :res_handler, invoice_id: event.data[:invoice_id])
rescue StandardError => e
ErrorReporting.error(e)
raise
end
|