By the PAYJN Operations team
A player in Bangladesh taps "Buy 500 gems", gets sent to confirm the payment in bKash, and takes a little too long to come back. Your checkout page shows "Payment timed out". The player opens a support ticket with a screenshot showing that the money left their wallet.
Nothing is broken. You have three timers that ended at different moments, and your code treated the first one as the answer.
This is a hypothetical walkthrough, not a production incident. It applies to bKash, Nagad, Upay or any wallet checkout where the customer confirms the payment outside your page.
Three timers, three questions
| Timer | Who owns it | What its expiry actually means |
|---|---|---|
| Checkout countdown | Your frontend | The player stopped looking at your page |
| Reservation / session | Your backend | You may release stock or a promotion slot |
| Payment instruction expiry | The provider | The instruction can no longer be paid |
Only the third one tells you anything about money, and even then you should get the final status from the provider instead of working it out from a clock.
The wallet confirmation step (a PIN or verification code on a hosted page, a jump to the wallet app, or a USSD session, depending on your integration) runs on its own timing. Your countdown has no idea where the player is in that flow.
Model payment and fulfilment as separate states
The most common bug is a single status column that holds pending | paid | expired | delivered. When the countdown fires, the order becomes expired, and a success notification that arrives later has nowhere legitimate to land.
Split it:
CREATE TABLE orders ( order_id TEXT PRIMARY KEY, player_id TEXT NOT NULL, sku TEXT NOT NULL, amount_bdt INTEGER NOT NULL, checkout_state TEXT NOT NULL, -- open | closed payment_state TEXT NOT NULL, -- pending | succeeded | failed | expired fulfil_state TEXT NOT NULL, -- none | queued | delivered | exception provider_ref TEXT UNIQUE, fulfil_key TEXT UNIQUE -- one grant per order ); Closing the checkout changes checkout_state only. Only the provider can move payment_state. Only a fulfilment job can move fulfil_state.
Handle the late success
When a notification arrives for an order whose checkout is already closed, do not reject it. Verify it, then decide what to deliver.
async function onPaymentNotification(evt) { // 1. Never trust the payload alone: confirm with a server-side status query. const status = await provider.queryPayment(evt.orderId); if (status.state !== "succeeded") return recordNonFinal(evt.orderId, status); await db.tx(async (t) => { const order = await t.lockOrder(evt.orderId); if (order.amount_bdt !== status.amount) return t.flagException(order, "amount_mismatch"); if (order.payment_state === "succeeded") return; // repeated notification, already handled await t.markPaid(order, status.providerRef); // 2. Payment succeeded; delivery is a separate question. if (await isStillDeliverable(t, order)) { await t.queueFulfilment(order, `grant:${order.order_id}`); // unique key } else { await t.flagException(order, "paid_after_reservation_lapsed"); } }); } Two details matter:
- The unique fulfilment key stops a notification retry and a reconciliation job from both granting the gems.
-
isStillDeliverableis a business rule, not a payment rule. A limited-time bundle may have ended. In that case the payment is still real, and support resolves it under your refund or substitution policy.
What support should not do
The instinctive fix is "please try again". If the first payment later turns out to have succeeded, the player has now paid twice. Resolve the first payment's outcome before giving any new payment instruction.
The opposite is also true: if the provider reports the instruction as expired or failed, a screenshot of a wallet screen is not a receipt. Escalate it with the provider reference instead of crediting by hand.
Five launch tests
- Close the checkout, then deliver a genuine success notification. Expect one grant and no second charge.
- Send a
pendingnotification after a confirmed success. The order must not roll back. - Run the notification handler and the reconciliation job at the same moment. Expect exactly one grant.
- Drop the game server's response to a grant, then retry. Check delivery history first.
- Let the player start a second checkout while the first is still confirming. Both payments must stay traceable to their own orders.
If those five pass, a closed countdown becomes a UI event again, not a money event.
Disclosure
I work at PAYJN, which provides local collections and payouts for game and app platforms in Bangladesh and other South and Southeast Asian markets. The patterns above apply whichever provider you use. Our bKash, Nagad and Upay game top-up timeout guide has a longer operating checklist, including what support should record for a late confirmation.