The Phantom Transaction
A customer places an order on your site. The STK Push is sent. They enter their PIN. Safaricom debits their account. You see the money in your M-Pesa Till. But your e-commerce dashboard still shows the order as "Pending Payment." You wait. You refresh. Nothing changes. The order is stuck in limbo.
This is the "Ghost Payment", a transaction that successfully completed on Safaricom's network but whose confirmation callback failed to reach your server. It is more common than you think, affecting an estimated 3 to 5 percent of STK transactions.
Why ghost payments happen
The STK Push API flow has two parts: (1) the push to the customer's phone, and (2) the callback from Safaricom to your server confirming the payment. If the callback fails due to a network hiccup, a server timeout, or a Safaricom gateway issue, your system never receives the confirmation.
The reconciliation hack: The "Double-Check" script
Stonehenge Digital implements a backup verification system that catches these ghost payments within minutes.
Step 1: The Primary Callback
Your system listens for Safaricom's confirmation callback as normal. If received within 60 seconds, the order is marked "Paid." Done.
Step 2: The "Reconciliation Query"
Every 10 minutes, a background script runs that fetches your recent M-Pesa Till transactions via the Safaricom API account statement endpoint. It looks for any incoming payments that match the approximate amount of any "Pending Payment" orders in your dashboard from the last 60 minutes.
const pendingOrders = getPendingOrders('last_60_mins');
const mpesaInflows = fetchMpesaStatement('today');
// Run fuzzy matching logic on amount and time
if (matchFound) { flagOrderForReview(); }
}
Step 3: The Smart Match
The script uses fuzzy matching logic. If a pending order is KSh 2,500, and the M-Pesa statement shows an incoming payment of KSh 2,500 from an unknown number within a 30 minute window, it flags a "Potential Match."
Step 4: The Customer Facing Fix
While the script is running, the customer who made the ghost payment sees a message on the order confirmation page. This reassures the customer and provides a manual fallback.
Peace of mind for you and your customer
From Limbo to Fulfilment
Ghost payments are a technical reality of mobile money. But they do not have to be a customer service crisis. With a reconciliation hack in place, you catch the phantoms before the customer even has to complain. The sale is saved, the order is fulfilled, and trust is maintained.
Do not rely solely on the STK Push callback. It will fail sometimes, leaving you with a paid customer and a stuck order.
Implement a background reconciliation script to catch the ghosts, and add a reassuring message for the customer in case they beat your system to the punch.
Ready to protect your store from ghost payments?
Stonehenge Digital builds e-commerce platforms with robust STK Push integrations, automated background reconciliation scripts, and customer-facing payment fallbacks, so no sale is ever left in limbo.
Protect My Store from Ghost Payments →Interested in E-Commerce Website with M-Pesa?
Let's build this for your business
Sell to any Kenyan with a phone. Full online shop with Safaricom STK Push payment — no card needed.