M-pesa payments API

3,142 views
Skip to first unread message

Ephra Swilla

unread,
Jul 20, 2013, 2:32:22 PM7/20/13
to GTUG
Hi guys,

How can I allow users to make payments online on a website using m-pesa, tigopesa or airtel money ?

Is there any API just like paypal  API that can allow to create application that allow such payment method?

Any help please.

Nice times

Jackson Isack

unread,
Jul 20, 2013, 2:46:26 PM7/20/13
to Ephra Swilla, GTUG
Hi,
I think this question has already been asked in this group. Anyway, as far as I know, there isn't any API for MPESA available in public. But solution I can across with.... is follow up and have your own M-PESA disbursal account, with which you can collect payments. which is still a manual work. So far, don't think if there is any automatic means of doing that.



--
You received this message because you are subscribed to the Google Groups "Google Developer Group(GDG) Dar es Salaam " group.
To unsubscribe from this group and stop receiving emails from it, send an email to dargtug+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jackson Isack Mrema
IT & E-Learning Consultant
PO Box 25420

Given Edward

unread,
Jul 21, 2013, 1:54:18 AM7/21/13
to dar...@googlegroups.com, Ephra Swilla
There isn't an API yet. I once asked Vodacom if they will create one and they told me straight NO.

Machaku Banga

unread,
Jul 21, 2013, 5:21:57 AM7/21/13
to Jackson Isack, Ephra Swilla, GTUG
There is no any official API and I don't think mobile operators will release one within this decade. But you can automate things in unofficial/dirty way.

Its a bit tricky
  • Push all incoming *pesa/money messages to the server
  • Parse them (* pesa/money messages) to extract important details like amount, sender, transaction ID and more
  • Validate transactions then do your things.


--------------------------------

Ephra Swilla

unread,
Jul 21, 2013, 6:15:38 AM7/21/13
to Machaku Banga, Jackson Isack, GTUG
Thanks guys,

you give me a nice solution. I will do as you say but for feature I think we have to do it for we developers to benefit from it.

Thanks and nice times


From: Machaku Banga <bmac...@gmail.com>
To: Jackson Isack <jackso...@gmail.com>
Cc: Ephra Swilla <swi...@yahoo.com>; GTUG <dar...@googlegroups.com>
Sent: Sunday, July 21, 2013 12:21 PM
Subject: Re: [Google Developer Group(GDG) Dar es Salaam ] M-pesa payments API

TGH Solutions

