Skip to content

About

Command-line simulation of Tanzania's M-PESA mobile-money service, written in C++17.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

M-Pesa Simulation

A cross-platform command-line simulation of Tanzania's M-PESA mobile-money service, written in C++17. It walks through the day-to-day flows a real M-PESA customer would recognise — sending money, buying airtime, paying bills, taking out a mobile loan, QR payments, mini statements, and so on — on top of a single local data file so the account survives between runs.

This is a learning / teaching project. It is not connected to any real mobile-money network.

Features

  • First-run account setup (name, phone number, region, 4-digit PIN, optional security question for PIN recovery).
  • PIN verification on start-up with a 3-attempt limit and a security-question recovery path.
  • Send money, buy airtime, withdraw cash (agent or ATM), Lipa na M-PESA, QR payments, and bill payments (TANESCO, DAWASCO, TV, internet, GePG).
  • M-PESA fee schedule with the 10% government levy shown as a breakdown.
  • Mobile loans with a credit-score-based limit, 10% interest, and a 30-day due date computed with real calendar arithmetic.
  • Mini statement and full recent-transaction view.
  • Top up the account from a (simulated) bank, agent, card, or mobile-banking source, including basic card-detail validation.
  • Persistent state in a local mpesa_data.txt file. The stored PIN is hashed (FNV-1a with a fixed salt) — not cryptographically secure, but it keeps the raw PIN out of the file. Legacy plaintext data files are migrated automatically on load.
  • Network-provider lookup for Tanzanian prefixes (Vodacom, Airtel, Halotel, Tigo/MIC, Zantel, TTCL, Smile, Viettel, etc.).

Requirements

  • A C++17 compiler (g++ 7+ or clang++ 5+).
  • make (optional — you can also use the raw compile scripts below).

Building

Linux / macOS

make            # builds ./mpesa_sim
make run        # builds and runs
make clean

Or without make:

./build.sh          # compile
./build.sh run      # compile and run

Windows (MinGW / MSYS2)

compile_and_run.bat

This produces mpesa_sim.exe and runs it. Alternatively, with make available the same make / make run targets work on Windows.

Running

./mpesa_sim        # Linux/macOS
mpesa_sim.exe      # Windows

On first launch the program walks you through account creation. Subsequent launches prompt for your PIN. The menu is numeric:

1.  Send Money            8.  Mobile Loans
2.  Buy Airtime           9.  QR Payment
3.  Withdraw Cash         10. Mini Statement
4.  Lipa na M-PESA        11. Top Up Account
5.  My Account            12. Help
6.  Settings              13. Exit
7.  Bill Payment

Data storage

All state is kept in mpesa_data.txt in the working directory. Delete it to start over with a clean account. The file is listed in .gitignore so it never ends up in commits.

Project layout

mpesa.h            Public declarations (structs + function prototypes)
main.cpp           Entry point, PIN verification and recovery
menu.cpp           Main menu and Settings submenu
transactions.cpp   Send / buy / withdraw / Lipa / bill / QR / loans
userdata.cpp       Persistence, new-user flow, account & mini-statement views
utils.cpp          Shared helpers: formatting, hashing, fees, processing UI
network.cpp        Tanzanian prefix → network-provider lookup

Continuous integration

Every push and pull request on main is built on Ubuntu with g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror -O2 via the workflow in .github/workflows/c-cpp.yml.

Author

Maximillian Urio — github.com/airiermonster

For support in the simulated "production" experience: 0762814092 (Vodacom) / 0683346262 (Airtel).

About

Command-line simulation of Tanzania's M-PESA mobile-money service, written in C++17.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages