The problem
Partner agents booked by phone and WhatsApp. Finance reconciled agent balances manually and there was a permanent gap between what agents believed they had booked and what the books recorded.
What we built
Built a wallet-first settlement engine. Balance check, wallet debit and booking write execute in a single database transaction, so a partial failure can leave neither a phantom booking nor a lost balance. Agents received a self-service portal with live balance, credit headroom, statement history and automated notification on every movement.
The naive implementation of an agent channel debits the wallet, then creates the booking. When the second step fails – and at scale it will – the agent has paid for nothing and support finds out days later from an angry phone call.
We wrapped balance validation, debit and booking creation in one transaction with correct lock ordering, so either all three commit or none do. Foreign key constraints were added to make the invalid intermediate states unrepresentable rather than merely unlikely.
The agent portal then made the position self-service: live balance, credit headroom, a statement where every line is labelled by movement type, and an email on every movement. The daily reconciliation calls stopped because both sides could see the same record.
Money and inventory move in the same instant, from a system the agent does not control. That is a transaction-integrity problem, not a UI problem.
