Skip to content

Add reconciliation job to sync stuck processing invoices with Wise#1617

Open
nyomanjyotisa wants to merge 1 commit intomainfrom
reconcile-stuck-processing-invoices
Open

Add reconciliation job to sync stuck processing invoices with Wise#1617
nyomanjyotisa wants to merge 1 commit intomainfrom
reconcile-stuck-processing-invoices

Conversation

@nyomanjyotisa
Copy link
Member

@nyomanjyotisa nyomanjyotisa commented Feb 13, 2026

Resolves #1615

Description

Problem

If a Wise webhook fails or is not delivered, invoices can remain stuck in "processing" status indefinitely, even though the transfer has been completed or failed on Wise's side. This required manual intervention to resolve.

Solution

Add ReconcileProcessingInvoicesJob that runs every 4 hours to check the actual transfer status via the Wise API for invoices stuck in "processing"


AI Disclosure

Claude Opus 4.6 for code generation. All code self reviewed

@@ -0,0 +1,45 @@
# frozen_string_literal: true

class InvoicePaymentTransferUpdate
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New service extracted from WiseTransferUpdateJob to handle invoice payment transfer status updates to we can reuse it

payment.update!(status: Payment::SUCCEEDED, wise_transfer_amount: amount, wise_transfer_estimate: estimate)
invoice.mark_as_paid!(timestamp: Time.zone.parse(params.dig("data", "occurred_at")), payment_id: payment.id)
end
InvoicePaymentTransferUpdate.new(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the inline invoice payment status handling with the new InvoicePaymentTransferUpdate service

description: Sends monthly vesting report to company admins

reconcile_processing_invoices_job:
cron: "0 */4 * * *" # Every 4 hours
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every 4 hours is frequent enough to catch stuck invoices within a reasonable window, but conservative enough to not over-call the Wise API

Copy link
Member

@ershad ershad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyomanjyotisa _a lgtm 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add reconciliation job to sync stuck “processing” invoices with Wise

2 participants