Debited but not credited: timeouts, status queries and reversals between banks
A timeout is the sending bank's problem and nobody else's: the customer is already debited, the switch has stopped waiting, and the receiver may have paid. Ask before you reverse
In the lab week 101 transfers got a timeout from the switch, after the sender had debited its customer. About how many of them did a later status query confirm as credited at the receiving bank?
Module 2 taught a timeout as a state: payment states, failures, reversals and refunds gave the payer’s side an “unknown” state with one exit, and idempotency and moving money exactly once showed how to ask safely. This chapter sits at the bank that holds the customer’s account, where the debit has already happened and a person on a desk decides what the customer sees. It reuses the status query from transfers and virtual accounts and the rail in Nigeria’s rails.
The lab is the rails week, a separate generator that writes the whole network from the switch’s point of view. Every code, timeout, fee and delay in it is illustrative: it models what the course teaches, not NIBSS, the CBN or any bank. The real rules sit in dated notes with their sources, and where this build could not read a source, the chapter says so.
What happens at 15:29
Take one transfer from the lab week, sent by B11 to Northmere (B05) rather than by Northmere but of the same shape. A customer sends ₦16,295.00 to a customer at B05. Four things happen to it, in this order.
First, the sending bank debits its customer’s account and sends the instruction through the switch. At that moment the money is no longer the customer’s. It is not yet the receiver’s either. Second, the switch waits for the receiving bank to answer, gives up at its own limit (30 seconds in the lab), and tells the sender “97”, the lab’s timeout code. Third, the sending bank, which has heard nothing definite, reverses its customer at 15:30:37, 45 seconds after the debit and 15 seconds after the 97. Fourth, the receiving bank, which has not stopped working, credits its customer anyway at 15:31:11, 49 seconds after the switch gave up. The friend has the money and so, now, does the customer. The only status query, at 15:59:52, answers 00.
Everyone behaved according to their own record, and no single party can see all three.
Three parties, three records
| Party | What it knows after the 97 | What it can do |
|---|---|---|
| Sending bank | Customer debited. Response 97. Nothing about the receiver. | Hold the money, ask the switch, reverse the customer |
| Switch | Sent the credit, stopped waiting, will answer a requery with what it learns | Answer a status query; settle the transfer if it ends as 00 |
| Receiving bank | Credited its customer (or did not) | Nothing the sender can see, until the switch tells it |
The sender is the party with the customer, so it gets the complaint, and the person who answers can see only the sender’s own record. The rest of the rail holds the facts, and the sender must go and get them.
Where does the money sit while the sender waits? In a suspense account, an internal account the bank uses for amounts that are no longer the customer’s and not yet anyone else’s. The sending bank’s side covers its books; here you need one rule from it. The debit credits suspense, and suspense is a liability account, so money held in it is a credit balance, and it must be back to zero when the transfer ends, either by paying the switch (the transfer succeeded) or by paying the customer back (it failed). One of the two, never both, never neither. Step 3 of the lab posts both outcomes and shows what the second leg of “both” does to the balance.
Asking: the status query
A status query, or TSQ (transaction status query), asks the switch what became of a transfer you already sent. You identify the transfer by its session ID, the 30-digit reference the lab’s switch gives each transfer, or by your own payment reference, and the switch answers with the status it holds. The chapter Nigeria’s rails introduced it and idempotency and moving money exactly once taught the habit: requery before you resend, never after.
In the lab the answer is one of two codes: 00, it was credited, or 25, the switch has no record of a credit. Across the week the lab holds 136 queries on 90 timeouts, and those 136 answers split into 60 00 and 76 25. The first thing to check about any status query is whether it can change its mind. In this data it never does: not one of the 90 sessions had a 00 after a 25 or the other way round, and step 2 prints that count. So in the lab, one answer is enough and a second query adds nothing. Do not carry that over to real operation. A real status can move from “in progress” to a final one, which is why the practice quoted below tells you to keep asking for a period. The lab hides the window in which asking is too early because its generator fixes the answer first.
The code 97 is the lab’s choice too. Interswitch’s public documentation lists 97 as a decline by the bank for custom reasons, as one search summary reads it. Search results found no NIBSS definition of 97, and other providers use the same number for other things, including a timeout, so its meaning depends on the platformas of 2026-11. Take your own switch’s code list and integration document before you write a rule that depends on a code, and keep the lab’s list as a model.
How long to wait before the first query, and how often to ask, is not a single published number. One Nigerian bank’s developer documentation recommends re-querying a transfer for 15 minutes to confirm a final statusas of 2026-11. A provider’s help article says a transaction should be at least 30 minutes old before you check NIBSS for its status, and describes a regular and an advanced queryas of 2026-11. A digital bank’s business-support article says pending transfers are usually processed within an hour and advises contacting support if nothing changes after 24 hoursas of 2026-11. These come from search summaries, they are one bank’s, one provider’s and one support page and not a CBN or NIBSS rule, and they differ. Your own integration agreement with your switch decides.
What the week shows
Step 2 of the lab counts the timeouts and sorts them. In the lab week the switch answered 97 on 101 of 17,998 transfers, worth ₦1,412,067.00. They end five ways, and the first three are normal.
| Ending | Transfers | Value | What it means |
|---|---|---|---|
| Late success, carried through | 34 | ₦396,046.00 | The status said 00, the sender kept the debit and paid at settlement |
| Never credited, reversed after a requery | 52 | ₦866,850.00 | The status said 25, the sender refunded the customer |
| Never credited, reversed without asking | 7 | ₦76,150.00 | Right outcome, wrong method: no query was ever made |
| Reversed after a late success | 4 | ₦43,647.00 | The customer was refunded and the receiver had been paid |
| Credited by the receiver, never settled | 4 | ₦29,374.00 | The receiver paid and the switch never settled it |
That is 34 + 52 + 7 + 4 + 4 = 101. Read the table by outcome. Thirty-eight transfers (34 + 4) were confirmed credited, ₦439,693.00, and 63 (52 + 7 + 4) were not, ₦972,374.00. In 15 of the 101, the sender reversed its customer before any status query had answered: 11 never asked, and 4 reversed before they asked. Seven of those 15 were lucky, because the transfer had not been credited; the other 8 are the breaks the lab asks you to find.
The last two rows are rare in number and costly in kind. In “reversed after a late success” the sender has refunded its customer and will also pay the switch at settlement, so it is out of pocket by ₦43,647.00 over four transfers, and the customer holds the money twice unless the bank recovers it. In the last row the receiver has credited its customer with no money coming from the switch, ₦29,374.00 over four transfers, so the receiving bank carries the loss. Both banks learn about their side only if they reconcile their own logs against the switch, which is why step 4 of the lab does exactly that.
Two patterns in the data are the generator’s, so read them as things to look for. Timeouts into one receiving bank, B19, run at 3.16% (11 of 348) against 0.51% for the rest (90 of 17,650). And in the 14 minutes of the Thursday switch incident, 20 of the 46 transfers timed out: a bank sees such a burst on its own list long before anyone tells it why.
The reversal that should not happen
Take the diagram’s transfer through the books, as step 3 does. The numbers are kobo, whole integers, because money in code is never a float. The transfer is 1,629,500 kobo.
| Step | Posting | Suspense after |
|---|---|---|
| Debit the customer | Dr customer 1,629,500, Cr suspense 1,629,500 | 1,629,500 owed |
| Reverse the customer | Dr suspense 1,629,500, Cr customer 1,629,500 | 0 |
| The status says 00; the transfer settles | Dr suspense 1,629,500, Cr settlement 1,629,500 | -1,629,500 |
Each line balances, and the whole ledger still balances. The last line is the problem: suspense now has a debit balance of 1,629,500 (shown as -1,629,500, because suspense is a liability and the table counts credits as positive), money that the bank has paid on behalf of a customer who has it back. A trial balance does not catch it, because a negative suspense balance is a valid number. Only a rule that says “suspense for a transfer must clear to zero” does. Step 4 applies that rule to all 17,998 transfers and finds 7 senders with a debit balance: the 4 wrong reversals (B11 -₦16,295, S02 -₦13,822, B22 -₦4,013, B17 -₦9,517) and 3 customers reversed twice, a different mistake that the same rule catches (B10 -₦6,794, B21 -₦41,899, S02 -₦1,810). On the receiving side it finds 4 credits that nobody settled (B19 +₦6,336, B07 +₦18,200 and +₦1,814, B23 +₦3,024). Nothing else in the network is left open.
One warning about the data. The generator plants each wrong reversal 45 seconds after the debit, which is 15 seconds after the switch’s 97, and every one comes before the sender’s first status query. The first, B11’s, was even reversed before the receiver had credited. The answers came 13 to 29 minutes later (788 to 1,755 seconds), so the senders had no way to know. Read the fixed 45 seconds as the planted behaviour: a bank that reversed on a short timer of its own without requerying. Real gaps would vary. The four credits nobody settled are the same habit with no query at all: those senders reversed 40 seconds after the debit.
The correct sequence takes the same two postings in a different order. Ask first. On 00, move the suspense to the settlement account and leave the customer’s debit in place. On 25 (not credited), move it back to the customer. The reversal is a new transaction that points at the original, as module 2 taught, and it must refuse when the original is no longer in the state “debited, unknown”. A guard that checks the state at the time of the reversal turns the four breaks into four refused postings. That is payment states and refunds again: legal moves only, and one state for “do not know”.
What the rules say, and what this build could not read
The CBN’s own instant-payment regulation is the source for the sender’s duties. The CBN’s Regulation on Instant (Inter-Bank) Electronic Funds Transfer Services in Nigeria, effective 2 October 2018 according to search results (one entry gives 20 October), is a PDF on the CBN’s site. Search summaries of it say the sending entity must refund into the customer’s account the full proceeds of a failed transaction returned by the receiving entity within 10 minutes, and a transaction it was unable to process within one hour after the next settlement closure; the receiving entity must apply funds within 60 seconds and, if it cannot, notify the sending entity or the beneficiary, with pending credits applied as soon as the issue is resolved but not exceeding 24 hours. A wrongly credited transfer is to be reversed by the receiving entity within one business day where funds are available, and settlement is as agreed among participants but no later than T+1, the next business day. This build could not open the PDF: every figure rests on search summaries, so read the text before you rely on any of themas of 2026-11.
Read that carefully, because several clocks are in it. The 10 minutes, in the summaries, is tied to the receiving entity’s return of a failed transaction, not to the complaint or the debit; whether it runs from the return or from the sender’s status answer is a question for the text. The 60 seconds and the 24 hours bind the receiver. Another clock is a fine. Search summaries and press reports of the regulation say a failed instant transfer not reversed into the customer’s account within 24 hours of a complaint attracts a fine of ₦10,000 per item; press reports also give that fine for an inward credit delayed beyond four minutes. This build could not read the clause, and whether the 10 minutes and the 24 hours are two clocks or one is not settled by the summaries, so treat each figure as unconfirmedas of 2026-11. Press reports are not the rule. Sources disagree here, and the chapter’s job is to say so.
Do not borrow neighbouring rules. A CBN press release of June 2020 on payment channels, per search results, gives 72 hours for resolving disputed or failed POS and web transactions and, for failed on-us ATM transactions, instant reversal with a manual reversal not exceeding 24 hoursas of 2026-11. A regulatory-alert site’s reproduction of a CBN circular of 31 May 2020 says 48 hours for refunds on failed or disputed POS and web transactions, so the two differ and this build could not settle which governsas of 2026-11. Those are channels (ATM, POS, web), not a bank-to-bank transfer, so do not quote them to a customer whose transfer timed out.
The consumer side adds more clocks. The CBN published an exposure draft of revised Consumer Protection Regulations on its site, which search results date to December 2023 and circulation on 9 February 2024; this build could not read it and did not confirm whether it was adoptedas of 2026-11. The CBN’s 2019 Consumer Protection Regulations, in search results, have a part on complaints handling and redressas of 2026-11. A desk that promises a customer a date must read the current regulations and its own service standard, not a blog. NIBSS’s own pages support one thing the desk relies on: NIBSS’s support FAQ describes NIP (NIBSS Instant Payment) as a deferred net settlement system in which funds are available in the beneficiary’s account in real time, before interbank settlementas of 2026-11. Deferred net means banks settle the difference between what they owe each other at set times, not transfer by transfer. That is why a late success still settles later, and why settlement has to be asked about too. A June 2023 press report, from search results, describes banks, NIBSS and the CBN blaming one another for slow reversals, with NIBSS saying it is not at faultas of 2026-11. That is a reason to keep your own evidence.
How long to wait, how often to ask
The lab cannot tell you the right wait, because its answers never change. It can show what a fixed rule costs. Step 5 replays the 101 timeouts under the rule “if the status is still unknown W minutes after the debit, reverse the customer”, taking each status as known at the time of the query that answered.
| W | Customers reversed, then found credited | Never-credited customers refunded sooner than waiting |
|---|---|---|
| 40 seconds | 38 of 38 | 52 of 52 |
| 5 minutes | 30 of 38 | 46 of 52 |
| 10 minutes | 24 of 38 | 38 of 52 |
| 15 minutes | 19 of 38 | 27 of 52 |
| 30 minutes | 1 of 38 | 2 of 52 |
Read it as a trade. The shorter the wait, the more successes get wrongly refunded. The longer the wait, the longer the customers whose transfer really failed stay without their money: in the lab the median wait for a never-credited customer was 16.5 minutes and the longest was 30.9 minutes. No row is free. Even the 30-minute row refunds one customer wrongly, because the slowest successful answer came at 30.2 minutes, and it helps only 2 of the 52 failed customers. The lab’s answers all arrive within about 31 minutes, a limit of the generator, so it cannot show a wait that never refunds a success. A fixed timer bets that the network behaves as last week did. A requery-driven rule waits for evidence, with a ceiling after which a person decides.
The data also says something about how often the lab’s senders asked. They asked once in 47 sessions, twice in 40 and three times in 3, with 10 to 60 seconds between the first and second ask. Eleven sessions were never asked. A sender that polls every second loads a shared service, and this build found no real rate limit, so check your switch’s agreement. A schedule that backs off, as the lesson on retries, backoff and jitter describes, with a ceiling and a hand-off to a person, is the pattern that survives.
Designing the desk
The suspense account is the desk’s work queue and its control total.
- A state for “debited, unknown”, with a clock. Entered when the response is a timeout or “in progress”, and left only by a definite answer from the switch or by a person. The module 2 guard applies: a reversal checks that the state is still “debited, unknown” in the same database transaction that posts it.
- A requery schedule and a ceiling. Ask soon, back off, stop at a ceiling set from your switch agreement and the regulation’s text. At the ceiling, do not reverse by rule: put the transfer on the morning list for a person.
- A definite
25refunds, a definite00settles. The refund is a new, linked posting, once. The settlement is the switch’s, and suspense moves to the settlement account on its own. - A list that says what is left. Every day, suspense by transfer, nonzero items, oldest first. This is the list Rashidat builds for Odinaka: it is step 4’s open-item query run each morning.
- A reconciliation of both sides. Your log against the switch’s transfer report. A transfer the switch settled that your log shows reversed is yours to fix. A credit the receiver’s log shows with no settlement is a dispute to raise with the switch, and the amount sits on the receiver’s list, not on yours.
Where it goes wrong
Reversing on a timer. The desk’s rule says “after N minutes, refund”. The lab shows customers paid twice at every wait it tests, even 30 minutes. A timer is a guess.
Treating 97 as failure at the screen. The customer is told “failed” and sends again, and the receiver is paid twice. The screen needs the books’ third state: “being checked”.
Asking never, or asking once and forgetting. Eleven of 101 timeouts in the lab were never queried. Seven were reversed within the minute and happened not to have been credited; the other four, ₦29,374.00 in all, had been, and nobody noticed.
Reversing without a state guard. The posting works on any transfer, including one already settled, and a clean trial balance will not object: the four breaks, and a second reversal too, are wrong postings that balance.
Copying the lab’s numbers. The 30-second timeout, the asking times and the codes are the generator’s; your switch’s documents give the values.
What you can prove, and what you cannot
You can prove that every timed-out transfer in your own log ends in exactly one of three states, that suspense for each is zero, that each reversal points at a transfer that was not later settled, and that your list of open items is empty or explained. You cannot prove from your own log that the receiver credited: that takes the switch’s record. Nor can the lab prove the real timelines; they live in the CBN’s text and your agreements. How banks settle with each other takes up what happens when records still disagree after settlement, and settlement and payouts covers settlement timing from a company’s side. For now: ask before you reverse, hold the money in suspense, and clear it to zero.
You work in labs/finance. Every step is Python run from that folder against data/rails.sqlite, which the rails generator writes (the same seed gives the same week). The scripts only read it. Your session ids differ if you change the seed, and nothing here uses the answer key. Amounts in the code are integer kobo; the scripts print naira only when they format a total.
1. Generate the week and check it. Skip the first command if data/rails.sqlite exists.
cd labs/finance
python3 rails.py
python3 check.py --rails-only32 participants, 22,835 accounts, 17,998 transfers, 12,158 name enquiries, 136 status queries
21 settlement sessions, 125 batch files, 193 RTGS payments, 3,412 USSD sessions, 3,453 PSB postings
planted (answers/rails_truth.csv): credited_without_settlement 4, customer_fee_not_charged 6, customer_reversed_twice 3, levy_not_charged 5, mmo_trust_shortfall 1, participant_limit 4, participant_outage 1, psb_cash_out_fee_not_posted 1, psb_cash_out_posted_twice 1, reversed_after_late_success 4, same_number_two_banks 8, switch_incident 1, telco_record_missing 12
rails week: 17,998 transfers, 21 settlement sessions, 22,835 accounts; checks 21-25 run
OK: all invariants holdThe last line is the check, and invariants 21 to 25 hold: every account number passes its check digit, every session nets to zero, exactly the transfers with final status 00 settle, a status changes after the first response only after a timeout with a status query that says so, and S01’s ledger agrees with the switch. The planted line names breaks the chapters find; do not open answers/rails_truth.csv until you have your own list.
2. Count the timeouts and sort them. Every transfer the switch answered 97, by what it finally was and how often its sender asked.
python3 - <<'PY'
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
q = lambda sql, *a: db.execute(sql, a).fetchall()
naira = lambda k: f"₦{k // 100:,}.{k % 100:02d}"
print("1. what the switch first answered")
for code, n in q("SELECT first_response, COUNT(*) FROM transfers GROUP BY 1 ORDER BY 2 DESC"):
print(f" {code} {n:>6}")
print("2. every 97, by final status and number of status queries")
rows = q("""SELECT t.final_status, (SELECT COUNT(*) FROM tsq WHERE tsq.session_id = t.session_id) AS asked,
COUNT(*), SUM(t.amount_kobo)
FROM transfers t WHERE t.first_response = '97' GROUP BY 1, 2 ORDER BY 1, 2""")
for final, asked, n, kobo in rows:
print(f" final {final} asked {asked}x {n:>3} transfers {naira(kobo):>14}")
tot = q("SELECT COUNT(*), SUM(amount_kobo) FROM transfers WHERE first_response = '97'")[0]
print(f" all {tot[0]} timeouts, {naira(tot[1])}")
print("3. the answers the status queries gave")
for resp, n in q("SELECT response, COUNT(*) FROM tsq GROUP BY 1"):
print(f" query answer {resp}: {n} answers")
flip = q("SELECT COUNT(*) FROM (SELECT session_id FROM tsq GROUP BY 1 HAVING COUNT(DISTINCT response) > 1)")[0][0]
print(f" sessions whose answers ever changed between queries: {flip}")
print("4. who sent the timeouts, and who received them")
print(" sender ", ", ".join(f"{s} {n}" for s, n in q("SELECT src, COUNT(*) FROM transfers WHERE first_response='97' GROUP BY 1 ORDER BY 2 DESC, 1 LIMIT 5")))
b19 = q("SELECT SUM(first_response='97'), COUNT(*) FROM transfers WHERE dest = 'B19'")[0]
rest = q("SELECT SUM(first_response='97'), COUNT(*) FROM transfers WHERE dest <> 'B19'")[0]
print(f" into B19: {b19[0]} of {b19[1]:>6} = {100 * b19[0] / b19[1]:.2f}%")
print(f" into others: {rest[0]} of {rest[1]:>6} = {100 * rest[0] / rest[1]:.2f}%")
w = q("""SELECT SUM(first_response='97'), COUNT(*) FROM transfers
WHERE at >= '2026-06-18T15:20:00+01:00' AND at < '2026-06-18T15:34:00+01:00'""")[0]
print(f" Thursday 15:20-15:34 (the switch incident): {w[0]} of {w[1]} transfers timed out")
PY1. what the switch first answered
00 17760
97 101
57 86
07 43
91 4
51 4
2. every 97, by final status and number of status queries
final 00 asked 1x 18 transfers ₦133,405.00
final 00 asked 2x 18 transfers ₦279,350.00
final 00 asked 3x 2 transfers ₦26,938.00
final 97 asked 0x 11 transfers ₦105,524.00
final 97 asked 1x 29 transfers ₦334,888.00
final 97 asked 2x 22 transfers ₦529,537.00
final 97 asked 3x 1 transfers ₦2,425.00
all 101 timeouts, ₦1,412,067.00
3. the answers the status queries gave
query answer 00: 60 answers
query answer 25: 76 answers
sessions whose answers ever changed between queries: 0
4. who sent the timeouts, and who received them
sender B20 12, B12 10, B01 9, B03 7, B17 7
into B19: 11 of 348 = 3.16%
into others: 90 of 17650 = 0.51%
Thursday 15:20-15:34 (the switch incident): 20 of 46 transfers timed outThe other first answers are declines, not timeouts: 57 frozen account, 07 closed or unknown account, 91 bank down, 51 over the participant’s limit. The sender knows what happened to those, and only the 97 leaves it guessing. Of the 101 timeouts, 38 were credited (final 00) and 63 not. The 11 that were never asked are all in the second group. In the lab a status never changes between queries, so a second ask told the sender nothing; a real status can. B19 and the incident window stand out against the base rate of 0.51%. These are the generator’s choices: what carries over is the habit of looking at who and when.
3. Follow one late success, and post it both ways. The first transfer in the week that timed out, was credited and was reversed by its sender. The timeline joins four tables; the books are the sender’s, in kobo.
python3 - <<'PY'
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
sid, src, dest, kobo, final_at = db.execute("""SELECT t.session_id, t.src, t.dest, t.amount_kobo, t.final_at
FROM transfers t JOIN bank_log o ON o.session_id = t.session_id AND o.direction = 'out'
WHERE t.first_response = '97' AND t.final_status = '00' AND o.status = 'reversed' ORDER BY t.at LIMIT 1""").fetchone()
print(f"session ...{sid[-8:]}: {src} sent {kobo} kobo to {dest}; the switch timed out, then said 00 at {final_at[11:19]}")
events = [(db.execute("SELECT at FROM transfers WHERE session_id = ?", (sid,)).fetchone()[0], f"{src} debits its customer and sends")]
lat, sess = db.execute("SELECT latency_ms, settlement_session FROM transfers WHERE session_id = ?", (sid,)).fetchone()
for at, who, d, st, rev in db.execute("SELECT posted_at, institution, direction, status, reversed_at FROM bank_log WHERE session_id = ?", (sid,)):
if d == "in":
events.append((at, f"{who} credits its customer"))
elif rev:
events.append((rev, f"{who} reverses its customer"))
for at, resp in db.execute("SELECT at, response FROM tsq WHERE session_id = ?", (sid,)):
events.append((at, f"requery answers {resp}"))
import datetime as dt
t0 = dt.datetime.fromisoformat(events[0][0])
events.append(((t0 + dt.timedelta(milliseconds=lat)).isoformat(), f"the switch gives up waiting ({lat} ms) and answers 97"))
events.append((final_at, f"the switch's final status is 00; it settles in session {sess}"))
for at, what in sorted(events):
print(f" {at[11:19]} {what}")
class Book:
"""The sending bank's books for one transfer, in integer kobo. Debits positive, credits negative."""
def __init__(self):
self.bal, self.lines = {}, []
def post(self, what, debit, credit, k):
self.bal[debit] = self.bal.get(debit, 0) + k
self.bal[credit] = self.bal.get(credit, 0) - k
self.lines.append((what, debit, credit, k))
assert sum(self.bal.values()) == 0 # every posting balances
def show(self, title):
print(title)
for what, d, c, k in self.lines:
print(f" {what:<34} Dr {d:<16} Cr {c:<16} {k:>8}")
print(f" suspense at the end: {-self.bal.get('suspense', 0)} kobo (credits minus debits; should be 0, and below 0 is a debit balance)")
right = Book()
right.post("1. debit the customer", "customer", "suspense", kobo)
right.post("2. requery says 00: owe the switch", "suspense", "settlement", kobo)
right.show("A. the sender waits for the requery")
wrong = Book()
wrong.post("1. debit the customer", "customer", "suspense", kobo)
wrong.post("2. desk reverses the customer", "suspense", "customer", kobo)
wrong.post("3. requery says 00: owe the switch", "suspense", "settlement", kobo)
wrong.show("B. the sender reverses first (what the lab's week did)")
print(f"customer net {-wrong.bal['customer']} kobo (was debited and refunded); settlement owed to the switch {-wrong.bal['settlement']} kobo")
PYsession ...06270881: B11 sent 1629500 kobo to B05; the switch timed out, then said 00 at 15:59:52
15:29:52 B11 debits its customer and sends
15:30:22 the switch gives up waiting (30000 ms) and answers 97
15:30:37 B11 reverses its customer
15:31:11 B05 credits its customer
15:59:52 requery answers 00
15:59:52 the switch's final status is 00; it settles in session 20260617-4
A. the sender waits for the requery
1. debit the customer Dr customer Cr suspense 1629500
2. requery says 00: owe the switch Dr suspense Cr settlement 1629500
suspense at the end: 0 kobo (credits minus debits; should be 0, and below 0 is a debit balance)
B. the sender reverses first (what the lab's week did)
1. debit the customer Dr customer Cr suspense 1629500
2. desk reverses the customer Dr suspense Cr customer 1629500
3. requery says 00: owe the switch Dr suspense Cr settlement 1629500
suspense at the end: -1629500 kobo (credits minus debits; should be 0, and below 0 is a debit balance)
customer net 0 kobo (was debited and refunded); settlement owed to the switch 1629500 koboThe sender reversed at 15:30:37, 45 seconds after the debit, before the receiver had credited (15:31:11) and 29 minutes before the only status query answered. The status then said 00. In book A suspense clears to zero. In book B it ends at -1,629,500 kobo, a debit balance of 1,629,500: the customer is whole, the bank owes the switch, and every posting balanced. The assert never fired, which is the point: balance is not the control.
4. Give every timeout a verdict, and clear suspense over the whole week. Write verdict: what the sender’s log, the receiver’s log and the switch’s settlement say for each of the 101. Then apply the open-item rule to all 17,998 transfers.
python3 - <<'PY'
import datetime as dt
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
q = lambda sql, *a: db.execute(sql, a).fetchall()
naira = lambda k: f"₦{k // 100:,}.{k % 100:02d}"
when = dt.datetime.fromisoformat
def verdict(final, sender_status, credited, settled, asked):
"""What each side holds for one timed-out transfer, and whether the sides agree."""
if final == "00":
if sender_status == "completed" and credited and settled:
return "ok: late success, carried through"
if sender_status == "reversed":
return "BREAK: sender reversed the customer after a late success"
else:
if sender_status == "reversed" and not credited:
return "ok: reversed after a requery" if asked else "ok by luck: reversed without asking"
if credited and not settled:
return "BREAK: receiver credited, nothing settled"
return "UNEXPECTED"
rows = q("""SELECT t.session_id, t.src, t.dest, t.amount_kobo, t.at, t.final_status, t.final_at,
t.settlement_session <> '' AS settled,
o.status, o.reversed_at,
EXISTS (SELECT 1 FROM bank_log i WHERE i.session_id = t.session_id AND i.direction = 'in') AS credited,
(SELECT COUNT(*) FROM tsq WHERE tsq.session_id = t.session_id) AS asked,
(SELECT MIN(at) FROM tsq WHERE tsq.session_id = t.session_id) AS first_ask
FROM transfers t JOIN bank_log o ON o.session_id = t.session_id AND o.direction = 'out'
WHERE t.first_response = '97' ORDER BY t.at""")
counts, money, breaks, early = {}, {}, [], 0
for sid, src, dest, kobo, at, final, final_at, settled, status, rev_at, credited, asked, first_ask in rows:
early += status == "reversed" and (first_ask is None or rev_at < first_ask)
v = verdict(final, status, bool(credited), bool(settled), asked)
counts[v] = counts.get(v, 0) + 1
money[v] = money.get(v, 0) + kobo
if v.startswith("BREAK"):
breaks.append((sid, src, dest, kobo, at, final_at, rev_at, v))
print(f"1. the verdict on each of the {len(rows)} timeouts")
for v in sorted(counts):
print(f" {counts[v]:>3} {naira(money[v]):>13} {v}")
print(f" reversals made before the first status query was answered, or without one: {early} of {len(rows)}")
print("2. the breaks")
for sid, src, dest, kobo, at, final_at, rev_at, v in breaks:
if "reversed the customer" in v:
gap = (when(final_at) - when(rev_at)).total_seconds()
print(f" {sid[-8:]} {src}->{dest} {naira(kobo):>11} debited {at[11:19]}, customer reversed {rev_at[11:19]}, "
f"switch said 00 at {final_at[11:19]} ({gap:.0f} s later)")
else:
print(f" {sid[-8:]} {src}->{dest} {naira(kobo):>11} debited {at[11:19]}, customer reversed {rev_at[11:19]}, "
f"the receiver's log has a credit, the switch never settled it")
print("3. open items over all transfers: what is left in suspense at the end of the week")
sender_open = q("""SELECT t.session_id, t.src,
t.amount_kobo * (1 - (SELECT COUNT(*) FROM bank_log o
WHERE o.session_id = t.session_id AND o.direction = 'out' AND o.status = 'reversed')
- (t.settlement_session <> '')) AS open_kobo
FROM transfers t""")
receiver_open = q("""SELECT t.session_id, t.dest, t.amount_kobo - (t.settlement_session <> '') * t.amount_kobo AS open_kobo
FROM transfers t JOIN bank_log i ON i.session_id = t.session_id AND i.direction = 'in'""")
for label, rows_ in (("sender side ", sender_open), ("receiver side", receiver_open)):
bad = [r for r in rows_ if r[2] != 0]
print(f" {label}: {len(rows_):>6} transfers checked, {len(bad)} not cleared: " +
", ".join(f"{r[1]} {r[2] // 100:+,}" for r in bad))
PY1. the verdict on each of the 101 timeouts
4 ₦29,374.00 BREAK: receiver credited, nothing settled
4 ₦43,647.00 BREAK: sender reversed the customer after a late success
7 ₦76,150.00 ok by luck: reversed without asking
34 ₦396,046.00 ok: late success, carried through
52 ₦866,850.00 ok: reversed after a requery
reversals made before the first status query was answered, or without one: 15 of 101
2. the breaks
18609909 B01->B19 ₦6,336.00 debited 07:46:48, customer reversed 07:47:28, the receiver's log has a credit, the switch never settled it
06270881 B11->B05 ₦16,295.00 debited 15:29:52, customer reversed 15:30:37, switch said 00 at 15:59:52 (1755 s later)
64397192 S02->B10 ₦13,822.00 debited 06:10:04, customer reversed 06:10:49, switch said 00 at 06:31:39 (1250 s later)
70689905 B01->B07 ₦18,200.00 debited 15:32:49, customer reversed 15:33:29, the receiver's log has a credit, the switch never settled it
90654102 B22->B05 ₦4,013.00 debited 11:38:23, customer reversed 11:39:08, switch said 00 at 12:03:23 (1455 s later)
04570876 B03->B07 ₦1,814.00 debited 12:15:40, customer reversed 12:16:20, the receiver's log has a credit, the switch never settled it
78727283 B17->B13 ₦9,517.00 debited 12:42:19, customer reversed 12:43:04, switch said 00 at 12:56:12 (788 s later)
67601939 B12->B23 ₦3,024.00 debited 19:02:15, customer reversed 19:02:55, the receiver's log has a credit, the switch never settled it
3. open items over all transfers: what is left in suspense at the end of the week
sender side : 17998 transfers checked, 7 not cleared: B10 -6,794, B11 -16,295, S02 -13,822, B21 -41,899, B22 -4,013, B17 -9,517, S02 -1,810
receiver side: 17802 transfers checked, 4 not cleared: B19 +6,336, B07 +18,200, B07 +1,814, B23 +3,024Eight breaks and 93 transfers that ended cleanly, 7 of them by luck: they were reversed within the minute with no query, and happened not to have been credited. The sender side clears for 17,991 of 17,998 transfers and shows seven debit balances: the four the verdict found, and three more that are not timeouts at all, customers reversed twice (B10, B21 and the second S02 line). The receiver side finds four credits, ₦6,336, ₦18,200, ₦1,814 and ₦3,024, with no settlement behind them. Reversals before the first answer total 15 of 101. The fixed 45 seconds is how the generator plants the break: a reversal before requerying. Your totals are the same because the week is fixed.
5. Measure the asking, and price a timer. When did the senders ask, how long were customers out of their money, and what does “reverse after W minutes” cost?
python3 - <<'PY'
import datetime as dt
import sqlite3
import statistics
db = sqlite3.connect("data/rails.sqlite")
q = lambda sql, *a: db.execute(sql, a).fetchall()
when = dt.datetime.fromisoformat
mins = lambda a, b: (when(b) - when(a)).total_seconds() / 60
timeouts = q("SELECT session_id, at, final_status, final_at FROM transfers WHERE first_response = '97'")
first_ask, gaps, per_session, never = [], [], [], 0
for sid, at, final, final_at in timeouts:
asks = [r[0] for r in q("SELECT at FROM tsq WHERE session_id = ? ORDER BY at", sid)]
per_session.append(len(asks))
if not asks:
never += 1
continue
first_ask.append(mins(at, asks[0]))
gaps += [(when(b) - when(a)).total_seconds() for a, b in zip(asks, asks[1:])]
print("1. when did the sender first ask?")
print(f" {len(first_ask)} of {len(timeouts)} asked at least once; {never} never asked")
qs = statistics.quantiles(first_ask, n=4)
print(f" minutes after the debit: min {min(first_ask):.0f}, quartiles {qs[0]:.1f} / {qs[1]:.1f} / {qs[2]:.1f}, max {max(first_ask):.0f}")
print(f" asked once: {per_session.count(1)}, twice: {per_session.count(2)}, three times or more: {sum(1 for n in per_session if n > 2)}")
print(f" gap between the first and second ask: min {min(gaps):.0f} s, max {max(gaps):.0f} s ({len(gaps)} gaps)")
print("2. how long the customer's money was in limbo (debit to the final status)")
for final, label in (("00", "late success"), ("97", "never credited")):
w = [mins(a, f) for a, f in q("""SELECT at, final_at FROM transfers t WHERE first_response = '97' AND final_status = ?
AND EXISTS (SELECT 1 FROM tsq WHERE tsq.session_id = t.session_id)""", final)]
print(f" {label:<15} {len(w):>2} transfers: median {statistics.median(w):.1f} min, longest {max(w):.1f} min")
print("3. a desk rule of 'reverse the customer after W minutes if the status is still unknown'")
print(" W customers reversed that the switch then credited never-credited customers refunded sooner")
succ = [mins(a, f) for a, f in q("SELECT at, final_at FROM transfers WHERE first_response='97' AND final_status='00'")]
fail = [mins(a, f) for a, f in q("""SELECT at, final_at FROM transfers t WHERE first_response = '97' AND final_status = '97'
AND EXISTS (SELECT 1 FROM tsq WHERE tsq.session_id = t.session_id)""")]
for w in (2 / 3, 5, 10, 15, 30):
wrong = sum(1 for x in succ if x > w)
sooner = sum(1 for x in fail if x > w)
name = "40 s" if w < 1 else f"{w:.0f} min"
print(f" {name:<9} {wrong:>3} of {len(succ)} {sooner:>3} of {len(fail)}")
PY1. when did the sender first ask?
90 of 101 asked at least once; 11 never asked
minutes after the debit: min 1, quartiles 7.8 / 16.0 / 25.0, max 30
asked once: 47, twice: 40, three times or more: 3
gap between the first and second ask: min 10 s, max 60 s (46 gaps)
2. how long the customer's money was in limbo (debit to the final status)
late success 38 transfers: median 15.1 min, longest 30.2 min
never credited 52 transfers: median 16.5 min, longest 30.9 min
3. a desk rule of 'reverse the customer after W minutes if the status is still unknown'
W customers reversed that the switch then credited never-credited customers refunded sooner
40 s 38 of 38 52 of 52
5 min 30 of 38 46 of 52
10 min 24 of 38 38 of 52
15 min 19 of 38 27 of 52
30 min 1 of 38 2 of 52The first ask came a median 16.0 minutes after the debit; 40 sessions asked twice and 3 asked three times. A customer whose transfer was never credited waited a median 16.5 minutes. A rule that reverses at 40 seconds refunds all 38 customers whose money had arrived, and a rule at 15 minutes still refunds 19 of them. Even the 30-minute row refunds one, because the slowest success answered at 30.2 minutes: the lab’s answers all end at about 31 minutes, which tells you about the data, not about a safe wait. The lab’s answers never change, so it cannot show a query made too early; the real practice quoted earlier ranges from 15 to 30 minutes.
6. Make Northmere’s morning list. Northmere is B05 in the lab. Its timed-out transfers, how often it asked, and how long each customer waited. Change BANK to another sender to see theirs.
python3 - <<'PY'
import datetime as dt
import sqlite3
BANK = "B05" # Northmere Bank in the lab: try another sender
db = sqlite3.connect("data/rails.sqlite")
when = dt.datetime.fromisoformat
naira = lambda k: f"₦{k // 100:,}.{k % 100:02d}"
rows = db.execute("""SELECT t.at, t.dest, t.amount_kobo, t.channel, t.final_status, o.status, o.reversed_at,
(SELECT COUNT(*) FROM tsq WHERE tsq.session_id = t.session_id),
EXISTS (SELECT 1 FROM bank_log i WHERE i.session_id = t.session_id AND i.direction = 'in')
FROM transfers t JOIN bank_log o ON o.session_id = t.session_id AND o.direction = 'out'
WHERE t.first_response = '97' AND t.src = ? ORDER BY t.at""", (BANK,)).fetchall()
print(f"{BANK}'s timed-out transfers in the week: {len(rows)}")
print(" debited to amount channel asked customer back after receiver credited final")
for at, dest, kobo, ch, final, status, rev, asked, credited in rows:
back = f"{(when(rev) - when(at)).total_seconds() / 60:.1f} min" if rev else "not reversed"
print(f" {at[:16].replace('T', ' ')} {dest} {naira(kobo):>11} {ch:<7} {asked:>3}x {back:>19} {'yes' if credited else 'no':>14} {final}")
reversed_ = [r for r in rows if r[6]]
no_ask = [r for r in reversed_ if r[7] == 0]
print(f"reversed: {len(reversed_)} of {len(rows)}; reversed within a minute without asking: {len(no_ask)}")
print(f"money held in limbo: {naira(sum(r[2] for r in rows))} over {len(rows)} customers")
PYB05's timed-out transfers in the week: 5
debited to amount channel asked customer back after receiver credited final
2026-06-17 16:13 B13 ₦47,870.00 app 2x not reversed yes 00
2026-06-18 09:36 B17 ₦2,404.00 branch 2x 28.9 min no 97
2026-06-18 12:35 B12 ₦7,658.00 app 0x 0.7 min no 97
2026-06-18 15:25 B01 ₦44,224.00 app 1x 27.0 min no 97
2026-06-18 15:30 B17 ₦13,324.00 app 2x not reversed yes 00
reversed: 3 of 5; reversed within a minute without asking: 1
money held in limbo: ₦115,480.00 over 5 customersB05 had 5 timeouts, ₦115,480.00 over 5 customers. Two (₦47,870.00 and ₦13,324.00) were credited and settled, and B05 rightly kept the debit. Three were reversed and none of those was credited. The ₦7,658.00 app transfer was reversed within a minute with no query: right here, by luck. Two customers waited longest, 28.9 minutes (queried twice) and 27.0 (once). B05 has no break this week. Odinaka’s list is this table, with any reversed row that has no query marked for a second look.
Assume every sender reverses its customer the moment it sees 97, as the desk in the Why did at its own timer. Run this and compare it with the 4 real wrong reversals of step 4:
python3 - <<'PY'
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
# The break: every sender reverses its customer the moment it sees 97, as the desk in the Why did.
n, kobo = db.execute("""SELECT COUNT(*), SUM(amount_kobo) FROM transfers
WHERE first_response = '97' AND final_status = '00'""").fetchone()
total = db.execute("SELECT COUNT(*) FROM transfers WHERE first_response = '97'").fetchone()[0]
print(f"customers refunded although the receiver was credited: {n} of {total}, {kobo} kobo (₦{kobo // 100:,}.{kobo % 100:02d})")
print("the week's real count of that mistake, from step 4: 4")
PYExpected output:
customers refunded although the receiver was credited: 38 of 101, 43969300 kobo (₦439,693.00)
the week's real count of that mistake, from step 4: 4Thirty-eight customers refunded although the receiver had been credited, ₦439,693.00, against 4 and ₦43,647.00 in the week itself. The extra 34 are the late successes that the week’s senders, by waiting for the answer, carried through correctly.
Template
# Reversals desk runbook: <bank, channel>
Owner: <reversals desk lead> · Approved by: <head of payments operations> · Version <n> · Review by <date>
Decision needed: <what the approver is asked to sign off, and from when>
## Scope
<Which transfers: outward, debited, no clear ending. What this runbook does not cover.>
## The morning list
- Built by <role> at <time> from <source>: suspense by transfer, nonzero items, oldest first
- Columns: <debited at, receiver, amount, channel, queries asked, customer back after, status>
- Marked for a second look: <any reversed row with no query>
## Status-query answers
| Answer | What it means | Action | Posting | Owner |
|---|---|---|---|---|
| 00 | | | | |
| 25 | | | | |
| No answer or in progress | | | | |
## The timer rule
<Is there one? If yes: the wait W, the ceiling, and what happens at the ceiling. Cost: <customers wrongly refunded at W>.>
## Never
- <Reverse before a status query proves failure, and the guard that stops it>
- <Other things the desk does not do>
## What the customer is told
| State | Message | Who may send it |
|---|---|---|
| Being checked | | |
| Refunded | | |
| Paid, debit stands | | |
Refund clock quoted: <what it runs from, source, date read, and "unconfirmed" if the text was not read>
## Escalation to the other bank
<When, to whom, with which evidence (session ID, amount, times, our log, the switch answer), and how we track the reply.>
## Where this could be wrong
<One way, and the figure or report that would show it.> WORKED EXAMPLE
Odinaka writes this for Northmere’s app transfers, and the head of payments operations approves it.
The morning list. Rashidat builds it by 07:30 (our assumption) from suspense by transfer, nonzero items, oldest first: the step 4 open-item rule. For B05 the lab week gives 5 timeouts, ₦115,480.00 over 5 customers. Two were credited and settled (₦47,870.00 and ₦13,324.00), so the debit stands. One reversed row, ₦7,658.00, had no query and is marked for a second look.
Answers. 00: keep the debit, suspense moves to settlement, the desk officer does nothing else. 25: the desk officer refunds the customer once, as a new posting linked to the original. No answer: ask again on a backing-off schedule. At a ceiling of 45 minutes (our assumption, above the lab’s slowest answer of 30.9 minutes, to be replaced by the switch agreement) the item goes to a person, never to a rule.
Timer. There is none. A 5-minute timer would have refunded 30 of 38 customers whose transfers were credited; at 15 minutes, 19 of 38.
Never. Reverse before a status query proves failure: 15 of 101 timeouts were, and 4 customers, ₦43,647.00, were paid twice. The reversal checks the state is still debited, unknown.
Messages. “Being checked”, never “failed”. Refund clock. Search summaries of the CBN’s 2018 instant-payment regulation, which this build could not open, say a sender refunds a failed transaction returned by the receiver within 10 minutes, and report a ₦10,000 fine if a failed transfer is not reversed within 24 hours of a complaint. Whether these are two clocks or one is not settled, so we quote neither until the text is read.
Escalation. An item unanswered at the ceiling goes to the switch with the session ID, amount, times, our log and the last answer. A transfer settled after we reversed is ours to fix. A credit with no settlement, like the lab’s four (₦29,374.00), is the receiver’s dispute with the switch.
Where this could be wrong. The ceiling may be too short for a slow receiver; items reaching it that later answer 00 would show it.
Now you
You lead the reversals desk at a bank the lab calls B20, which has no cast name. In the lab week it sent more timeouts than any other bank: 12, the top line of step 2. Run step 6 with BANK = "B20" to see them, how often it asked and how long each customer waited. Until now the desk has refunded customers by a timer. The head of payments operations, who will approve the runbook, wants one document to replace the timer from Monday. You do not know B20’s switch ceiling, so state your own and mark it as an assumption, and say who builds the morning list and when. Write the runbook, including what the desk tells a customer at the screen and when it escalates to the receiving bank. Your approver reads it to decide whether to switch the timer off on that date.
Self-check
Odinaka has to set the rule for Northmere's app. A customer sends ₦16,295, is debited, and the switch answers with a timeout after 30 seconds. The customer is on the phone to the branch, which can see only Northmere's record. Rashidat has pulled last week's list: 38 of 101 timeouts turned out to be credited. Which rule should the desk adopt for the debit?
- DOC Regulation on Instant (Inter-Bank) Electronic Funds Transfer Services in Nigeria (CBN, 2018) Central Bank of Nigeria, 2018
The CBN's own text. Read the sending entity's duties on refunding failed transactions, the receiving entity's on applying funds and notifying, and the clause on erroneous transfers and reversals. This chapter's figures rest on search summaries of it, so check each against the text. Skip the licensing sections.
- DOC Guidelines on Instant (Inter-Bank) Electronic Funds Transfer: exposure draft (CBN, 2017) Central Bank of Nigeria, 2017
The draft that came before the 2018 regulation. Read it beside the final text to see which clocks moved. It is a draft, not a rule.
- DOC Press release on payment channels (CBN, 2020) Central Bank of Nigeria, 2020
The June 2020 announcement of reversal and dispute timelines for ATM, POS and web transactions. Short. Read it to learn which transactions the clocks apply to, so you do not quote them for a bank transfer.
- DOC CBN circular on refund timelines for ATM, POS and web transactions, 31 May 2020 (reproduced by a regulatory-alert site) Central Bank of Nigeria, 2020
The circular behind the press release, as reproduced by a third-party site, not the CBN's own page. Read the sections on failed transactions and refunds; it gives 48 hours for POS and web where the press release gives 72, so check the CBN's own text.
- DOC Exposure draft: revised Consumer Protection Regulations (CBN, 2024 path) Central Bank of Nigeria, 2024
The CBN's draft on complaints handling. Read the complaint and escalation sections and then check whether the revised text was adopted. A draft is not a rule.
- DOC How does Settlement happen on the service? (NIBSS support article) NIBSS, 2026
NIBSS's own wording on deferred net settlement and funds available before settlement. Read it for the real-time credit that makes a late success possible. A support page, not a rule; check which service it covers.
- DOC Get NIP Transaction Status (Providus Bank developer documentation) Providus Bank, 2026
One bank's API for the status query, with its advice on re-querying. Read it to see a real request and response and compare its waiting advice with a second source. A bank's own guidance, not a CBN or NIBSS rule.
- POST Failed transactions: banks, others trade blame as customers' agony persists (press) News Express, 2023
A press report on who is blamed for slow reversals. Read it as the customer's side of this chapter and as press, not as a source for any rule. Skip the figures.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.