unread,
Jul 22, 2013, 1:30:36 AM7/22/13
to Ephra Swilla, Machaku Banga, Jackson Isack, GTUG
I am aware that there is a Voda API to do all this. However, the right to this feature is given to a specific company in Dar (don't know who) and the surcharge is a 100/= PER transaction. Airtel has an API as well but to get the code and security token is very difficult. Don't know anything about tigo.
--
TGH Solutions
+255 784 535525
Stationery & Office Supplies
Computers and Accessories
CCTV Consulting and Installation
Sales & Inventory Software

TGH Solutions

unread,
Jul 22, 2013, 4:32:56 AM7/22/13
to Tony Severine, Dar es Salaam GTUG, Machaku Banga, Ephra Swilla, Jackson Isack
Voda will just refer you to the IT company after you sign the business account agreement with them.

Airtel the same, after your contract is signed.


On Mon, Jul 22, 2013 at 8:38 AM, Tony Severine <to...@eightgigconsulting.com> wrote:

Do you know the procedure to get access to the APIs you listed?

Tony
IT Consultant
8gig Consulting

Oscar Makala

unread,
Aug 2, 2013, 1:27:35 AM8/2/13
to TGH Solutions, Ephra Swilla, dar...@googlegroups.com, Machaku Banga, Jackson Isack, Tony Severine

vodacom does not have an mpesa api.their was a failed attempt to get it live. companies after getting a business account are given a web portal auth by browser certificates.solution is to create webscrappers to automate login and read contents in transaction histories page and push them to the app for collection.disbursment involves a more different process.those who are interested in the solution can contact me.and will see prospects of doing business.
tigo only offers a collection api by doing an xml over http post.same applies to airtel.they do not have a disbursment solution

Michael Shaka

unread,
Oct 30, 2013, 8:06:58 AM10/30/13
to dar...@googlegroups.com, Jackson Isack, Ephra Swilla
i agree with machaku, there isn't an official API for reading the transactions online, but you can implement it yourself
I am currently developing the automate response for mobile transactions and the drawback am experiencing is the time delay between the time the transaction was made and the time M-Pesa throws the xml response to my server. (5-10min). I suppose this is inevitable.

Oscar Makala

unread,
Oct 30, 2013, 8:18:10 AM10/30/13
to Michael Shaka, Ephra Swilla, Jackson Isack, dar...@googlegroups.com

news flash...vodacom now has a collection api.disbursment still not out

--

Josephat O. Oroma

unread,
Oct 30, 2013, 10:07:12 AM10/30/13
to Oscar Makala, Michael Shaka, Ephra Swilla, Jackson Isack, dar...@googlegroups.com
Hi All,

Am surprised that non of you have heard about Pesapal. Using this system, you can actually accept Vodacom M-Pesa payments from a mobile phone into your website and direct into your bank account. Its available in Uganda (MTN and Airtel Money), Tanzania (M-Pesa and Airtel Money) and also in Kenya (Saffaricom M-Pesa, Airtel Money and Yu cash).

Read more info on www.pesapal.com


Josephat O. Oroma
--
Josephat Oling Oroma
Doctoral Student, in Computer Science
University of Eastern Finland



Nicky Mlelwa

unread,
Oct 30, 2013, 9:43:56 AM10/30/13
to Oscar Makala, Michael Shaka, Ephra Swilla, Jackson Isack, dar...@googlegroups.com
Thanks for info Oscar.

Have you tested it already?

Can you give some comments about it.


On Wed, Oct 30, 2013 at 3:18 PM, Oscar Makala <makal...@gmail.com> wrote:

Abdulaziz Abdulaziz

unread,
Oct 30, 2013, 10:01:28 AM10/30/13
to Oscar Makala, Michael Shaka, Ephra Swilla, Jackson Isack, dargtug


On Wed, Oct 30, 2013 at 3:18 PM, Oscar Makala <makal...@gmail.com> wrote:



--
Thank You .
Yours Sincerely ,
Abdulaziz Abdulaziz,
Software Engineer .

"Everybody should learn how to program a computer ... because it teaches you how to think." 
- Steve Jobs

Jackson Isack

unread,
Oct 30, 2013, 11:02:48 AM10/30/13
to Josephat O. Oroma, Oscar Makala, Michael Shaka, Ephra Swilla, GTUG

On Wed, Oct 30, 2013 at 5:07 PM, Josephat O. Oroma <josepha...@gmail.com> wrote:
Pes

Just another input. Kopokopo are now in Tanzania. https://app.kopokopo.com/users/sign_in They so far accept MPesa and Tigo Pesa. (Airtel money on way). Been using this for months and its working perfect.
They have API which will push every transaction taken place to url you specified. They also have options to transfer money to your Bank acc or Mpesa/Tigo Pesa acc and so on.
If need help how to set it up, contact me.

Martin Mendrad

unread,
Jan 17, 2014, 3:54:26 AM1/17/14
to dar...@googlegroups.com, Jackson Isack, Ephra Swilla
can you plz tell how to push that sms to the server?

Rutaihwa

unread,
Jan 18, 2014, 3:32:41 AM1/18/14
to dar...@googlegroups.com
Hi,

Take the sms as a JSON object, and when you have it, you can do amazing things with it.
I take it you want to take to your database and analyse it.
That will be the same way you handle other objects in your system.
--
You received this message because you are subscribed to the Google Groups "Google Developer Group(GDG) Dar es Salaam " group.
To unsubscribe from this group and stop receiving emails from it, send an email to dargtug+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
La patrie ou la mort nous vaincrons.

Ephra Swilla

unread,
Jan 20, 2014, 11:42:36 AM1/20/14
to Machaku Banga, Martin Mendrad, Dar es Salaam Google Technology User Group(GTUG), Jackson Isack
Hi guys

Starting an open source project is the best idea to implement as we programmers from Tanzania. 
Mobile payment for online application is still demanding and is a feature strategy that we software
developers should focus upon.

Me and my company have been planning to do this project (even though not yet started) that will combine all network providers in Tanzania and provide an API to other developers, but making the open source project is the best idea together that will let a team of more developers to join and contribute to develop a best solution to be used now and for feature.

I will be glad if Tanzania programmers could join together all as one team and create a solution that will be a pride for Tanzania and Africa in general.

I would like to hear more from other guys about this OPEN SOURCE PROJECT concept for online mobile payments. Let us share our views and say YES for this or NO (with reasons) for this idea.

cheers.


On Monday, January 20, 2014 6:54 PM, Machaku Banga <bmac...@gmail.com> wrote:
How do you do all of these!?
  • Push all incoming *pesa/money messages to the server..!!
  • Use device/platform/software which has API for SMS events or database, Telephony services and Networking (eg HTTP requests). Retrieve the SMS text, SMS metadata, requesting account balance, etc then send whatever you want to your server via HTTP or whatever protocol that suits you. For example you can use Android tablet or smartphone for this task. Android has a very open and powerful API.
  • Parse them (* pesa/money messages) to extract important details like amount, sender, transaction ID and more.
  •  You can use XML parser, JSON parser, YAML parser, regex, string manipulation techniques, etc depending on the content type, etc  
  • Validate transactions then do your things.
  • You have validate the obtained data to make sure is genuine, contains all required attributes, etc... like validating user input from a web form. Then ......
Also as @Oscar Makala suggested, I think if you have business account and if the Portal Pages allows scrapping, you can use a web scrapper.

If you have a questions, challenge, comment, security flaw or you think something is wrong with these approaches please share it the group, it will be useful to all of us.

I haven't tried to build the  *pesa/moneAPI/service because I didn't have a strong reason and time, but I think I can do that. I wounder, if I do this and provide it as a service, will anyone be willing to Pay for it...???? How much???? Are there other more convenient services???? or should we start an Open Source project????

Cheers!!!


--

Jervis Muindi

unread,
Jan 20, 2014, 2:55:19 PM1/20/14
to Ephra Swilla, Martin Mendrad, Machaku Banga, Dar es Salaam Google Technology User Group(GTUG), Jackson Isack

Hello,

I think developing a standard API to MPESA and other such mobile payment systems is an excellent idea. Frankly I am a bit surprised that the telecommunication companies have not done this or somthing like it themselves. 

Making the project open-source is also nice as it allows us to collectively work together to solve this problem as I'd imagine there will be a number of technical hurdles to overcome. Ideally the solution would be simple enough such that anyone should be able to adopt it and use it.

With the caveat that I have never actually used MPESA here are my thoughts on the problem:

From what I understood of the suggestion by @Banga, it seems like the onus is on the user to initiate payment, which generates an SMS message that's eventually received, parsed and processed on the server. This is a good approach and for an initial implementation, it's probably the way to go.

That said, it did occur to me that there is a bit of friction in the process for the user. Specifically, they have to get the transaction details right each time they buy something. An improvement of the approach would be something like this: 

* User Bob visits site X and wants to buy item Y

* Site X lookups Bob's phone number and sends him/her a payment request to deliver the requested goods / service

* Bob receives the message and responds YES / NO to the request. A non-response is also considered as a NO. 

* Site X processes Bob's reply and then responds accordingly. 

As I stated, I don't have actual experience with MPESA so I don't know if the above scenario is technically possible (i.e. can a user request payment from another user, and can the receiving user of that payment request just respond with a YES/NO?), but it will help simplify the transaction flow from the user's perspective.


- Jervis

Sent on the go.
   

Jessen Mutta

unread,
Jan 21, 2014, 12:50:49 AM1/21/14
to Jervis Muindi, Ephra Swilla, Machaku Banga, Martin Mendrad, Dar es Salaam Google Technology User Group(GTUG), Jackson Isack

Hello,
That's a good idea. I would also suggest you to chek on a system called Centili, it offers a mobile payment but for virtual goods only.. we can use their idea to implement our system.

Machaku Banga

unread,
Jan 21, 2014, 3:54:29 AM1/21/14
to Jessen Mutta, Jervis Muindi, Ephra Swilla, Martin Mendrad, Dar es Salaam Google Technology User Group(GTUG), Jackson Isack
A site/service can include user profile which also includes a user's phone number/s for payment and basic accounting functionality.  So whenever payment is detected, parsed and validated, and its from users number it will be recorded under user's financial account within the service. Also you include an option for user to submit transaction ID & service provider through a web-form, SMS or whatever, then you can check if that transaction is available in your records.
Therefore, only thing that user has to do is, either register his/her phone number or submit a transaction ID. Also there may be an administrator web interface for manual  override.
 
Also on the server side you may need a collection/database of samples of all * Pesa/Money receipts. Each entry in a collection, may include respective service provider ID/number, something like REGEX which can be used to extracting content of interest from  the message text, eg, transaction ID, amount and other details from the message body. REGEX stands for Regular Expressions, it is a fairly powerful technique for parsing strings and it is available in almost every sane programming language. 






Bryan Fawcett

unread,
Jan 23, 2014, 4:08:15 AM1/23/14
to dar...@googlegroups.com, Ephra Swilla
Hi Guys,

here is an app


it's done through mobile banking.

mic...@pluspeople.dk

unread,
Oct 18, 2014, 6:16:32 AM10/18/14
to dar...@googlegroups.com, swi...@yahoo.com, mendra...@gmail.com, bmac...@gmail.com, jackso...@gmail.com
Hi Everyone,

I wanted to point everyone's attention to PesaPi ( http://www.pesapi.com ).
It's an open source mobile money middleware - essentially it is the missing API you are talking about, only it works across multiple mobile money systems and not just one specific.

In Tanzania it supports MPESA & Tigo systems - help in extending this to more systems are most welcome.

Finally it should be mentioned that it is released under BSD(Lite) license, this means you are welcome to use it for any purpose even commercially or embedded in your own products.
(Full disclosure: I'm one of the developers of PesaPi)

..
Mike
Reply all
Reply to author
Forward
0 new messages