Advertisement
Local News

Mpesa API Integration: Step-by-Step Guide to Integrating Lipa na Mpesa Online

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.

Lipa Na Mpesa Online

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.

Advertisement

Requirements to accept Lipa na Mpesa Online

  1. You should have a Paybill account. To apply for a paybill account, sent an empty email to [email protected]
  2. A Safaricom developer account. You can visit Safaricom developer’s portal and register an account for free if you do not have one.
  3. Any programming knowledge (PHP, JavaScript, Python e.t.c). If you don’t any programming skills, you can hire here a Mpesa integration expert.
  4. A website, App, or Point of Sale or any other.

Step-by-Step Guide to Integrating Mpesa to a Website, App or System

Step 1: Create an account on Mpesa G2 Portal

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.

  • To get an account on Mpesa G2 portal send an email to [email protected] or call 0722002222 and request Safaricom to setup Mpesa G2 portal for you.
  • Login to the portal and go to “Operator management”
  • Create a user with the name “Business Manager”
  • Set phone number (not email) to get notification via SMS.

Step 2: Create an App on Mpesa Developer portal

Go to Mpesa Developer Portal and register for an account

Create an app

The app will be used to access the Mpesa API

Step 3: Write C2B, B2C or B2B code

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 . 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.

Step 4: Go live

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.

  • Go to developer portal and “Go live”
  • You will be required to verify that you are the actual owner of the API before going live.
  • The first step for verification is to upload the test case.
  • The second step is to fill in the company details. The following substeps will guide you on how to fill the forms.
  • Verification Type: Short Code
  • Organization Name: Enter your pay bill or till name
  • Organization Short Code: Enter either your pay bill number
  • Mpesa User Name: use the name you created in step 2
  • You will receive an OTP to the number you registered in step 1
  • Enter the received password and click Submit
  • Tick all the check and key in the OTP then click “Submit”
  • Switch to the live app and use the live app’s secret code written in step 2 and Consumer Keys

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.

Tambua Africa Reporter

Blogger and news writer at Tambua Africa News.

Related Articles

Hi! Post Your Comment Here.

Back to top button

Adblock Detected

Kindly Allow Ads to view this page.