Skip to content

Feat/be 092 payment reconciliation - #1979

Open
Dev-Savio-hub wants to merge 2 commits into
StellarDevHub:mainfrom
Dev-Savio-hub:feat/be-092-payment-reconciliation
Open

Dev-Savio-hub wants to merge 2 commits into
StellarDevHub:mainfrom
Dev-Savio-hub:feat/be-092-payment-reconciliation

Conversation

@Dev-Savio-hub

Copy link
Copy Markdown

this pr closes #1839

Summary

Implements automated multi-currency payment reconciliation and slippage auditing for Stellar token payments (XLM, USDC, EURC).

Changes

  • Prisma Schema (backend/prisma/schema.prisma):
    • Extended PaymentRecord with multi-currency and reconciliation fields (currency, expectedAmount, settledAmount, slippageBps, ledgerSequence, reconciliationStatus, reconciledAt, alertTriggered, reviewNotes).
    • Added ReconciliationAlert and ReconciliationReport models for accounting alerts and daily audit snapshots.
  • Reconciliation Worker (backend/src/workers/paymentReconciliationWorker.ts):
    • Added HorizonLedgerClient to poll finalized Stellar ledger transactions and payment operations (XLM, USDC, EURC).
    • Implemented calculateSlippageBps, reconcilePayment, reconcilePaymentsBatch, and runReconciliationCycle with configurable slippage tolerance and partial payment thresholds.
    • Added automated accounting alerts (logged, persisted, and optionally delivered via ACCOUNTING_ALERT_WEBHOOK_URL) for partial payments, slippage breaches, currency mismatches, failed transactions, and missing on-chain settlements.
    • Added daily financial reconciliation report generation (generateDailyReconciliationReport) with CSV (exportReconciliationReportCsv) and JSON (exportReconciliationReportJson) exporters, plus background polling lifecycle (startPaymentReconciliationWorker / stopPaymentReconciliationWorker).
  • Subscriptions Route (backend/src/routes/subscriptions.ts):
    • Enforced multi-currency token validation (XLM, USDC, EURC) on plan creation and tracked reconciliation metadata on payments.
    • Added reconciliation endpoints: POST /reconciliation/run, GET /reconciliation/flagged, POST /reconciliation/alerts/:alertId/resolve, and GET /reconciliation/reports/daily?format=json|csv.
  • Tests (backend/src/tests/paymentReconciliationWorker.test.ts):
    • Added unit tests covering multi-currency reconciliation, slippage calculation, partial payments, missing/failed/mismatched transactions, alert resolution, and daily CSV/JSON report exports.

Verification

  • Ran npx jest src/tests/paymentReconciliationWorker.test.ts --runInBand --forceExit (7/7 tests passed).

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Dev-Savio-hub is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Dev-Savio-hub Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
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.

[BE-092] Multi-Currency Payment Gateway Reconciliation Worker with Slippage Auditing

1 participant