Monnify and Paystack Webhook Silent Drops: Building a Poll-and-Lock Reconciliation Engine in Go
Bank transfers via dynamic virtual accounts in Nigeria suffer a 2-3% webhook drop rate during peak banking hours. This case study details how we eliminated double-crediting race conditions and automated transfer reconciliation using Go and PostgreSQL row locks.
Engagement Overview: The 3% Black Hole in Bank Transfers
In early 2024, Neobot Tech was brought in to audit and refactor the core payment ingested by a high-volume Nigerian digital wallet app. The client was processing roughly 85,000 daily bank transfer deposits across dynamic virtual accounts generated via Monnify and Paystack. Customers would request a wallet top-up, receive an ephemeral virtual account number tied to Wema Bank or Fidelity Bank, send money via their commercial bank's mobile app through the NIBSS Instant Payments (NIP) network, and wait for their wallet balance to reflect.
On paper, the workflow relies entirely on webhooks. When NIBSS settles the interbank transfer into the payment processor’s provider account, the processor sends an HTTP POST payload (charge.success for Paystack or transaction notification for Monnify) to the merchant server. The merchant server verifies the HMAC signature, updates the transaction status, and credits the user's wallet balance.
In reality, Nigerian banking infrastructure breaks this happy path daily. During peak hours—typically 4:00 PM to 8:00 PM on weekdays and payday weekends—between 2% and 4% of valid transaction webhooks never reached our client's servers or failed silently. Cloudflare ingress timeouts, upstream socket resets at the aggregator level, and gateway 504 errors meant funds landed safely in the gateway settlement account while the customer's app screen hung indefinitely.
The customer support desk was inundated with manual intervention requests. Worse, when support staff manually pushed funds, delayed webhooks would occasionally land hours later, double-crediting user wallets.

The Constraints: CBN Compliance, Financial Risk, and Latency SLA
Fixing this system meant working within strict operational constraints imposed by both financial regulators and end-user behavior:
- Zero Double-Crediting Tolerated: Under no circumstances could a wallet be funded twice for a single NIP Session ID or Gateway Transaction Reference. In a system handling hundreds of millions of Naira daily, double-credits directly eat into company equity.
- Strict NDPR Compliance: Customer identity details tied to virtual account generation, including BVNs and bank details, could not be dumped unencrypted into secondary logging tools to debug drops. See our technical breakdown on Why Storing Raw BVNs in PostgreSQL Is an NDPR Liability: Building a Zero-Leakage HMAC Blind Index.
- Sub-60 Second Resolution SLA: If a user completes an NIP transfer, their wallet must reflect the credit within 60 seconds, even if the primary HTTP webhook payload was completely lost in transit.
- Flaky Gateway Query APIs: Querying payment provider verification endpoints (
/transaction/verify/:refor Monnify's transaction status API) during network outages often resulted in rate limits (429 Too Many Requests) or prolonged 500 errors.
What We Tried First (And Why It Failed)
Before Neobot Tech took over the architecture, the client's internal team attempted two straightforward fixes. Both failed in production under high concurrency.
Attempt 1: Naive Retries via Background Queues
When a customer opened the app and complained about an uncredited transfer, the frontend triggered an aggressive polling request to the backend. The backend queued a background worker using standard background jobs to poll the payment provider's API every 15 seconds until the status turned SUCCESSFUL.
Why it failed: This created a severe race condition. When NIBSS bank congestion suddenly cleared, the payment provider would bulk-fire backlogged webhooks at the exact same moment the background worker was executing a poll request. Because the database update logic lacked atomic isolation, both threads read the transaction as PENDING, both verified the transaction as paid, and both issued an append statement to the user balance. The company lost over ₦4.2 million in phantom wallet credits in two weeks.
Attempt 2: Naive Cron Reconciliation without DB Locking
To capture dropped webhooks for inactive users, the team ran a 10-minute cron job that scanned all PENDING virtual account sessions older than 5 minutes and checked their status against the Monnify API Documentation and Paystack endpoints.
Why it failed: The job hit gateway rate limits almost immediately. Fetching status sequentially for 1,200 pending accounts took 8 minutes. When the job overlapped with the next cron execution, duplicate queries saturated the app's PostgreSQL connection pool, throwing 53300: too_many_connections errors and crashing the main application server.
The Solution: A Dual-Ledger Poll-and-Lock Engine in Go
We redesigned the payment processing pipeline around three core patterns:
- Strict Idempotency Keys at the Database Level: Utilizing composite unique constraints on NIP Session IDs and Provider References inside an append-only double-entry transaction ledger.
- Distributed Redis Locks + Postgres Row-Level Locking: Ensuring that a delayed incoming Webhook worker and an automated Polling worker could never process the same reference concurrently.
- State Machine Poll-and-Lock Worker: A Go background service leveraging
SELECT ... FOR UPDATE SKIP LOCKEDto safely query provider status for stuck transactions without blocking database connections or risking queue backlog execution. For a deeper discussion on task queue architectures in high-latency environments, refer to our comparison of BullMQ vs Temporal vs AWS Step Functions: Architecting 72-Hour Payment Retries for Flaky Nigerian Bank APIs.
+-----------------------+ +-----------------------+
| Incoming Webhook Worker| | Scheduled Poll Worker |
+-----------------------+ +-----------------------+
| |
v v
+-----------------------------------------------------------+
| Redis Distributed Lock (Key: tx_ref) |
| If locked -> Fail fast / Skip execution |
+-----------------------------------------------------------+
| (Lock Acquired)
v
+-----------------------------------------------------------+
| PostgreSQL Transaction: BEGIN |
| SELECT * FROM pending_deposits |
| WHERE reference = $1 FOR UPDATE |
+-----------------------------------------------------------+
|
v
+-----------------------------------------------------------+
| Is Deposit Status == 'COMPLETED'? |
| YES -> ROLLBACK & Release Lock (Exit) |
| NO -> Execute Double-Entry Credit Ledger Insert |
+-----------------------------------------------------------+
|
v
+-----------------------------------------------------------+
| UPDATE pending_deposits SET status = 'COMPLETED' |
| COMMIT & Release Lock |
+-----------------------------------------------------------+
Technical Deep Dive: Implementation Details
Below is the concrete implementation of our poll-and-lock reconciliation mechanism written in Go. It illustrates how database transactions are held with FOR UPDATE NOWAIT to prevent concurrent webhook-and-polling execution.
Neobot Engineering Standard
Every system deployed by Neobot Tech incorporates enterprise baseline practices. We continuously audit our database topologies, REST API query paths, and frontend modular bundles to prevent latency spikes and ensure top-tier security posture.
Discussion
Comments Coming Soon
We are currently migrating our discussion engine to a new real-time database schema. Check back shortly to join the conversation.