M-Pesa Integration

Introduction

M-Pesa is a virtual banking service that allows users to participate in financial transactions using their SIM cards. Once a SIM card is entered into a mobile phone, SMS messages are used to send and receive money.

M-Pesa was first introduced in Kenya as an alternative to the traditional brick-and-mortar set up. Being a digital tool, it is widely popular in over seven African nations as it speaks to financial inclusivity for marginalized and far-flung groups.

OpenG2P, in it's interoperable and modular approach, is able to easily integrate with M-Pesa to demonstrate the ease of access for its benefit delivery mechanism. The integration is done using an M-Pesa simulator. Here is the link to the simulator https://africastalking.com/

More information on M-Pesa can be found here https://www.investopedia.com/terms/m/mpesa.asp

Integration

An M-Pesa simulator is used for demonstration. It is a direct integration that doesn't involve a payment switch like Mojaloop.

How does the integration work? The M-Pesa account is mapped to the person's phone number. When payment is initiated from the OpenG2P system, the individual dials the USSD code from their phone, enters the mobile number to which their M-Pesa account is linked, and then checks their balance to see if they have received any money or pays their dues to a vendor who may also have an M-Pesa account.

This diagram here encapsulates the flow and components for an M-Pesa integration. It is assumed that MOSIP is the ID issuer here, and that the M-Pesa account is created at the time of issuance of ID, and is mapped to the person's phone number instantly.

Deployment

Instructions to deploy M-Pesa integration:

  1. Download the kube-config file from the rancher of a particular environment

  2. Set kube-config to that particular environment in your local dev environment

  3. Edit the config.yaml file with appropriate database location, username and password

  4. Edit the virtualService.yaml file with appropriate hostname.

  5. Run the below commands:

kubectl create ns mpesa
kubectl -n mpesa apply -f config.yaml
kubectl -n mpesa apply -f deployment.yaml
kubectl -n mpesa apply -f service.yaml
kubectl -n mpesa apply -f virtualservice.yaml

Demonstration

Here is a link to the slides which demonstrates payments to the M-Pesa simulator.

Source code

Click here to go to the program repository, under which all the M-Pesa functions and code can be found here.

Last updated

Logo

Copyright © 2024 OpenG2P. This work is licensed under Creative Commons Attribution International LicenseCC-BY-4.0 unless otherwise noted.