What is live and what is not
RanaWallet is a wallet for buying electricity for mini-grid prepaid meters. The mobile app and the website are live. The USSD and SMS channel described here is built and tested against a simulator of the telecoms aggregator, and it is switched off. It stays off until the aggregator agreement and approvals are in place and a purchase has passed end to end on a real handset on each mobile network.
So this note reports a design and its tests, not field results. We have no usage figures for USSD and give none.
Design for the phone in the customer’s hand
A feature phone shows plain text and takes digits. Three rules follow, and the code checks them when it loads:
- Every screen is at most 160 characters. Only the screens that carry the terms summary may run longer.
- Every screen is plain ASCII. Hausa hooked letters are written as b, d and k, because some handsets garble other characters or refuse the screen.
- Every screen exists in English and Hausa, with the same options in the same order.
The Hausa text is still a draft. Each string is marked for review by a native speaker before launch.
The main menu has seven numbered options: buy electricity, check balance, add money, get my last token, recent purchases, change PIN and language. On every screen, 0 means back or cancel and # returns to the main menu.
A session that asks and does not wait
A USSD session is short, and the network can drop it at any moment. A token purchase can be slow, because the token comes from the meter vendor’s vending service and that call can be retried.
The channel therefore records what the customer wants and does not carry it out inside the session. The customer picks a saved meter or types a meter number, sees the meter holder’s initials and the operator, enters the total to pay and confirms with a PIN. The reply is immediate: “Request received. Your token will come by SMS.” The purchase itself runs in a background worker.
The only outside call made during the session is the meter check at the start, and it has a time limit. Session state lives in a short-lived store and expires 120 seconds after the last input by default. If the session is lost, the customer dials again. A session that ends before the confirm step charges nothing.
One purchase, however many times the network repeats itself
Aggregators resend callbacks, and customers redial when a reply does not arrive. Neither may cause a second debit.
Each purchase gets one reference, built from the customer and the session, and the same reference names the queued job. A repeated callback is answered from the stored reply with no side effect, so a repeated confirm is not a second purchase. A redial for the same meter and amount while the first purchase is in flight is told that a purchase is already in progress.
A second check looks across channels. If the same customer recently bought the same meter and face value in the app, USSD does not queue another purchase. It tells the customer to check the app or their messages. If that check cannot run, the channel refuses the purchase.
SMS as receipt, fallback and proof
A feature phone cannot show a token in an app, so the token SMS is part of the purchase. The message carries the token, the units, the last four digits of the meter, the total paid, the electricity value, the fee and VAT, and a short reference. It doubles as the receipt and fits one plain-text segment. The token goes only to a verified phone number and is never written to logs.
Delivery reports from the aggregator mark each message delivered or failed. A failed token SMS is retried after 2, 10, 30 and then 120 minutes, up to a set limit. After that it sits in a failure queue for support staff, because that customer has paid and has no token on their phone. The customer can ask for it again from the menu, or by text.
SMS is also a way to buy. There are three text commands: BUY with a meter, amount and PIN, BAL with a PIN, and TOKEN with a PIN. A PIN sent by text stays in the phone’s sent folder, so BUY by text spends only on a meter already saved on the account.
When the money has moved and the token has not arrived
Sometimes the vendor’s answer is unclear: a timeout, or a reply that cannot be read. Reversing the debit at that point risks giving the money back for a token that was in fact issued.
RanaWallet holds these purchases. The wallet stays debited, the customer gets an SMS saying the purchase is being confirmed, and a reconciliation job asks the vendor what happened. A held purchase is never reversed only because time has passed. A confirmed failure is reversed in full, and the customer is told. The words “you were not charged” are used only when a purchase was refused before any debit.
A phone number is not a person
The network reports the caller’s number, and a SIM can be borrowed or swapped. A number alone therefore opens nothing. Every money action asks for a four-digit PIN, on a screen that says what the PIN will do. Two wrong PINs end the session, and repeated failures lock the PIN on USSD and SMS together.
A forgotten PIN cannot be reset over USSD. After a password reset by phone code, buying, adding money and changing the PIN are paused on these channels for a period, 24 hours by default, and the number receives an SMS saying so.
What stands between this and a live service
The remaining work is mostly not code. It includes real-handset tests on each network, native-speaker review of the Hausa, a way for a customer to ask for their data or withdraw consent from a basic phone, and drills for SMS failure and held purchases. The cost of a USSD session and of each SMS is not known until the aggregator’s rate card exists, so we do not quote one.
RanaWallet is described on the RanaWallet page, alongside our other work in energy.