Class: Payment::StripeRefundReconciliationWorker

Inherits:
Object
  • Object
show all
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 =

Currencies.

24.hours
CURRENCIES =

Constant.

%w[USD CAD].freeze

Instance Method Summary collapse

Methods included from Workers::ErrorReportingConcern

#report_worker_error, #report_worker_warning

Instance Method Details

#performObject

Runs the job.

Returns:

  • (Object)

    the result



29
30
31
32
33
34
35
# File 'app/workers/payment/stripe_refund_reconciliation_worker.rb', line 29

def perform
  CURRENCIES.each do |currency|
    reconcile_currency(currency)
  rescue StandardError => e
    report_worker_error(e, currency: currency)
  end
end