USSD: the telco, the bank and who pays for the session
A USSD session is billed for the time it was open, whether or not the transfer happens. In the lab's week a fifth of sessions fail and still cost a quarter of the bill, so the price of a completed transfer is the whole bill divided by the sessions that finished
In the lab's week, 3,412 USSD sessions were opened across 32 institutions. The lab charges ₦7.00 for every started 20 seconds of a session, completed or not. About what share of the sessions did not complete, and about what share of the week's session charges did those failed sessions account for?
USSD and mobile money, seen from the network shows where the session runs: the phone, the signalling path, the gateway that holds the dialogue and the timers that end it. Here you stay with the money. Nigeria’s rails already said that USSD is a channel and not a rail, and that a session can end while the debit behind it has happened. This chapter adds a third fact. The session is also an item on a bill, with its own counts, its own payer and its own dispute. The lab is rails.py, one invented week on an instant-payment network. Telco T1 is Lumora Mobile and B05 is Northmere. Every charge, timer and share in the lab is illustrative, and none of it is a real operator’s or the regulators’. Real rules appear in dated notes with their sources.
One session, one record, one line on a bill
The ussd_sessions table has one row for every session the telcos carried. Read its columns as the telco’s billing record.
| Column | What it says |
|---|---|
started_at, duration_s |
When the dialogue opened and how many seconds it lasted |
telco |
The network that carried it: T1 (Lumora Mobile), T2, T3 or T4 |
institution |
The bank, PSB, MFB, MMO or wallet company whose menu the customer was in |
msisdn_hash |
The caller’s number, hashed, so you can follow one phone without holding the number |
steps |
How many screens the customer saw: 4 to 6 in the lab |
outcome |
completed, timeout, user_cancel or network_drop |
session_id |
The 30-digit switch session of the transfer, set only when the outcome is completed |
charge_kobo, billed_to |
The lab’s charge for the session, and who pays it: customer or bank |
Two columns decide most of the chapter. session_id is blank for every failed session, so a failed session never meets a transfer: it is a cost with no transaction to explain it. And charge_kobo does not depend on outcome. The lab charges ₦7.00 (700 kobo) for each started 20 seconds, so a session of 70 seconds is 4 units, ₦28.00, and a session of 90 seconds is 5 units, ₦35.00. A cancel after 35 seconds is 2 units, ₦14.00. The unit and the price are the lab’s. A real operator’s unit, rounding and price are set by the rules in the next section, and the lab’s are far from them.
The dark part of each bar is the time the session was open. The light part is the rest of the last unit, which is charged anyway. The same arithmetic runs in the real world with different numbers, and it is why the session, and not the transfer, is the unit you reconcile on.
Who may bill whom
Three layers of rules touch a USSD transfer, and they come from two regulators. Keep them apart.
The central bank’s rules are about risk. The CBN’s USSD Regulatory Framework, circulated in April 2018, is summarised in search results as requiring a PIN as the first factor on every USSD transaction, a second factor on transactions above ₦20,000, and a daily limit of ₦100,000 per customer that a customer can raise by signing an indemnity with the bank or mobile money operator. Reports give 1 June 2018 as the start and say the CBN extended it to 1 October 2018, and a press report quotes a CBN official as later saying the ₦100,000 limit still stood. This build did not open the PDF, so check the text, the dates and any later change before you rely on a figureas of 2026-11. Nothing in those controls says who pays the telco.
The telecoms regulator’s rules are about price and the payer. The Nigerian Communications Commission (NCC) sets how a USSD session may be priced and who may bill for it. The NCC’s Determination of USSD Pricing and Services is dated 13 March 2025 and, as summarised in search results, replaces the 2019 pricing determination. Search results show two start dates: a summary of the document gives 14 March 2025, and a press report (Technology Times) quoting a version of it gives 3 June 2025. The results did not settle which is right, and this build could not open the PDF, so check itas of 2026-11. Press reports say the determination was developed with the CBN. The older arrangement is the one a bank’s finance team remembers: a bank pays the operator for the sessions its customers open, under a commercial agreement, and recovers the cost as it can. Call that corporate billing, as the dispute coverage does. An NCC press statement of August 2020, as summarised in search results, says the NCC revised the 2019 determination by removing its price floor and cap so that operators and banks negotiate the rate, told operators not to charge consumers directly for USSD financial services but to return to corporate billing, and put the banks’ debt to operators at over ₦17 billion. This build did not open the statementas of 2026-11.
End-user billing (EUB) is the other design. The operator bills the customer’s airtime for the session, and the bank does not charge for the session. The NCC’s question-and-answer page on end-user billing for USSD banking is described in search results as saying that only mobile network operators may bill for the session, that the customer opts in or out and must be notified at the end of the activity of what was charged, and that the customer is not charged twice. The snippets did not show the price. Press reports (Leadership, TheCable and others) give ₦6.98 for a session of up to 120 seconds, taken from the customer’s airtime, and say banks stopped debiting accounts from 3 June 2025 and operators began billing airtime on 18 June 2025. Reports disagree on failed sessions: an operators’ spokesperson is quoted as saying a session that fails on the operator’s network is not billed but one that fails at the bank after the operator processed it is, while a press report in August 2025 describes a customer charged ₦6.98 for each of two failed sessions. The association of operators was reported in February 2026 as saying the market had fully migrated to end-user billing. Treat the price, the dates and the treatment of failures as press-reported, and check the NCC’s current textas of 2026-11.
The lab models both policies. A participant whose ussd_billing is bank is on corporate billing. A participant whose ussd_billing is customer is on end-user billing. The lab assigns them at random, and it does not know which real bank does which. It also bills every failed session, which is a modelling choice and not a finding about the real rule. Press reports of the December 2024 circular, in the dispute section below, tied the move to end-user billing to banks meeting the payment terms.
A failed session still costs
Start with the arithmetic Obafemi and Nwanneka need. Group the 3,412 sessions by outcome.
| Outcome | Sessions | Share | Average seconds | Charged |
|---|---|---|---|---|
| completed | 2,743 | 80.4% | 47.4 | ₦54,460.00 |
| timeout | 347 | 10.2% | 90.0 | ₦12,145.00 |
| user_cancel | 197 | 5.8% | 47.5 | ₦3,941.00 |
| network_drop | 125 | 3.7% | 50.6 | ₦2,632.00 |
The three failure outcomes add to 669 sessions and ₦18,718.00 of the week’s ₦73,178.00. Do the sums by hand. 347 + 197 + 125 = 669, and 669 ÷ 3,412 = 19.6%. ₦12,145.00 + ₦3,941.00 + ₦2,632.00 = ₦18,718.00, and 18,718 ÷ 73,178 = 25.6%. The failures cost about a third more than their share of sessions because a timeout is the longest session there is: 90 seconds, five started units, against 47 seconds on average for a completed one.
Now the number the room could not name. The cost per completed transfer is every session charge, including the failed ones, divided by the completed sessions: ₦73,178.00 ÷ 2,743 = ₦26.68. Dividing by all 3,412 sessions gives ₦21.45, a number that makes the channel look cheaper than it is. Every failed session is a cost that a completed one has to carry, so a rise in the failure rate raises the price of a transfer even when the price per second does not move.
By billing policy the figure is almost the same: ₦25.77 for the 877 completed sessions billed to banks and ₦27.11 for the 1,866 billed to customers. The policy decides who carries the cost. It does not shrink it. Under corporate billing the bank sees the failures on its invoice. Under the lab’s end-user policy the customer pays for them from airtime, and the bank may never see them at all. Whether real end-user billing charges failed sessions is reported both ways, as the notes above say.
Notice what the failure rate does not depend on, in this lab. A longer menu should fail more often, since each screen is another chance to stall, and the network chapter shows the arithmetic. The lab’s failure rate by number of steps is 19.3% at 4 steps, 19.6% at 5 and 19.9% at 6: no trend worth the name. The generator draws a failure for about a quarter of first attempts whatever the menu. Do not conclude that menu length does not matter. The lab was not built to show it, and your own logs will.
What the customer fee has to cover
The sender’s bank also charges the customer a fee for the transfer. In the lab it is ₦10, ₦25 or ₦50 depending on the amount, and the switch takes a fee of its own. All three are the lab’s numbers. Put the bank-billed sessions against that fee: the 877 completed sessions of bank-billed institutions earned ₦18,290.00 in customer fees, and all 1,065 of their sessions, failed ones included, cost those banks ₦22,596.00. The difference is -₦4,306.00. For B05 it is 145 completed sessions and 181 sessions in all, ₦3,090.00 of fees and ₦3,969.00 of charges: -₦879.00.
That result is a property of the lab’s invented fee and price, so it does not mean a real bank loses money on USSD. It shows the question to ask of a real one: for each channel, what does the bank earn on a completed transfer, and what does the channel cost it, failed sessions included? What a transfer earns and costs a bank takes the full version. Here the fact to keep is that a channel’s cost belongs to whoever is billed, and that the billed party has to know the failure rate to price the channel.
Where it goes wrong
The two lists are never the same list. The telco’s session list and the bank’s transfer log count different events, and the key between them, session_id, exists only on completed sessions. In this lab every USSD transfer should have exactly one completed session, so a join on it should match all 2,755 USSD-channel transfers in the switch’s data. It matches 2,743. Twelve transfers (0.4%), worth ₦129,776.00, have no completed session in the telco’s log, and all twelve settled. They are completed sessions the telco lost: the lab plants them. Three of the twelve sit after a failed session from the same phone, so a reader of the failed-session list alone would see a customer who gave up and never learn that money moved. The lesson is the reconciliation. A telco that bills only the sessions it holds cannot bill, or explain, a session it lost, and a bank that checks only its own transfers will not notice. Both lists have to be matched in both directions. A real log would need a gateway or billing-extract record to say why a session went missing, and the lab does not model one. Step 5 finds the twelve and step 6 scores the finding.
The customer tries again and pays twice. In 666 cases a failed session is followed within ten minutes, from the same phone, by a completed one. Those 666 failed attempts were charged ₦18,627.00. Under end-user billing the customer pays for that retry. Before the retry, check whether the first attempt moved money, as payment states and refunds set out for any pending answer. In this lab it did not: each failed session pairs with the single transfer that the retry produced. A real gateway can fail after the debit, which is why the check matters. The timer lesson, timeouts, covers why the second attempt is a gamble.
A rate card applied to the wrong unit. The lab bills per started 20 seconds. The end-user rate in the press is for each 120 seconds. Applied to the same sessions the two give very different totals, ₦73,178.00 and ₦23,815.76 in step 4, and a bank that budgets on one unit and is invoiced on the other finds out at the end of the month.
The dispute between banks and telcos
The money side of USSD in Nigeria has been a public dispute for years. This part rests on press reports, and each one is labelled. The facts that follow are events as reported, not rules.
Press reports (TechCabal and others) say that in December 2024 the CBN and the NCC issued a joint circular, dated 20 December in most reports and 23 December in one, on what banks owed operators for USSD sessions. The debt is put at about ₦250 billion, owed by 18 banks. Other reports give ₦160 billion, ₦180 billion or more than ₦200 billion, and later reports give nearly ₦300 billion, so the totals conflict and the sources do not say whether they count the same invoices. TechCabal reports that banks were to pay 85% of the ₦250 billion (₦212.5 billion) by 31 December 2024 and agree a payment plan by 2 January 2025 to settle 60% of the older invoices, and other reports add that instalments were to end by July 2025 and that pending legal action was to stop. One report gives the 85% as applying to new invoices by 31 December 2025 instead. The circular itself was not opened here, so the invoice classes, the percentages and the dates are as the press reports themas of 2026-11.
Press reports say that on 15 January 2025 the NCC authorised MTN, Airtel, Globacom and 9mobile to disconnect the USSD codes of nine banks that had not cleared their debts by 27 January, and that nine other banks had complied. MTN said in February 2025 that banks had paid it ₦32 billion of ₦74 billion (TechCabal and TheCable; other outlets give ₦72 billion), leaving about ₦42 billion. In June 2025 the operators’ association was reported as saying banks had settled about 95% of ₦180 billion, with three banks still owing, and in February 2026 as saying the debt, then put at nearly ₦300 billion, was fully cleared. Those are the association’s statements as the press reports them, and this build found no statement from the NCC or the CBN on the final balanceas of 2026-11.
What can an engineer take from that? The reports describe a dispute over unpaid invoices and session charges that ran for years. The sources found here do not say which line items were contested, so do not assume the cause. Three habits help in any invoice dispute. Keep the session list and the transfer log joined and dated, so that an invoice line can be traced to a customer action or marked as a failure. Agree on the unit (a session, a started interval, a billed second) in writing before the first invoice. And keep a total, by month, of the failed sessions. That is the number that explains why an invoice is larger than the report of completed transfers.
What the data cannot tell you
The lab cannot show you the real unit, the real price or the real session timers. It cannot tell you which real bank is on which billing model. It gives no reason for a session to fail beyond its random draw, so it cannot say what a real failure looks like in a gateway log or whether a particular network drops more sessions than another. It plants twelve lost telco records and gives no cause for them, so it cannot tell you how often a real operator loses a session, or whether it would be to the bank’s cost or the telco’s. T1 carries 1,397 of the 3,412 sessions and T4 carries 335, but the generator assigns telcos by fixed shares, so the split says nothing about a real operator. Its fee and charge figures are inventions made to be computed on. Use the method, and bring your own logs.
You work in labs/finance. Every script is Python’s own sqlite3 module, run from that folder against data/rails.sqlite. Leave the data/answers folder shut until step 6. Amounts are integer kobo in the data and are printed as naira only for display. The lab’s charge, unit, timers, fees and billing policies are invented. The one outside rate in the lab is the press-reported end-user price in step 4, and it is a labelled input, not a confirmed rule.
1. Generate the week and check it. It takes about a second. Seed 42 gives the same week every time.
cd labs/finance
python3 rails.py
python3 check.py --rails-onlyrails.py prints:
32 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 12and check.py prints:
rails week: 17,998 transfers, 21 settlement sessions, 22,835 accounts; checks 21-25 run
OK: all invariants holdThe line 3,412 USSD sessions is the table this lab reads. The planted list names a kind, telco_record_missing, that this chapter is about, and the file behind that line stays closed until step 6.
2. Count the sessions by outcome, and what the failures cost. The script also checks that every charge equals the lab’s rule, so you know the table is what the generator says it is.
python3 - <<'PY'
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
def naira(kobo):
return f"₦{kobo // 100:,}.{kobo % 100:02d}"
UNIT_S, UNIT_KOBO = 20, 700 # the lab's illustrative billing: per started 20 seconds
print("1. sessions by outcome")
print(f" {'outcome':<13} {'sessions':>8} {'share':>7} {'avg s':>6} {'charged':>13}")
total, = db.execute("SELECT COUNT(*) FROM ussd_sessions").fetchone()
for outcome, n, avg, charged in db.execute("""
SELECT outcome, COUNT(*), AVG(duration_s), SUM(charge_kobo)
FROM ussd_sessions GROUP BY outcome ORDER BY COUNT(*) DESC"""):
print(f" {outcome:<13} {n:>8,} {100 * n / total:>6.1f}% {avg:>6.1f} {naira(charged):>13}")
failed, failed_charge = db.execute(
"SELECT COUNT(*), SUM(charge_kobo) FROM ussd_sessions WHERE outcome <> 'completed'").fetchone()
all_charge, = db.execute("SELECT SUM(charge_kobo) FROM ussd_sessions").fetchone()
print(f"2. {failed:,} of {total:,} sessions ({100 * failed / total:.1f}%) did not complete "
f"and were charged {naira(failed_charge)} of {naira(all_charge)} ({100 * failed_charge / all_charge:.1f}%)")
bad = 0
for dur, charge in db.execute("SELECT duration_s, charge_kobo FROM ussd_sessions"):
if charge != -(-dur // UNIT_S) * UNIT_KOBO:
bad += 1
print(f"3. rows where charge differs from ceil(duration / {UNIT_S}) x {UNIT_KOBO} kobo: {bad}")
print("4. timeout rows and the longest sessions")
print(" timeout durations:", db.execute(
"SELECT MIN(duration_s), MAX(duration_s) FROM ussd_sessions WHERE outcome = 'timeout'").fetchone())
longest, = db.execute(
"SELECT MAX(duration_s) FROM ussd_sessions WHERE outcome = 'completed'").fetchone()
print(f" the longest completed session: {longest} s")
PY1. sessions by outcome
outcome sessions share avg s charged
completed 2,743 80.4% 47.4 ₦54,460.00
timeout 347 10.2% 90.0 ₦12,145.00
user_cancel 197 5.8% 47.5 ₦3,941.00
network_drop 125 3.7% 50.6 ₦2,632.00
2. 669 of 3,412 sessions (19.6%) did not complete and were charged ₦18,718.00 of ₦73,178.00 (25.6%)
3. rows where charge differs from ceil(duration / 20) x 700 kobo: 0
4. timeout rows and the longest sessions
timeout durations: (90, 90)
the longest completed session: 76 sOf 3,412 sessions, 669 did not complete (19.6%), and they were charged ₦18,718.00 of ₦73,178.00 (25.6%). All 3,412 charges equal ceil(duration / 20) x 700 kobo. The timeout rows are all exactly 90 s and the longest completed session is 76 s, so every completed session ended inside the timer.
3. Find who paid, and the cost per completed transfer. Failed sessions stay in the numerator.
python3 - <<'PY'
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
def naira(kobo):
sign = "-" if kobo < 0 else ""
kobo = abs(kobo)
return f"{sign}₦{kobo // 100:,}.{kobo % 100:02d}"
print("1. by billing policy: who paid for the sessions")
print(f" {'billed to':<10} {'sessions':>8} {'completed':>9} {'charged':>13} {'per completed':>14}")
for who, n, done, charged in db.execute("""
SELECT billed_to, COUNT(*), SUM(outcome = 'completed'), SUM(charge_kobo)
FROM ussd_sessions GROUP BY billed_to ORDER BY billed_to"""):
print(f" {who:<10} {n:>8,} {done:>9,} {naira(charged):>13} {naira((2 * charged + done) // (2 * done)):>14}")
print("2. by institution: charge for every session divided by the sessions that completed")
rows = db.execute("""
SELECT institution, billed_to, COUNT(*), SUM(outcome = 'completed'), SUM(charge_kobo)
FROM ussd_sessions GROUP BY institution""").fetchall()
rows.sort(key=lambda r: r[4] / r[3])
print(f" {'inst':<5} {'billed to':<9} {'sessions':>8} {'completed':>9} {'charged':>12} {'per completed':>14}")
for inst, who, n, done, charged in rows[:3] + rows[-3:]:
print(f" {inst:<5} {who:<9} {n:>8,} {done:>9,} {naira(charged):>12} {naira((2 * charged + done) // (2 * done)):>14}")
print(" ... and the bank this course follows:")
for inst, who, n, done, charged in rows:
if inst == "B05":
print(f" {inst:<5} {who:<9} {n:>8,} {done:>9,} {naira(charged):>12} {naira((2 * charged + done) // (2 * done)):>14}")
print("3. by telco (the network that carried the session)")
for telco, n, charged, bank_part in db.execute("""
SELECT telco, COUNT(*), SUM(charge_kobo),
SUM(CASE WHEN billed_to = 'bank' THEN charge_kobo ELSE 0 END)
FROM ussd_sessions GROUP BY telco ORDER BY telco"""):
print(f" {telco} {n:>5,} sessions {naira(charged):>11} billed of which to banks {naira(bank_part):>11}")
print("4. the sender's customer fee on the transfers those sessions completed, against the session charges")
print(f" {'billed to':<10} {'completed':>9} {'fees earned':>13} {'session charges':>16} {'fees - charges':>15}")
for who, done, fees, charged in db.execute("""
SELECT u.billed_to, SUM(u.outcome = 'completed'),
SUM(CASE WHEN u.outcome = 'completed' THEN t.customer_fee_kobo ELSE 0 END), SUM(u.charge_kobo)
FROM ussd_sessions u LEFT JOIN transfers t ON t.session_id = u.session_id
WHERE u.billed_to = 'bank' GROUP BY u.billed_to"""):
print(f" {who:<10} {done:>9,} {naira(fees):>13} {naira(charged):>16} {naira(fees - charged):>15}")
who, done, fees, charged = db.execute("""
SELECT u.billed_to, SUM(u.outcome = 'completed'),
SUM(CASE WHEN u.outcome = 'completed' THEN t.customer_fee_kobo ELSE 0 END), SUM(u.charge_kobo)
FROM ussd_sessions u LEFT JOIN transfers t ON t.session_id = u.session_id
WHERE u.institution = 'B05'""").fetchone()
print(f" B05 (billed to {who}): {done} completed, fees {naira(fees)}, session charges {naira(charged)}, "
f"difference {naira(fees - charged)}")
PY1. by billing policy: who paid for the sessions
billed to sessions completed charged per completed
bank 1,065 877 ₦22,596.00 ₦25.77
customer 2,347 1,866 ₦50,582.00 ₦27.11
2. by institution: charge for every session divided by the sessions that completed
inst billed to sessions completed charged per completed
F02 customer 17 15 ₦364.00 ₦24.27
B14 bank 67 54 ₦1,316.00 ₦24.37
M01 customer 24 21 ₦518.00 ₦24.67
B12 customer 214 163 ₦4,704.00 ₦28.86
B18 customer 67 50 ₦1,463.00 ₦29.26
S01 customer 108 80 ₦2,408.00 ₦30.10
... and the bank this course follows:
B05 bank 181 145 ₦3,969.00 ₦27.37
3. by telco (the network that carried the session)
T1 1,397 sessions ₦30,135.00 billed of which to banks ₦9,478.00
T2 987 sessions ₦21,014.00 billed of which to banks ₦6,335.00
T3 693 sessions ₦14,805.00 billed of which to banks ₦4,683.00
T4 335 sessions ₦7,224.00 billed of which to banks ₦2,100.00
4. the sender's customer fee on the transfers those sessions completed, against the session charges
billed to completed fees earned session charges fees - charges
bank 877 ₦18,290.00 ₦22,596.00 -₦4,306.00
B05 (billed to bank): 145 completed, fees ₦3,090.00, session charges ₦3,969.00, difference -₦879.00The policy changes who pays and hardly changes the cost per completion: ₦25.77 against ₦27.11. The institution table shows the three lowest and three highest of the 32. The small ones (F02 and M01, with 17 and 24 sessions) are noisy. B05, billed to the bank, pays ₦3,969.00 for 181 sessions and ₦27.37 for each of its 145 completions. T1 (Lumora) carried 1,397 sessions and billed ₦30,135.00, of which ₦9,478.00 went to banks. Block 4 sets the lab’s customer fee against the lab’s session charge: -₦4,306.00 across the bank-billed sessions. Check one figure by hand: ₦22,596.00 ÷ 877 = ₦25.77.
4. Write the billing rule as a function and re-price the week. Save this as reprice.py. The function is the whole idea: the price of every started block. The asserts make it reproduce the lab’s own charges and the press-reported rate’s blocks before you trust it on the data. The 120 s rule is the press-reported end-user price in the notes above, used here as an input to arithmetic and not as a statement of the rule.
"""Re-price the week's sessions under a different billing rule. Money is integer kobo."""
import sqlite3
def sessions_charge(duration_s, block_s, price_kobo):
"""Charge for one session: the price of every block of block_s seconds that was started."""
if duration_s <= 0:
return 0
blocks = -(-duration_s // block_s) # ceiling division, no floats
return blocks * price_kobo
def naira(kobo):
return f"₦{kobo // 100:,}.{kobo % 100:02d}"
# the rule must reproduce the lab's own charges before it is trusted on another rule
assert sessions_charge(90, 20, 700) == 3500 and sessions_charge(91, 20, 700) == 3500
assert sessions_charge(101, 20, 700) == 4200
assert sessions_charge(120, 120, 698) == 698 and sessions_charge(121, 120, 698) == 1396
db = sqlite3.connect("data/rails.sqlite")
rows = db.execute("SELECT duration_s, outcome, charge_kobo FROM ussd_sessions").fetchall()
done = sum(1 for _, o, _ in rows if o == "completed")
RULES = [
("lab: ₦7.00 per started 20 s", 20, 700),
("press-reported: ₦6.98 per started 120 s", 120, 698),
]
print(f"{'rule':<42} {'week total':>12} {'failed sessions':>16} {'per completed':>14}")
for name, block, price in RULES:
total = sum(sessions_charge(d, block, price) for d, _, _ in rows)
lost = sum(sessions_charge(d, block, price) for d, o, _ in rows if o != "completed")
print(f"{name:<42} {naira(total):>12} {naira(lost):>16} {naira((2 * total + done) // (2 * done)):>14}")
# how many sessions start a second 120 s block
blocks = sum(-(-d // 120) for d, _, _ in rows)
long_ones = [o for d, o, _ in rows if d > 120]
print(f"120 s blocks started in the week: {blocks:,} x 698 kobo = {naira(blocks * 698)}")
print(f"sessions longer than 120 s: {len(long_ones)}, of which completed: {long_ones.count('completed')}")python3 reprice.pyrule week total failed sessions per completed
lab: ₦7.00 per started 20 s ₦73,178.00 ₦18,718.00 ₦26.68
press-reported: ₦6.98 per started 120 s ₦23,815.76 ₦4,669.62 ₦8.68
120 s blocks started in the week: 3,412 x 698 kobo = ₦23,815.76
sessions longer than 120 s: 0, of which completed: 0Redo the second row by hand. 3,412 sessions each start one 120 s block, and none ran past 120 s (the longest, a timeout, is 90 s), so 3,412 blocks × 698 kobo = 2,381,576 kobo = ₦23,815.76. Divided by 2,743 completions that is ₦8.68. The same sessions cost ₦73,178.00 under the lab’s rule and ₦23,815.76 (32.5% of that) under the press-reported one. The unit of billing matters more than the outcome mix.
5. Find the completed sessions the telco does not list. Every USSD transfer should have one completed session, so the test is an anti-join: the USSD transfers whose session_id is not among the telco’s completed sessions. The script then joins the failed sessions, which carry no session_id, to the same phone’s next transfer by phone and time. Do not open the answer key yet.
python3 - <<'PY'
import sqlite3
from datetime import datetime, timedelta
db = sqlite3.connect("data/rails.sqlite")
def naira(kobo):
return f"₦{kobo // 100:,}.{kobo % 100:02d}"
n_ussd, = db.execute("SELECT COUNT(*) FROM transfers WHERE channel = 'ussd'").fetchone()
linked, = db.execute("""SELECT COUNT(*) FROM transfers t
WHERE t.channel = 'ussd' AND t.session_id IN (SELECT session_id FROM ussd_sessions WHERE outcome = 'completed')""").fetchone()
print(f"1. transfers on the USSD channel: {n_ussd:,}; with a completed session in the telco's log: {linked:,}")
# the anti-join: a USSD transfer should have exactly one completed session
orphans = db.execute("""SELECT t.session_id, t.at, t.src, t.amount_kobo, t.first_response, t.final_status
FROM transfers t
WHERE t.channel = 'ussd'
AND t.session_id NOT IN (SELECT session_id FROM ussd_sessions WHERE outcome = 'completed')
ORDER BY t.at""").fetchall()
print(f"2. USSD-channel transfers with no completed session: {len(orphans)}, worth {naira(sum(o[3] for o in orphans))}")
for sid, at, src, amount, first, final in orphans:
print(f" {sid} {at[:16]} {src} {naira(amount):>13} first answer {first}, final {final}")
# a failed session has no session_id: join it to the same phone's next USSD transfer by time
by_phone = {}
for sid, at, phone in db.execute("""SELECT t.session_id, t.at, a.msisdn_hash
FROM transfers t JOIN accounts a ON a.account_no = t.debit_account WHERE t.channel = 'ussd'"""):
by_phone.setdefault(phone, []).append((datetime.fromisoformat(at), sid))
done_ids = {r[0] for r in db.execute("SELECT session_id FROM ussd_sessions WHERE outcome = 'completed'")}
orphan_ids = {o[0] for o in orphans}
paired = retried = 0
lonely = []
for phone, started, secs in db.execute("""SELECT msisdn_hash, started_at, duration_s FROM ussd_sessions
WHERE outcome <> 'completed'"""):
end = datetime.fromisoformat(started) + timedelta(seconds=secs)
hits = [x for x in by_phone.get(phone, []) if timedelta(0) <= x[0] - end <= timedelta(minutes=10)]
if len(hits) != 1:
continue
paired += 1
if hits[0][1] in done_ids:
retried += 1
else:
lonely.append(hits[0][1])
print(f"3. failed sessions joined to exactly one transfer by phone and time: {paired}")
print(f" the transfer has a completed session (the customer retried): {retried}")
print(f" the transfer has none: {len(lonely)}, all on the list in block 2: {set(lonely) <= orphan_ids}")
# a failed session followed within ten minutes by a completed one from the same phone
sessions = db.execute("""SELECT msisdn_hash, started_at, outcome, charge_kobo FROM ussd_sessions
ORDER BY msisdn_hash, started_at""").fetchall()
pairs = paid_twice = 0
for i in range(1, len(sessions)):
a, b = sessions[i - 1], sessions[i]
gap = (datetime.fromisoformat(b[1]) - datetime.fromisoformat(a[1])).total_seconds()
if a[0] == b[0] and a[2] != "completed" and b[2] == "completed" and gap < 600:
pairs += 1
paid_twice += a[3]
print(f"4. a failed session followed by a completed one from the same phone within 10 minutes: {pairs}")
print(f" the failed attempts in those pairs were charged {naira(paid_twice)}")
print("5. does the number of steps explain the failures?")
for steps, n, bad in db.execute("""SELECT steps, COUNT(*), SUM(outcome <> 'completed')
FROM ussd_sessions GROUP BY steps ORDER BY steps"""):
print(f" {steps} steps: {n:>4} sessions, {100 * bad / n:>5.1f}% did not complete")
PY1. transfers on the USSD channel: 2,755; with a completed session in the telco's log: 2,743
2. USSD-channel transfers with no completed session: 12, worth ₦129,776.00
900912260615080104193315439686 2026-06-15T08:01 B04 ₦14,232.00 first answer 00, final 00
900866260616103915323393371891 2026-06-16T10:39 B21 ₦8,519.00 first answer 00, final 00
900923260616211107845773673439 2026-06-16T21:11 F02 ₦8,705.00 first answer 00, final 00
900916260617093054516892207235 2026-06-17T09:30 B16 ₦488.00 first answer 00, final 00
900996260617180128630831954452 2026-06-17T18:01 B17 ₦5,678.00 first answer 00, final 00
900984260617184906789928290512 2026-06-17T18:49 B09 ₦4,933.00 first answer 00, final 00
900996260617230027834643961551 2026-06-17T23:00 B17 ₦26,742.00 first answer 00, final 00
900981260618114316265094219194 2026-06-18T11:43 B22 ₦42,237.00 first answer 00, final 00
900810260618125856858986114243 2026-06-18T12:58 F03 ₦7,251.00 first answer 00, final 00
900981260619113823153390654102 2026-06-19T11:38 B22 ₦4,013.00 first answer 97, final 00
900815260619125408600709170601 2026-06-19T12:54 B14 ₦2,707.00 first answer 00, final 00
900996260619140510552300735848 2026-06-19T14:05 B17 ₦4,271.00 first answer 00, final 00
3. failed sessions joined to exactly one transfer by phone and time: 669
the transfer has a completed session (the customer retried): 666
the transfer has none: 3, all on the list in block 2: True
4. a failed session followed by a completed one from the same phone within 10 minutes: 666
the failed attempts in those pairs were charged ₦18,627.00
5. does the number of steps explain the failures?
4 steps: 1128 sessions, 19.3% did not complete
5 steps: 1133 sessions, 19.6% did not complete
6 steps: 1151 sessions, 19.9% did not complete2,743 of the 2,755 USSD-channel transfers have a completed session in the telco’s log, and twelve do not: ₦129,776.00 that moved with no session to explain it. Eleven were approved at the switch’s first answer and one, ₦4,013.00 from B22, timed out at first and was settled later; all twelve are settled. Read the list as an investigator would. Twelve is too few to show a pattern in the amounts or the banks, so the finding is the list itself and not a cause. Block 3 gives a second angle. All 669 failed sessions pair with exactly one transfer by phone and time. In 666 of them the customer retried and the retry has a completed session. The other three have a transfer and no completed session, and all three are on the list: for those customers the only telco record is a failed one, while money moved. Block 4 reaches the same 666 from the telco’s side alone, and the failed attempts cost ₦18,627.00. Block 5 repeats the point that the failures do not depend on menu length in this generator.
6. Score the finding against the key. Now open the key. answers/rails_truth.csv lists every planted fault, and the kind telco_record_missing names the transfers whose completed session was removed from the telco’s records. Compare it with the set your anti-join found.
python3 - <<'PY'
import csv
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
found = {r[0] for r in db.execute("""SELECT t.session_id FROM transfers t
WHERE t.channel = 'ussd'
AND t.session_id NOT IN (SELECT session_id FROM ussd_sessions WHERE outcome = 'completed')""")}
# only now open the key
with open("data/answers/rails_truth.csv", newline="") as f:
key = {row["ref"]: row["who"] for row in csv.DictReader(f) if row["kind"] == "telco_record_missing"}
print(f"found {len(found)}, in the key {len(key)}")
print(f"found and in the key: {len(found & set(key))}")
print(f"found but not in the key: {len(found - set(key))}")
print(f"in the key but not found: {len(set(key) - found)}")
by_telco = {}
for t in key.values():
by_telco[t] = by_telco.get(t, 0) + 1
print("telco whose record was lost:", dict(sorted(by_telco.items())))
PYfound 12, in the key 12
found and in the key: 12
found but not in the key: 0
in the key but not found: 0
telco whose record was lost: {'T1': 6, 'T2': 1, 'T3': 2, 'T4': 3}Twelve found, twelve in the key, none missing and none extra. The key also says which telco lost each record, which the bank’s own data cannot tell you: T1 six, T4 three, T3 two, T2 one. Take that to the telco as a list of session ids to look for, not as an accusation, and ask for the gateway log of those minutes before anyone guesses at a cause.
The telco cannot bill a session it lost. Estimate what the twelve would have cost at the week’s average completed session, using integer kobo. Save this as lost.py and run python3 lost.py.
import sqlite3
db = sqlite3.connect("data/rails.sqlite")
def naira(kobo):
return f"₦{kobo // 100:,}.{kobo % 100:02d}"
done, charged = db.execute(
"SELECT COUNT(*), SUM(charge_kobo) FROM ussd_sessions WHERE outcome = 'completed'").fetchone()
average = charged // done # integer kobo per completed session
print(f"average completed session: {naira(average)}")
rows = db.execute("""SELECT p.ussd_billing, COUNT(*), SUM(t.amount_kobo)
FROM transfers t JOIN participants p ON p.code = t.src
WHERE t.channel = 'ussd'
AND t.session_id NOT IN (SELECT session_id FROM ussd_sessions WHERE outcome = 'completed')
GROUP BY p.ussd_billing ORDER BY p.ussd_billing""").fetchall()
for who, n, value in rows:
print(f"billed to {who:<8} {n:>2} transfers, {naira(value):>13} moved, about {naira(n * average)} of session charges not on any list")The output is:
average completed session: ₦19.85
billed to bank 6 transfers, ₦85,648.00 moved, about ₦119.10 of session charges not on any list
billed to customer 6 transfers, ₦44,128.00 moved, about ₦119.10 of session charges not on any listSix of the twelve transfers are from banks billed for sessions and six from customer-billed institutions, so the ₦238.20 is split in the lab’s own terms, about ₦119.10 each way. Then ask who gains from the gap and who should raise it, and why a bank on corporate billing would still want the twelve found. Write your answer in one sentence, with the line of output that supports it.
Template
# Invoice reconciliation: <telco>, <period>
Prepared by <name, role>. Approved and signed by <name, role>.
## 1. What was billed, against what we logged
| Line | Telco invoice | Our log | Difference |
|---|---|---|---|
| Sessions billed to us | <n> | | |
| Completed sessions | <n> | <our completed transfers> | <n> |
| Failed sessions (timeout, cancel, drop) | <n> | | |
| Amount | <₦> | | |
Cost of a completed transfer: <all charges ÷ completed sessions>.
## 2. Failed sessions
<count and ₦. Say whether the contract treats them as billable; not disputed unless it says otherwise.>
## 3. Transfers with no telco record
| Session id | Time | Amount moved | Our status |
|---|---|---|---|
Estimated charge not on any invoice: <n × average session>. What we cannot show without the telco's record: <...>
## 4. Amount disputed, and amount at risk
<₦ disputed (may be 0.00) and what it covers. ₦ we hold back or expect to be billed later, and why.>
## 5. Evidence attached
<queries run, row counts, files, session ids>
## 6. Letter to <telco contact>
<what we will pay and by when; what we ask you to send; by when we need it>
## 7. Not yet checked
<contract terms, current rules, anything you did not open. Owner and date.>
## 8. How this could be wrong
<one way, and what would show it> WORKED EXAMPLE
A finance analyst at a bank on corporate billing drafts this for the head of finance, who signs the letter and releases the payment. For the example, treat the lab’s bank-billed lines as one bank’s invoices for 15 to 21 June 2026, from the three telcos involved.
Reconciliation. The telcos billed 1,065 sessions and ₦22,596.00 to the bank. 877 completed, and the bank’s log has 883 USSD transfers, so six transfers have no completed session on any telco’s list. Cost of a completed transfer: ₦22,596.00 ÷ 877 = ₦25.77, the figure the lab printed.
Failed sessions. 188 of the 1,065 (39 dropped, 93 timed out, 56 cancelled) did not complete. Until the contract is read, we treat them as a cost of the channel and do not dispute them.
No telco record. Six transfers moved ₦85,648.00. We can show the money moved but not the session that carried it, so a customer who questioned one could not be shown a telco record. The first is 900996260617180128630831954452 on 17 June, ₦5,678.00; five more are listed with time and amount. The step 6 key puts two with T1, two with T3 and two with T4. None is on an invoice. At the week’s ₦19.85 average completed session, about ₦119.10 (6 × ₦19.85) may be billed later.
Amount disputed. ₦0.00. The 877 completed sessions match 877 of our transfers, so nothing is overcharged. At risk: ₦119.10, which we accrue and do not withhold from the payment. We pay ₦22,596.00 and ask each telco for its gateway records for its two session ids, and whether it will bill them.
Evidence. Step 5’s anti-join: 12 lab-wide, 6 for bank-billed institutions.
Not yet checked. The contract’s terms on failed sessions and late billing. The analyst reads it before the payment date.
How this could be wrong. A transfer id may never have reached a telco, so no record was lost. The gateway records would show it.
Now you
You work in finance at a bank on corporate billing. T4’s invoice for the month arrives and the head of finance wants to know whether to pay it as it stands. Treat the lab’s week as that month, and T4’s lines for banks as your invoice. Step 3 prints T4’s 335 sessions, ₦7,224.00 billed in all, of which ₦2,100.00 went to banks. Step 6 says the key lost three T4 records. Adapt the step 5 anti-join to list them, and keep only those from banks on corporate billing, since only those could belong on this invoice. Price them with the step 5 average. Decide what you dispute, if anything, and what you only ask for. Write the reconciliation and a letter to T4’s revenue-assurance team. The head of finance reads it and decides whether to pay in full by the due date or hold part of it.
Self-check
Nwanneka's invoice to Northmere for the month is larger than Obafemi's count of completed transfers would explain. Obafemi's team has joined the telco's session list to its own transfer log. About a fifth of the sessions failed, and almost all of those were followed by a retry from the same phone, so failures explain the gap. A dozen of Northmere's USSD transfers, which moved money, have no completed session on the telco's list at all. In this invented scene Northmere is still on corporate billing for the month. Reports say regulators told banks to pay operators' invoices on a schedule and to stop legal action, and allowed operators to disconnect the codes of banks that did not comply. The contract and the current rules have not been read by anyone in the room. What should Northmere do with this invoice?
- DOC Determination of USSD Pricing and Services (NCC, 13 March 2025) Nigerian Communications Commission, 2025
The telecoms regulator's own text on how a USSD session is priced and who may bill for it. Read the definitions, the billing model and the start date, which the search results gave two ways. This chapter could not open it, so check every figure.
- DOC End User Billing (EUB) Policy for USSD Banking Transactions in Nigeria (NCC FAQ) Nigerian Communications Commission
The regulator's plain-language answers on consent, the end-of-session notice, double billing and opting out. Look for the price and for what it says about failed sessions, where press reports disagree.
- DOC USSD Regulatory Framework (CBN, 2018) Central Bank of Nigeria, 2018
The central bank's controls on USSD financial services: authentication, the second factor above a threshold and the daily cap. Read it beside the billing rules to see that the two regulators answer different questions. Reports differ on the start date.
- DOC Press Statement: USSD: Banks Owe Telcos N17bn, Says Danbatta (NCC, August 2020) Nigerian Communications Commission, 2020
An NCC statement on the 2020 revision of USSD pricing and the return to corporate billing, which is the history behind the 2025 change. Read it for how the regulator states its aims and the debt it then reported; this chapter did not open it.
- POST Banks must settle ₦212.5 billion USSD debt to telcos by year-end (TechCabal, 24 December 2024) TechCabal, 2024
Press coverage of the December 2024 joint circular and its percentages and deadlines. It is press, so go to the circular for the rule. Read it for the invoice classes and the dates it reports; skip the commentary.
- POST NCC orders telcos to disconnect nine banks over USSD debt (Channels Television, 15 January 2025) Channels Television, 2025
Press coverage of the enforcement step in January 2025. Read it for what the regulator allowed the operators to do and to which banks. It is a press report, so check any figure against a regulator's statement.
- POST Banks, telcos end protracted USSD fee dispute after N300bn debt settlement (TheCable) TheCable, 2026
Press coverage of the operators' association saying the debt was cleared. Read it to see how the total grew from the ₦250 billion of the 2024 reports, and treat the figure as the association's, reported by the press.
- DOC Revision To The USSD Pricing Model By The NCC (TNP, via Mondaq) TNP, 2020
A law firm's note on the 2020 revision of the pricing model, listed in search results and not opened here. It is commentary, not the rule. Use it for the history of price floors and caps before the 2025 determination, and check it against the NCC's documents.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.