Behind the Build: Handling Mobile Money Webhooks & Failed USSD Prompts at Scale
The unspoken engineering challenges of integrating telecom APIs in Ghana, dealing with delayed callbacks, and guaranteeing zero lost transactions.

Kelvin Agyare Yeboah
Founder & Lead Engineer, Zoharix

The Telecom Webhook Reality
When building [Z-Events](https://z-events.zoharix.tech), the payment pipeline was our highest-risk subsystem.
In mature markets using Stripe, card authorizations happen over synchronous HTTPS within 500ms. In Ghana, over 88% of event ticket transactions occur via Mobile Money (MTN MoMo, Telecel Cash, AT Money).
The flow requires: 1. Initiating a payment prompt request to the telecom gateway. 2. The telco pushing an asynchronous USSD prompt to the user's mobile screen. 3. The user entering their 4-digit PIN. 4. The telco processing the ledger debit. 5. The telco sending an asynchronous HTTP webhook back to our server.
The catch? Step 5 can take anywhere from **2 seconds to 15 minutes**, or occasionally never arrive if telco webhook queues back up under high national load.
1. Idempotent Reservation State Machine
To prevent ticket overselling while waiting for slow telco callbacks, we built an explicit state machine:
- `PENDING_PAYMENT` (Holds inventory lock for 10 minutes)
- `PROCESSING_CALLBACK` (Webhook received, payload signature verified)
- `TICKET_ISSUED` (Ed25519 signature generated, WhatsApp notification queued)
- `EXPIRED` (Inventory returned to pool if no authorization received within TTL)
interface TransactionState {
id: string;
ticketBatchId: string;
amount: number;
phone: string;
network: "MTN" | "TELECEL" | "AT";
status: "INITIATED" | "WAITING_USSD" | "CONFIRMED" | "FAILED";
idempotencyKey: string;
expiresAt: Date;
}2. Active Polling Fallback Worker
Never trust webhooks alone for financial transactions. We implemented a background worker that polls telco status endpoints if no webhook callback is received after 45 seconds.
If the user approved the PIN prompt but the telco webhook was dropped, our worker recovers the status, issues the ticket, and dispenses the pass to the customer's WhatsApp before they even reach the help desk.
3. Results on Z-Events
Since implementing this hybrid webhook-plus-poller architecture: - 99.4% of ticket purchases complete under 3 seconds. - Zero duplicate charges during high-demand festival drops. - Attendees receive their WhatsApp ticket with zero friction.
Read more about our overall ticketing platform in our [Z-Events flagship architecture breakdown](/insights/z-events).

Explore Z-Events Platform
Sub-second Mobile Money ticketing, instant WhatsApp tickets, and offline gate operations built in Accra for the continent.
