Class: Payment::StripeRefundReconciliationWorker
- Inherits:
-
Object
- Object
- Payment::StripeRefundReconciliationWorker
- Includes:
- Sidekiq::Job, Workers::ErrorReportingConcern
- Defined in:
- app/workers/payment/stripe_refund_reconciliation_worker.rb
Overview
Sidekiq worker: nightly Stripe ↔ Heatwave refund reconciliation.
Picks up refunds created on the Stripe dashboard (typically by ops
resolving a duplicate charge or refund request) and syncs them back
into Heatwave's Payment state. Without this, a Stripe-side refund
leaves the local Payment row stuck at state="captured", the
accounting reports keep counting it as revenue, and the customer
shows up with a payment that doesn't match their bank statement.
Idempotent by Stripe refund id (re_xxx): records each refund as an
OrderTransaction keyed off reference: refund.id and skips refunds
already mirrored.
Constant Summary collapse
- WINDOW =
24.hours
- CURRENCIES =
%w[USD CAD].freeze
Instance Method Summary collapse
Methods included from Workers::ErrorReportingConcern
#report_worker_error, #report_worker_warning
Instance Method Details
#perform ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/workers/payment/stripe_refund_reconciliation_worker.rb', line 24 def perform CURRENCIES.each do |currency| reconcile_currency(currency) rescue StandardError => e report_worker_error(e, currency: currency) end end |