6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/jobs/spree/bank_payments/expire_sessions_job.rb', line 6
def perform
Spree::BankPayments::Gateway.find_each do |payment_method|
unless payment_method.reconciler_healthy?
Spree::Events.publish(
'bank_transfer.reconciler_unhealthy',
{
payment_method_id: payment_method.id,
reconciler: payment_method.preferred_reconciler,
last_successful_run_at: payment_method.reconciler_state.last_successful_run_at&.iso8601,
last_error: payment_method.reconciler_state.last_error
}
)
next
end
expire_for(payment_method)
rescue StandardError => e
Spree::Events.publish(
'bank_transfer.expiry_failed',
{
payment_method_id: payment_method.id,
error: e.message
}
)
Rails.error.report(e, source: 'spree_bank_payments.expire_sessions')
next
end
end
|