Mpesa is a mobile payment service offered by Safaricom to its Subscribers in Kenya and Tanzania. It was launched in 2007 and has won the masses over the years. Mpesa allows you to deposit, withdraw, send money, buy airtime and borrow a loan from M-Shwari or Fuliza service. On the same note, you can pay for goods or services via Paybill or buy goods till number. Almost every business organization has a Lipa na Mpesa till number or Paybill number to accept payments from customers and other business organizations.
This guide provides a step by step process to Lipa na Mpesa integration for your website, mobile application, point of sale or any other software systems for you to accept payments via Mpesa.
Recently, Safaricom introduced a new Safaricom Mpesa API dubbed ‘The Daraja API’ to enable developers to integrate Safaricom payment for Business to Customers (B2C), Customers to business (C2B) and Business to Business (B2B).
To accept Lipa na Mpesa online, you should have a checkout button in your website, app or system which the user can click to pay for the goods or services that you offer. When a user clicks the button, it triggers a post request to Daraja having the relevant payload amount. Daraja processes the request and sends an STK push to the user’s phone prompting him or her to enter M-Pesa password and click OK to complete the transaction. M-Pesa processes the request by debiting the user’s account and sending a webhook with the details for the transaction to your servers.
Accessing pay bill and till number transactions require you to have an account on Mpesa G2 Portal. Creating an account on Mpesa G2 Portal will enable you to create a user who will be sent a One Time Password (OTP) that you can use to test if Mpesa API integration is a success.
Mpesa API integration requires windows internet explorer browser with a certificate from Safaricom to setup the Mpesa portal. To request a certificate, send a blank email to [email protected]
Safaricom will respond to the email automatically with a link for you to request a certificate. Click on the link to install the certificate in Windows Internet Explorer.
Note: You can use chrome to continue the process once you have installed the certificate.
Go to Mpesa Developer Portal and register for an account
Create an app
The app will be used to access the Mpesa API
The third step is where it gets juicy. You have to write the code for handling all the transaction. You can use any language that you are comfortable with when writing the code. Check the article Demystifying the M-Pesa API to learn how to write a code to handle transactions. If you are not a developer you can hire an API expert from Shara Solutions. Go to Mpesa API Integration Service to hire a developer.
A Mpesa API developer will go through all the steps provided in this tutorial and do all the process for you. All that you will be required to do is apply for Paybill account only and the developers will take care of the rest.
The fourth step in Mpesa API integration is to go live. Before you go live, ensure that your code runs properly to be testing the code.
Once you have done this, enter the URL endpoints to the action button which a customer will click on your website, app or system. Test if the integration was a success by clicking on the button to initiate payments and pay before making your site or app live for customers to make payments.
Want to integrate Mpesa to your website? Go to Mpesa API Integration Service to get a quote