Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

API for (mobile) commercial accounts

branch: master

Mpesa Private name-bug fixed

It turns out that Safaricom sometime have "misentered" the names of the subscribers (surprise).
The kind of mistype I have just seen is to use 0 instead of O - example "0RENGE" instead of "ORENGE".

I have updated the private mpesa accounts to support this kind of typo.
latest commit 67740b3cf4
Octocat-spinner-32 csharp PesaPi version 0.0.4 September 02, 2011
Octocat-spinner-32 java Version 0.1.0: October 14, 2011
Octocat-spinner-32 php Mpesa Private name-bug fixed March 29, 2014
Octocat-spinner-32 python restructuring in preperation for developer meetup July 15, 2011
Octocat-spinner-32 ruby restructuring in preperation for developer meetup July 15, 2011
Octocat-spinner-32 simulator added the database for the simulator July 17, 2011
Octocat-spinner-32 Airtel kenya support March 27, 2014
Octocat-spinner-32 changelog.txt Version 0.1.0: October 14, 2011
Octocat-spinner-32 database.sql TIGO Tanzania support added March 11, 2014


PesaPI is an unofficial open source API for mobile money systems, released under the BSD(lite) license.
The system currently support:

  • Kenya: Mpesa paybill accounts
  • Kenya: Mpesa private accounts
  • Kenya: Airtel private accounts
  • Kenya: Yu private accounts (experimental)
  • Ghana: Airtel private accounts (experimental)
  • Rwanda: MNT private accounts (experimental)
  • Tanzania: Mpesa private accounts
  • Tanzania: Tigo private accounts

The API supports both PUSH and PULL versions. The PHP version of the API is generally the most mature and recomended at this point - the system is build using Mysql and Curl. Please direct all questions to the public mailing-list "pesaPi" on Google-groups:

Short example

For a short usage example please see:

Current status

The current system should be considered as beta version - at least one commercial solution is using it as its payment gateway. However it is not recomended that you deploy the system without having a developer available to support the setup.

Version 0.1.0 was recently released and is contains a major rework of the internal structures of PesaPi - be alert that things that worked previously may not be fully working yet - as detailed testing is ongoing.

Currently we are looking for people to provide copies of the SMS messages they are getting from various payment systems.

System design overview

  • Supports both push and pull notifications.
  • Does synchroization between local and server database.
  • Transaction data are available even when main server is down.
  • Super easy to utilize for integrators.
  • Fast response on historical data.
  • Keep the load on servers as low as possible.
  • Hopefully more reliable than other APIs.

API Overview

The PesaPi class contains several static methods, these methods are the main interface.

  • availableBalance(time) -- returns the balance at a given point in time
  • locateByReceipt(receipt) -- returns a payment or null for the given receipt number
  • locateByPhone(phone, from, until) -- returns an array of payments from a particular phone
  • locateByName(name, from, until) -- returns an array of payments from a particular client name
  • locateByAccount(account, from, until) -- returns an array of payments from a particular account-no
  • locateByTimeInterval(from, until) -- returns an array of all payments within a given time interval

As an alternative you can ask PesaPi to call a your on your site when a new transaction is received (push mechanics).

Way forward

The following is a highlevel "todo" list for the project

  • Getting the code to release/production quality.
  • Getting more developers onboard.
  • Add support for more payment systems.
Something went wrong with that request. Please try again.