Disbursement and repayment rails: direct debit, card on file, GSI
A loan is paid out once and collected many times, and each collection runs on a rail with its own permission, its own failures and its own cost. Choose the rail by how it fails, not by how it looks on the day it works
Owoleaf's book has four repayment rails: wallet debit (the money is in Owoleaf's own wallet, so Owoleaf takes it), card on file, direct debit and GSI. Which has the lowest share of instalments paid on their due date, and why?
A loan moves money twice, in opposite directions and under different rules. At disbursement the lender pushes money to the borrower once, and a mistake costs the principal. At repayment the lender collects many times, over weeks, and a mistake costs customers, goodwill and sometimes a complaint. Module 1 taught the schedule and the status ladder (the loan lifecycle and loan products). This chapter teaches what carries the money.
A rail is the road a payment travels, with its own rules for when it is final (Nigeria’s rails). A mandate is a borrower’s standing permission for a lender to pull money from an account, which direct debit and mandates teaches in full. A saved card is a card the borrower has agreed to keep on file, and tokenisation and recurring payments covers it. This chapter does not repeat them. It asks what they mean for a lender.
Five rails in, two out
The table lists what a lender can use, who starts each, and how each fails. The last column says which of Owoleaf’s products the lab puts on it.
| Rail | Direction | Who starts it | Permission it rests on | Typical way it fails | Lab product |
|---|---|---|---|---|---|
| NIP transfer | out | Lender | None needed from the borrower beyond the account details | Wrong account, bank down, answer 09 | all four, at disbursement |
| Wallet credit | out | Lender | The borrower’s wallet exists | Almost none: it is a ledger entry | all four |
| Wallet debit | in | Lender | The loan agreement | The wallet is empty on the day | SAL |
| Direct debit | in | Lender | A mandate authorised at the borrower’s bank | Not authorised yet, cap, insufficient funds (51), revoked | PL |
| Card on file | in | Lender | A saved card and the borrower’s agreement at the first payment | Soft decline, expired card, card replaced | BNPL |
| Global Standing Instruction (GSI) | in | Creditor bank, through NIBSS (the Nigeria Inter-Bank Settlement System) | A mandate signed with the loan | No funds in any account, restrictions on the account | SME (a simplification, see below) |
| Salary deduction | in | Employer | An agreement among lender, employer and employee | Employee leaves, payroll runs late | not in the lab |
Two things in the table recur through the chapter. Every rail that pulls money depends on a permission the borrower gave earlier, and the permission is the part of the system that decays. And only wallet debit lets the lender decide when the money moves and see the balance first.
Paying out: the net amount and the answer “in progress”
A salary advance, a personal loan, a BNPL purchase and an SME loan are all paid out net of the fee. Take L000043, the personal loan from module 1: ₦310,000 principal, a fee of 1% (₦3,100), so ₦306,900 leaves. In kobo (one hundredth of a naira) that is 31,000,000 − 310,000 = 30,690,000. The loan’s receivable is the full principal, because the borrower owes ₦310,000; the ₦3,100 is fee income, earned on the day. A system that books the receivable as the net amount understates what is owed and makes every interest figure wrong. Interest, APR, fees and amortisation showed what the fee does to the true cost.
Wallet credit is a posting in Owoleaf’s own ledger: debit the loan receivable and the fee income, credit the borrower’s wallet. It is instant and costs nothing in rail fees. The customer can then spend it or cash it out over NIP, so the cash-out is the real payout and it can fail on its own, after the loan has been booked.
A NIP transfer to the borrower’s bank account has the problems of every push payment (transfers and virtual accounts). Run a name enquiry first, so the account name can be compared with the name the lender verified. Then send. The answer can be 00 (done), a failure, or 09, in progress. 09 is not a failure. The only safe action is to ask the switch for the status of the transfer you already sent, and to wait.
The CBN’s Regulation on Instant (Inter-Bank) Electronic Funds Transfer Services in Nigeria, per search summaries, says senders must support name enquiry so that wrong credits are avoided and that instant transfers are settled no later than the next business day (T+1). The cover is dated July 2018, the circular is dated September 2018, and secondary sources give 2 October 2018 as the start date, with one reposting giving another October dateas of 2026-11. The Nigeria’s rails chapter states the rule in more detail, with the same caveat: this build could not open the PDF.
For a lender the rule that matters is the order of events. A loan should have a state between approved and disbursed: call it disbursing. It holds the payment reference, which is built from the loan, so that a crashed job that restarts sends the same reference and is refused as a duplicate. The loan becomes disbursed, with its schedule and its interest clock starting, only when the status is final and successful. If the loan starts its clock at the approval, a payout stuck in 09 for a day charges the borrower interest on money they do not have.
What goes wrong, in the order it hurts: the loan is booked and the money never left (the borrower owes money they never received); the job sends again after a timeout with a new reference (a double payout, and principal lost unless the second payee returns it); the account name does not match the borrower (a fraud signal that Compliance, not Lending, owns in depth). The lab sends one payout through the mock switch and a pending answer.
Collecting: the permission comes first
Wallet debit
Owoleaf can take an instalment from the borrower’s wallet because the loan agreement says so. This is the simplest rail to build and the only one where the lender sees the balance before it asks. It still fails when the wallet is empty, and in Owoleaf’s design the wallet is also where the borrower’s other money lives. A salary advance repaid from a wallet competes with the borrower’s rent, transport and data. Taking everything in the wallet at 00:01 on the due date is possible. Whether it is fair, and whether it matches what the borrower agreed to, is a conduct question for the module’s collections and consumer-protection chapters, which this course names in plain text until they are written.
Direct debit
A direct debit is a pull from the borrower’s bank account under a mandate that the borrower authorised at their own bank. Three lender decisions sit inside it: the cap on one debit, the frequency, and what to do with a refusal. The Payments chapter has the refusal codes. Two are worth repeating because they decide the lender’s retry logic: 51 (insufficient funds) may clear by another day, while 61 (over the cap) and 63 (mandate not active) will not, whatever the balance. The lab shows a lender setting a mandate’s cap to exactly the instalment and then trying to collect a late fee on top. The debit is refused with 61. The cap was set for the schedule and not for the schedule’s worst case.
The CBN’s Regulation for Direct Debit Scheme in Nigeria, 2018 (revised), per search summaries, says (clause 2.1.14, as quoted in a search result) that a biller must notify the payer by SMS or email of a failed direct debit, with no deadline found for that notice, and that the biller’s bank accepts cancellation of a mandate only from the biller. A 24-hour period in the summaries is about something else: the biller’s bank may re-present an unpaid instruction within 24 hours or as agreed with the payer. This build could not open the PDF, and the searches did not confirm that the 2018 text is still the current oneas of 2026-11.
Read those together. The notice duty means a failed debit is a customer communication, not a line in a log, and it belongs in the collector; how fast it must go out is for the current text, and this chapter states no deadline. A debit above the mandate’s cap is refused (61) in the lab, and a lender should treat the cap as the limit of what the borrower agreed to. The direct debit and mandates chapter lists what the same Regulation, per its summaries, says about activation, and what could not be confirmed about re-presentment. The lab’s collector retries after a 51 on a later day. How many times, and how soon, is set by the current text and by what the borrower agreed to, never by the lab.
Card on file
A saved card gives the lender a pull payment with the cost and the decline pattern of a card payment. The first payment is taken with the borrower present, with their agreement to keep the card; later instalments are taken without them. The provider’s reply on the first charge carries an authorization_code, not the card number. A later charge sends that code and the borrower’s reference. The two failures behave differently. A soft decline (insufficient funds, in the lab) can clear another day. A hard one, such as an expired card, never will: a retry is wasted money and may cost scheme fees. The tokenisation chapter teaches the classes, the sources on retry limits and where they disagree, and what a retry earns, and the lab uses its mock provider the same way.
Cost differs too. The mock provider takes 1% of a successful charge, an invented rate that stands for a processor’s fee. On an instalment of ₦8,000 that is ₦80. The lab assumes a flat amount for each direct-debit attempt, also invented; a real provider’s terms may be a percentage with a cap or something else. The lab makes both explicit and compares them, because the cheaper rail changes with the size of the instalment.
GSI
The Global Standing Instruction is a Nigerian mechanism for a lender to recover a loan from a defaulting borrower’s accounts at other banks. It is not a way to collect a normal instalment.
The CBN’s Operational Guidelines on Global Standing Instruction (GSI) for individuals, circular FPRD/DIR/GEN/CIR/07/056 of July 2020 (search results date it 13 July), took effect on 1 August 2020, per search summaries. They say the GSI is a last resort for the creditor bank, that it applies to loans to individuals, that the borrower signs a GSI mandate, on paper or digitally, as part of the loan agreement and disbursement depends on it, that NIBSS runs the operation using Bank Verification Numbers (BVNs), that recovery covers principal and accrued interest and not penal charges, and that accounts with recognised restrictions (a court order is one example in a search snippet) are not available to it. A circular of January 2022 appears in search results, described by some summaries as an amendment allowing continuous recovery and by others as a re-circulation, so the 2020 points may have changed. Sources also disagree on whether the scheme has been extended to microfinance banks and corporate accounts. This build could not open the CBN’s PDFas of 2026-11..
Three consequences for a lender follow, each one a design decision. First, the permission is taken at the loan’s start, so the loan agreement must contain it; a lender who forgets has nothing to enforce. Second, the borrower’s BVN must match the accounts, or the instruction finds nothing. Third, a late fee is a candidate for “penal charges”, which the 2020 guidelines exclude according to the summaries. Whether a given fee is penal is a reading of the contract and the text, and for counsel, not for the collector.
In the lab, SME loans carry the rail gsi as a simplification: the book needs one repayment rail per product, and it labels the rail it expects to collect on. Read it as “the loan has a GSI mandate behind it”, not as “instalments are collected by GSI”. The summaries describe a mechanism for creditor banks and for loans to individuals, so whether a wallet lender such as Owoleaf, or a loan to a business, could use a GSI is not established here: the label is a teaching device. Read its row in the table below with that in mind.
Salary deduction
For a lender that is also a salary bank, there is a fifth rail. Northmere Bank built its own salary-disbursement system in 2014 and holds the salary accounts of many customers. When the salary arrives in an account at Northmere, a loan repayment can, if the loan agreement allows it, be taken at that moment, before the customer can spend it. That is a strong position, and it exists because Northmere holds the account, not because of a clever collector. Owoleaf, a wallet, does not see salaries. A lender that is not the salary bank can reach the same position only through an agreement with the employer, who deducts and remits, or with a data partner. The lab has no salary rail, and this chapter states no rule for it: the terms are contractual, and it is a rail whose permission involves three parties.
When to ask
Every pull rail has a clock, and the clock that matters most is the borrower’s. A debit at 08:00 on the due date is early for a borrower paid on the 28th and late for one paid on the 25th. A lender’s own schedule fixes the due date from the disbursement day (L000043 was paid out on 20 June and its periods are 30 days long, so its instalments fall on 20 July, 19 August, 18 September and 18 October: a fixed number of days apart, not on the same date each month). The borrower’s income does not follow it.
Three choices follow. Choose the due date to follow the borrower’s pay day, which is a product decision made at the offer. Choose the hour of the debit, since a debit soon after the salary credit meets a full account. And choose the retry rule: a soft failure is retried on a later day, with a new reference each time, up to a limit, and a hard failure goes to a person or to the customer for a new card or a new mandate. The retry limit is a rule from the scheme or the regulator, not from the lab. A sequence of retries that recovers little is worth measuring before you pay for it, and the tokenisation chapter shows how.
What the book says, and what it cannot
The loan book records repayments, not attempts. It has one row for each payment that arrived, with the rail and the late fee. So it cannot show how many debits were refused, or with which code, or what each retry cost. What it can show is the outcome for each instalment that fell due before the cut-off: paid on its due date, paid late, or not paid in full. The lab computes that for every rail. At the default scale it gives this:
| Rail | Instalments due | On time | Late | Missed | On time % | Collected % |
|---|---|---|---|---|---|---|
| Card | 340 | 279 | 46 | 15 | 82.1 | 97.7 |
| Direct debit | 237 | 200 | 25 | 12 | 84.4 | 95.5 |
| GSI | 180 | 157 | 15 | 8 | 87.2 | 97.5 |
| Wallet debit | 190 | 134 | 28 | 28 | 70.5 | 84.7 |
Wallet debit is the weakest by a wide margin, and a reader’s instinct is to blame the rail. Check what else changes with the rail. Each rail carries exactly one product: card with BNPL, direct debit with the personal loan, GSI with the SME loan, wallet debit with the salary advance. A salary advance is a single repayment, so one missed instalment is the whole loan. It is also the product to which the generator adds an extra chance of default. The data cannot separate the rail from the product and the borrowers on it. In this book, by construction, the rail does not change anyone’s behaviour: loans.py draws a borrower’s lateness from a hidden risk, and the chance of default from that risk, the product and the number of instalments, and the rail is only a label. You can read the code to check. A real book would have to compare the same product on two rails before it could say anything about the rail.
Where it goes wrong
- A retry that reuses the reference. The switch answers 26 and the first attempt’s outcome. If that was a failure, nothing is tried, and a job that logs “attempt 2” has not made one.
- A cap that fits the schedule and not the fee. The first late instalment cannot be collected in full, and a retry never fixes it.
- Retrying a hard failure. An expired card or a revoked mandate wastes calls and cost, and may bring scheme fees.
- Booking the payout before it is final. The loan is live, the interest runs, and the money is still pending or has failed.
- Treating the rail’s success rate as the rail’s quality. The borrowers on a rail are not a random sample.
- A failed debit with no notice to the borrower. The Regulation, per its summaries, requires the biller to notify the payer by SMS or email; check the text for any deadline.
- A permission that lapsed. A mandate past its end date, a card past its expiry month and a changed BVN all quietly turn a collectable loan into an uncollectable one. A check of every live loan’s permission each night is cheap.
Owoleaf and Northmere at 200 people
At 200 people Owoleaf has four products, four rails and one collector. Akpofure’s change is small: a debit that gets 51 is retried on later days with a new reference per try, stops at 61 or 63 and opens a task for a person, and a failed debit sends the borrower a message. The harder change is Salamatu’s: move the due dates of new personal loans towards the pay days the customers state at the offer. Northmere can do that for its own salary customers because it sees the salary. Owoleaf must ask, and accept the answer as a claim it checks against the wallet’s inflows. A lender chooses rails by how the borrowers behave on them and by the permissions it can hold. Choosing the one that looked best in a table is how a product gets built on a confound.
You work in labs/finance. Every step is Python run from that folder. The keys sw_test_owoleaf_mock (the switch) and sk_test_owoleaf_mock (the provider) are the mocks’ fixed test keys. Every rate, fee, code and timing in the mocks is illustrative. Step 2 reads the book alone. Step 3 resets the switch and step 5 resets the provider as their first action. Run step 3 before step 4, and run them together again if you repeat either.
1. Start the two mocks. In one terminal start the switch, and in another the provider. --fresh deletes their earlier state.
cd labs/finance
python3 generate.py && python3 loans.py # skip if data/finance.sqlite already has the loan tables
python3 mock_switch.py --freshcd labs/finance
python3 mock_provider.py --freshmock_switch on http://127.0.0.1:8102 institution P01 key sw_test_owoleaf_mock callbacks -> (none)
mock_provider on http://127.0.0.1:8101 secret sk_test_owoleaf_mock webhooks -> (none)Each terminal keeps running. Use a third terminal for the steps that follow.
2. Read the repayment outcomes by rail. The script takes every instalment that fell due before the cut-off, adds up what was paid on it, and sorts it into on time, late or missed. It then prints which products each rail carries.
python3 - <<'PY'
import datetime as dt
import sqlite3
con = sqlite3.connect("data/finance.sqlite")
cut_off = con.execute("SELECT value FROM loan_book_meta WHERE key = 'cut_off'").fetchone()[0]
# One row per instalment that fell due before the cut-off, with what was paid on it.
rows = con.execute("""
SELECT l.repayment_rail, s.due_date, s.total_kobo,
COALESCE(SUM(r.amount_kobo - r.late_fee_kobo), 0) AS paid_kobo,
MAX(r.paid_at) AS last_paid
FROM schedule s
JOIN loans l ON l.id = s.loan_id
LEFT JOIN repayments r ON r.loan_id = s.loan_id AND r.instalment = s.instalment
WHERE s.due_date < ?
GROUP BY s.loan_id, s.instalment
""", (cut_off,)).fetchall()
stats = {}
for rail, due, total, paid, last_paid in rows:
s = stats.setdefault(rail, {"due": 0, "on_time": 0, "late": 0, "missed": 0, "days_late": 0, "due_kobo": 0, "got_kobo": 0})
s["due"] += 1
s["due_kobo"] += total
s["got_kobo"] += min(paid, total)
if paid < total:
s["missed"] += 1 # unpaid, or part paid and never completed
else:
late = (dt.date.fromisoformat(last_paid) - dt.date.fromisoformat(due)).days
if late <= 0:
s["on_time"] += 1
else:
s["late"] += 1
s["days_late"] += late
print(f"cut-off {cut_off}; instalments due before it, by repayment rail")
print(f"{'rail':<13}{'due':>5}{'on time':>9}{'late':>6}{'missed':>8}{'on time %':>10}{'missed %':>9}{'avg days late':>14}{'collected %':>12}")
for rail in sorted(stats):
s = stats[rail]
print(f"{rail:<13}{s['due']:>5}{s['on_time']:>9}{s['late']:>6}{s['missed']:>8}"
f"{100 * s['on_time'] / s['due']:>10.1f}{100 * s['missed'] / s['due']:>9.1f}"
f"{s['days_late'] / max(s['late'], 1):>14.1f}{100 * s['got_kobo'] / s['due_kobo']:>12.1f}")
print()
print("products per rail (is the rail the product?)")
for rail, products, loans in con.execute(
"SELECT repayment_rail, group_concat(DISTINCT product), COUNT(*) FROM loans GROUP BY repayment_rail"):
print(f" {rail:<13} {products:<5} {loans} loans")
PYcut-off 2026-10-28; instalments due before it, by repayment rail
rail due on time late missed on time % missed % avg days late collected %
card 340 279 46 15 82.1 4.4 10.7 97.7
direct_debit 237 200 25 12 84.4 5.1 10.8 95.5
gsi 180 157 15 8 87.2 4.4 10.5 97.5
wallet_debit 190 134 28 28 70.5 14.7 11.1 84.7
products per rail (is the rail the product?)
card BNPL 85 loans
direct_debit PL 52 loans
gsi SME 45 loans
wallet_debit SAL 190 loansRead the second block before the first. Each rail has one product, so every difference in the table is a difference between products and borrowers as well. The 15, 12, 8 and 28 missed instalments include borrowers who paid part and never completed the instalment. collected % is the naira collected divided by the naira due, capped at the amount due: wallet debit collects 84.7%, the others 95.5% to 97.7%. The book holds no failed attempts, so nothing here says how often a debit was refused.
3. Pay out L000043 and meet an answer of 09. The script resets the switch, reads the loan, runs a name enquiry for the borrower’s account, sends the net amount with the test hook X-Mock-Force: pending, tries to send it again, and requeries until the transfer is final. The wait is about 10 seconds.
python3 - <<'PY'
import json
import sqlite3
import time
import urllib.error
import urllib.request
BASE, KEY = "http://127.0.0.1:8102", "sw_test_owoleaf_mock"
def call(method, path, body=None, force=None):
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
if force:
headers["X-Mock-Force"] = force
data = json.dumps(body).encode() if method == "POST" else None
req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
call("POST", "/admin/reset", {}) # start from an empty switch
con = sqlite3.connect("data/finance.sqlite")
loan_id, customer_id, principal, fee, net = con.execute(
"SELECT id, customer_id, principal_kobo, fee_kobo, disbursed_net_kobo FROM loans WHERE id = 'L000043'").fetchone()
print(f"{loan_id}: principal {principal}, fee {fee}, net paid out {net} (check: {principal} - {fee} = {principal - fee})")
# The payee's account: a pseudo-bank account that exists (any 10 digits not ending in 0).
enquiry = call("POST", "/name-enquiry", {"bank_code": "B03", "account_number": "2100000233"})
print(f"name enquiry -> {enquiry['response_code']} {enquiry['account_name']}")
pay = {"payment_reference": f"OWL-DISB-{loan_id}", "name_enquiry_ref": enquiry["name_enquiry_ref"],
"sender_account": "9000000233", "amount_kobo": net, "narration": f"Loan {loan_id}"}
first = call("POST", "/transfers", pay, force="pending")
print(f"send -> {first['response_code']} ({first['response_message']}), status {first['status']}")
again = call("POST", "/transfers", pay)
print(f"send again -> {again['response_code']} ({again['response_message']}), same session: {again['session_id'] == first['session_id']}")
for attempt in range(1, 9):
q = call("POST", "/tsq", {"payment_reference": pay["payment_reference"]})
print(f"requery {attempt} -> {q['response_code']}, status {q['status']}")
if q["status"] != "pending":
break
time.sleep(3)
print(f"Post the loan only now: receivable {principal}, cash out {net}, fee income {fee}")
PYL000043: principal 31000000, fee 310000, net paid out 30690000 (check: 31000000 - 310000 = 30690000)
name enquiry -> 00 HOLDER B03-0233
send -> 09 (Request processing in progress), status pending
send again -> 26 (Duplicate record), same session: True
requery 1 -> 09, status pending
requery 2 -> 09, status pending
requery 3 -> 09, status pending
requery 4 -> 09, status pending
requery 5 -> 00, status successful
Post the loan only now: receivable 31000000, cash out 30690000, fee income 310000The net amount is 31,000,000 − 310,000 = 30,690,000 kobo (₦306,900). The first send answers 09, in progress. Sending again with the same reference answers 26, duplicate, and returns the same session id: nothing new was sent. The requery stays 09 until the mock’s pending time (10 seconds) has passed, then answers 00. The number of requery lines can be 4 or 5 on your machine. Only after the last line does the loan move from disbursing to disbursed.
4. Collect instalment 2 by direct debit: a refusal, a cap, a retry. The script creates a mandate whose cap is the instalment, authorises it, and runs four debits. Instalment 2 of L000043 is ₦60,102.30, due 19 August 2026. The loan’s late fee is ₦1,000 (100,000 kobo).
python3 - <<'PY'
import datetime as dt
import json
import sqlite3
import urllib.error
import urllib.request
BASE, KEY = "http://127.0.0.1:8102", "sw_test_owoleaf_mock"
def call(method, path, body=None, force=None):
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
if force:
headers["X-Mock-Force"] = force
data = json.dumps(body).encode() if method == "POST" else None
req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
con = sqlite3.connect("data/finance.sqlite")
loan = con.execute("SELECT l.id, c.ref, l.principal_kobo FROM loans l JOIN customers c ON c.id = l.customer_id "
"WHERE l.id = 'L000043'").fetchone()
loan_id, customer_ref, principal = loan
due, instalment, late_fee = con.execute(
"SELECT due_date, total_kobo, (SELECT late_fee_kobo FROM loan_products WHERE code = 'PL') "
"FROM schedule WHERE loan_id = ? AND instalment = 2", (loan_id,)).fetchone()
print(f"{loan_id} instalment 2 due {due}: {instalment} kobo; late fee {late_fee} kobo")
# 1. The mandate. Its cap is the instalment: the amount the borrower agreed to.
today = dt.date.today()
m = call("POST", "/mandates", {
"reference": f"OWL-MND-{loan_id}", "payer_bank": "B03", "payer_account": "2100000233",
"max_amount_kobo": instalment, "frequency": "monthly", "start_date": today.isoformat(),
"end_date": (today + dt.timedelta(days=200)).isoformat(), "customer_ref": customer_ref})
mid = m["mandate_id"]
print(f"mandate -> {m['response_code']} {m['status']}, cap {m['max_amount_kobo']}")
print(f"authorise -> {call('POST', f'/admin/mandates/{mid}/authorise', {})['status']}")
def debit(label, ref, amount, force=None):
d = call("POST", "/debits", {"mandate_id": mid, "reference": ref, "amount_kobo": amount}, force)
print(f"{label:<12} -> {d['response_code']} ({d['response_message']}), status {d.get('status', '-')}")
return d
# 2. Attempt 1: the payer's account is empty. 51 is soft: try again on another day, with a new reference.
debit("try 1", f"{loan_id}-I2-T1", instalment, force="nsf")
# 3. The late fee does not fit under the cap. 61 is not about the balance: retrying cannot change it.
debit("with late fee", f"{loan_id}-I2-T1F", instalment + late_fee)
# 4. Attempt 2, a new reference, funds present.
debit("try 2", f"{loan_id}-I2-T2", instalment)
# 5. The mistake: sending try 2 again after it worked.
debit("resend try 2", f"{loan_id}-I2-T2", instalment)
print("attempts on the switch")
for d in call("GET", f"/debits?mandate_id={mid}")["debits"]:
print(f" {d['reference']:<18} {d['amount_kobo']:>9} {d['response_code']} {d['status']}")
s = call("GET", "/settlement")
print(f"settlement -> inward {s['inward_kobo']}, outward {s['outward_kobo']}, net {s['net_kobo']}")
PYL000043 instalment 2 due 2026-08-19: 6010230 kobo; late fee 100000 kobo
mandate -> 00 pending_authorisation, cap 6010230
authorise -> active
try 1 -> 51 (Insufficient funds), status failed
with late fee -> 61 (Transfer limit exceeded), status failed
try 2 -> 00 (Approved or completed successfully), status successful
resend try 2 -> 26 (Duplicate record), status successful
attempts on the switch
L000043-I2-T1 6010230 51 failed
L000043-I2-T1F 6110230 61 failed
L000043-I2-T2 6010230 00 successful
settlement -> inward 6010230, outward 30690000, net -24679770Try 1 is refused with 51: the payer’s account is empty (the script forces it with X-Mock-Force: nsf). The debit for the instalment plus the late fee, 6,010,230 + 100,000 = 6,110,230 kobo, is over the cap and is refused with 61, whatever the balance. Try 2 carries a new reference and is approved. Sending try 2 again returns 26 with status successful, the first attempt’s outcome, and nothing new is collected: that is why GET /debits lists three attempts, not four. The settlement line is 6,010,230 − 30,690,000 = −24,679,770 kobo: the switch’s net position for the day is out by ₦246,797.70 because of the payout in step 3 and the one instalment collected.
5. Collect by saved card: a soft decline, a retry and a hard failure. The first instalment of a BNPL loan is charged at checkout and the card is saved. Instalment 2 is charged with the saved card’s authorization_code, with the provider forced to decline for insufficient funds, and again after the decline is switched off. A second loan’s card (test card 0007) expires at the end of this month, and is billed on the first of next month.
python3 - <<'PY'
import datetime as dt
import json
import sqlite3
import urllib.error
import urllib.request
BASE, KEY = "http://127.0.0.1:8101", "sk_test_owoleaf_mock"
def call(method, path, body=None):
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
data = json.dumps(body).encode() if method == "POST" else None
req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
def charge(label, body):
out = call("POST", "/charges", body)
ch = out.get("charge", out)
print(f"{label:<14} -> {ch.get('status', out.get('error'))}"
f"{' ' + str(ch['decline_code']) if ch.get('decline_code') else ''}"
f" amount {ch.get('amount_kobo', '-')}"
f"{' provider fee ' + str(ch['fee_kobo']) if ch.get('status') == 'success' else ''}")
return ch
call("POST", "/admin/reset", {}) # an empty provider
call("POST", "/admin/faults", {"decline_rate": 0})
con = sqlite3.connect("data/finance.sqlite")
def bnpl(loan_id):
ref, = con.execute("SELECT c.ref FROM loans l JOIN customers c ON c.id = l.customer_id WHERE l.id = ?", (loan_id,)).fetchone()
rows = con.execute("SELECT instalment, due_date, total_kobo FROM schedule WHERE loan_id = ? ORDER BY instalment", (loan_id,)).fetchall()
return ref, rows
# Loan A: the card is saved with the first instalment, at checkout (test card 0001 succeeds).
ref, sched = bnpl("L000030")
print(f"L000030 {ref}: " + ", ".join(f"{i}: {d} {t}" for i, d, t in sched))
first = charge("1 at checkout", {"reference": "L000030-I1-T1", "amount_kobo": sched[0][2], "customer_ref": ref,
"card_number": "5060990000000001", "save_card": True})
code = first["authorization"]["authorization_code"]
print(f"saved card: last4 {first['authorization']['card_last4']}, reusable {first['authorization']['reusable']}")
def renew(label, loan_ref, inst, due, amount, tries, auth):
return charge(label, {"reference": f"{loan_ref}-I{inst}-T{tries}", "amount_kobo": amount, "customer_ref": ref_of[loan_ref],
"authorization_code": auth, "billing_date": due})
ref_of = {"L000030": ref}
call("POST", "/admin/faults", {"decline_rate": 1}) # the payer is short on the day
renew("2, try 1", "L000030", 2, sched[1][1], sched[1][2], 1, code)
call("POST", "/admin/faults", {"decline_rate": 0}) # funds arrive; try again, new reference
renew("2, try 2", "L000030", 2, sched[1][1], sched[1][2], 2, code)
# Loan B: a card (test card 0007) that expires at the end of this month, billed on the 1st of next month.
next_month = (dt.date.today().replace(day=28) + dt.timedelta(days=4)).replace(day=1).isoformat()
ref_b, sched_b = bnpl("L000135")
ref_of["L000135"] = ref_b
print(f"L000135 {ref_b}: instalment 1 {sched_b[0][2]}, instalment 2 {sched_b[1][2]}")
first_b = charge("1 at checkout", {"reference": "L000135-I1-T1", "amount_kobo": sched_b[0][2], "customer_ref": ref_b,
"card_number": "5060990000000007", "save_card": True})
print(f"saved card expires {first_b['authorization']['exp_month']}")
renew("2, try 1", "L000135", 2, next_month, sched_b[1][2], 1, first_b["authorization"]["authorization_code"])
PYL000030 C0000191: 1: 2026-05-24 800000, 2: 2026-06-07 800000, 3: 2026-06-21 800000, 4: 2026-07-05 800000
1 at checkout -> success amount 800000 provider fee 8000
saved card: last4 0001, reusable True
2, try 1 -> failed insufficient_funds amount 800000
2, try 2 -> success amount 800000 provider fee 8000
L000135 C0000758: instalment 1 700000, instalment 2 700000
1 at checkout -> success amount 700000 provider fee 7000
saved card expires 2026-11
2, try 1 -> failed expired_card amount 700000L000030 is ₦32,000 in four fortnightly instalments of 800,000 kobo (₦8,000). The saved card carries reusable True. Try 1 on instalment 2 fails with the soft decline insufficient_funds, and try 2, with a new reference, succeeds. The provider fee of 8,000 kobo is the mock’s 1%. The second card expires in 2026-11 (it will show the month you run this), and the next-month billing fails with expired_card: a hard failure that no retry can fix. The lender’s next step is a message asking for a new card, not another call. The provider shows no fee for a failed charge here, so a failed try is free in the lab and may not be in a real provider’s terms.
6. Price the rails. The costs are assumptions at the top of the script: the mock’s 1% for the card, and an invented flat ₦50 per direct-debit attempt. Change them and run again.
python3 - <<'PY'
# ILLUSTRATIVE assumptions, set here so you can change them. Integer kobo.
CARD_FEE_BPS = 100 # the mock provider's 1% of the amount (PROCESSOR_FEE_RATE), taken on a success
DEBIT_FEE_KOBO = 5_000 # an invented flat fee of 50 naira for each debit attempt, success or not
tickets = {"BNPL instalment (L000030)": 800_000, "PL instalment (L000043)": 6_010_230}
print(f"{'ticket':<27}{'rail':<14}{'attempts':>9}{'cost kobo':>10}{'naira per 1,000':>17}")
for name, amount in tickets.items():
for attempts in (1, 2):
card = amount * CARD_FEE_BPS // 10_000 # only the successful attempt pays the card fee
debit = DEBIT_FEE_KOBO * attempts # every attempt pays the flat fee
for rail, cost in (("card", card), ("direct debit", debit)):
print(f"{name:<27}{rail:<14}{attempts:>9}{cost:>10}{cost * 1000 / amount:>17.2f}")
PYticket rail attempts cost kobo naira per 1,000
BNPL instalment (L000030) card 1 8000 10.00
BNPL instalment (L000030) direct debit 1 5000 6.25
BNPL instalment (L000030) card 2 8000 10.00
BNPL instalment (L000030) direct debit 2 10000 12.50
PL instalment (L000043) card 1 60102 10.00
PL instalment (L000043) direct debit 1 5000 0.83
PL instalment (L000043) card 2 60102 10.00
PL instalment (L000043) direct debit 2 10000 1.66Redo one row by hand: ₦8,000 on a card at 1% costs 800,000 × 100 ÷ 10,000 = 8,000 kobo, ₦80, which is ₦10 per ₦1,000. A flat ₦50 on the same ₦8,000 is ₦6.25 per ₦1,000, and on the ₦60,102.30 instalment it is ₦0.83. The flat fee wins on the large instalment and costs more per naira on the small one once it needs two attempts (₦12.50 against ₦10). The card rail pays only on the success, in this model. A real provider’s terms for a failed charge decide whether that holds. The fees are invented: put your own contract’s in before you rely on a comparison.
Reuse a reference on the retry, as Akpofure’s job did. This script debits a new mandate on Monday with a forced 51 and again on Tuesday with the same reference:
python3 - <<'PY'
import datetime as dt
import json
import urllib.error
import urllib.request
BASE, KEY = "http://127.0.0.1:8102", "sw_test_owoleaf_mock"
def call(method, path, body=None, force=None):
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
if force:
headers["X-Mock-Force"] = force
data = json.dumps(body).encode() if method == "POST" else None
req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
today = dt.date.today()
m = call("POST", "/mandates", {"reference": "OWL-MND-BREAK-0001", "payer_bank": "B03", "payer_account": "2100000233",
"max_amount_kobo": 6_010_230, "frequency": "monthly", "start_date": today.isoformat(),
"end_date": (today + dt.timedelta(days=200)).isoformat(), "customer_ref": "C0000233"})
mid = m["mandate_id"]
call("POST", f"/admin/mandates/{mid}/authorise", {})
for label, force in (("monday", "nsf"), ("tuesday, same reference", None)):
d = call("POST", "/debits", {"mandate_id": mid, "reference": "OWL-DD-BREAK-0001", "amount_kobo": 6_010_230}, force)
print(f"{label:<24} -> {d['response_code']} ({d['response_message']}), status {d['status']}")
settled = call("GET", "/settlement")["inward_kobo"]
print(f"inward on the switch: {settled}")
PYYou get this:
monday -> 51 (Insufficient funds), status failed
tuesday, same reference -> 26 (Duplicate record), status failed
inward on the switch: 6010230The Tuesday attempt is not an attempt. The switch answers 26 with the first attempt’s status, failed, and the inward total is the same 6,010,230 kobo as after step 4: nothing was collected. A job that records “retry 1 failed” has recorded a refusal to try. Change the reference to carry the try number, as step 4 does (-T1, -T2), and run it again. Then decide what the collector should do when it sees a 26 with status failed: treat it as a bug in the collector, and alert.
Template
# Repayment collection runbook: <product> on <rail>, <company>
Written by <role>. Signed by <role>. Version <n>, <date>. Reviewed against <rules and mandate terms>, <date>.
## 1. Methods, in the order they are tried
| Order | Method | Permission it rests on | Cap or limit | Who owns it |
## 2. Retry schedule
Try 1: <when>. Try 2: <when>. Try 3: <when>. Limit: <n> tries, then <what happens>.
Reference format: <loan>-<instalment>-<try>. A reused reference is a bug.
## 3. What happens on each failure code
| Code | Meaning | Retry? | Action | Owner |
## 4. Reconciliation
Compared each <day>: <record A> against <record B>. Expected difference: <₦ amount>. A difference goes to <owner> by <time>.
## 5. Customer messages
| Trigger | Channel | Wording (short) | Sent by | Owner |
## 6. How this could be wrong
<one way, and what would show it>
## 7. Decision and sign-off
Decision needed: <what, from whom, by when>. Out of scope: <what this runbook does not cover>.
Written <name, date>. Approved <name, date>. WORKED EXAMPLE
Akpofure, who owns the repayment job at Owoleaf, writes this runbook and Owoleaf’s head of lending operations signs it. It covers personal-loan direct debits, using L000043 instalment 2: ₦60,102.30, due Wednesday 19 August 2026, under a mandate capped at ₦60,102.30.
Methods. 1. Direct debit at 08:00 on the due date. 2. After the last try, or on 61 or 63, a person asks for a new mandate. GSI is a last resort for the creditor bank, out of scope.
Schedule (assumed). Try 1 on 19 August, try 2 on Monday 24 August, try 3 on Friday 28 August, when Salamatu at Northmere says salaries usually land. Three tries, then a person. References L000043-I2-T1, -T2, -T3.
Codes. 51: the collector retries on the next date. 61: stop, collections operations acts; the ₦61,102.30 debit (instalment plus the ₦1,000 late fee) was over the cap, so collect the fee another way only if the contract allows. 63: stop, collections operations asks for a new mandate. 26 with status failed: a collector bug, so alert Akpofure.
Reconciliation (assumed timing). Each evening, the collector’s attempts against the switch’s list. In the lab the collector sent four debits and the switch lists three, because the resend of try 2 got 26; that is the expected difference. Inward was ₦60,102.30, collected once. Any other gap goes to the lending ledger owner by 10:00.
Messages. On a 51 or 61 the collector sends an SMS, owned by Akpofure. Same day is Owoleaf’s own choice. The CBN’s Regulation for Direct Debit Scheme in Nigeria, 2018 (revised), per search summaries, says (clause 2.1.14, as quoted in a search result) that a biller must notify the payer by SMS or email of a failed direct debit, with no deadline found for that notice, and that the biller’s bank accepts cancellation of a mandate only from the biller. A 24-hour period in the summaries is about something else: the biller’s bank may re-present an unpaid instruction within 24 hours or as agreed with the payer. This build could not open the PDF, and the searches did not confirm that the 2018 text is still the current oneas of 2026-11
Could be wrong. The retry days are assumed. A mandate or rule allowing fewer tries would show it.
Decision. The head of lending operations approves three tries and the pay-day date. Collections conduct is out of scope.
Now you
You are the collections operations analyst at a buy-now-pay-later lender in Lagos with 40 staff, and your head of collections signs what you write. Write the runbook for BNPL instalments collected on a saved card. Use the lab’s step 5 and step 6 outputs. L000030 is four fortnightly instalments of ₦8,000. Its try 1 on instalment 2 fails with the soft decline insufficient_funds and try 2, with a new reference, succeeds with a provider fee of ₦80 (the lab’s invented 1%). L000135, a ₦7,000 instalment, fails with the hard expired_card. Decide the order of methods, the retry days and limit, what each failure leads to and who acts, what you compare each day (your ledger against the provider’s list of charges), and what the borrower is told and by whom. Say which numbers are assumptions. Your head of collections reads it to decide how many tries a card gets and when a person steps in.
Self-check
Owoleaf has 200 people. Its personal-loan debits go out at 08:00 on each instalment's due date, and most of the first attempts on the 25th return 51. Akpofure can change the collector this week. Salamatu at Northmere says the customers' salaries mostly arrive on the 28th. The loan contracts fix due dates from the day of disbursement. What do you change first?
- DOC Operational Guidelines on Global Standing Instruction (GSI): Individuals (CBN, 2020) Central Bank of Nigeria, 2020
The regulator's own text on recovering a loan from a borrower's accounts across banks. Read the sections on the mandate, the exclusion of penal charges and restricted accounts. This chapter's account rests on search summaries, so check each point here before you build on it.
- DOC Regulation for Direct Debit Scheme in Nigeria, 2018 (revised) (CBN) Central Bank of Nigeria, 2018
The rule behind a lender's mandate: the biller's duties, cancellation and the notice after a failed debit. Read the biller sections first. Check whether it is still the current text before you rely on it.
- DOC Guidelines for the Direct Debit Scheme and Bill Payments in Nigeria (CBN, 2017) Central Bank of Nigeria, 2017
The earlier text, which search results show as an exposure draft of January 2017. Read it beside the 2018 Regulation to see what changed on arrears and re-presentment. Treat it as superseded until you have checked.
- DOC Regulation on Instant (Inter-Bank) Electronic Funds Transfer Services in Nigeria (CBN, 2018) Central Bank of Nigeria, 2018
The rule behind a payout: name enquiry and settlement. Read it to see what a lender can and cannot expect when a disbursement answers 09.
- DOC Recurring Charges (Paystack documentation) Paystack, 2026
A vendor's design for charging a saved card: the authorization code and its reusable flag. A vendor's description, not a rule. Read it to compare its fields with the mock provider's.
- DOC Receiving payments with NIBSS direct debit (Lendsqr documentation) Lendsqr, 2026
A lending-software vendor's account of how a lender collects by e-mandate. A vendor's claim, not the scheme's text. Read it for the lender's view of activation and the limits on a mandate, and take the details from the scheme's own documents.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.