fix: harden invoice reconciliation
This commit is contained in:
@@ -105,6 +105,21 @@ async function runTick(): Promise<void> {
|
||||
for (const invoice of pendingInvoices) {
|
||||
try {
|
||||
const providerInvoice = await paymentProviderAdapter.getInvoiceStatus(invoice.providerInvoiceId);
|
||||
|
||||
if (providerInvoice.providerInvoiceId !== invoice.providerInvoiceId) {
|
||||
reconciliationSummary.failedCount += 1;
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
service: "worker",
|
||||
event: "invoice_reconciliation_provider_mismatch",
|
||||
invoiceId: invoice.id,
|
||||
requestedProviderInvoiceId: invoice.providerInvoiceId,
|
||||
returnedProviderInvoiceId: providerInvoice.providerInvoiceId,
|
||||
}),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const result = await billingStore.reconcilePendingInvoice({
|
||||
invoiceId: invoice.id,
|
||||
providerStatus: providerInvoice.status,
|
||||
|
||||
Reference in New Issue
Block a user