Ronald Ngoda

PESA LIB-MPESA PAYMENT API LIBRARY FOR PHP

THIS LIBRARY CONTAINS FILES AND SCRIPTS TO HELP YOU QUICKLY INTEGRATE MPESA API INTO YOUR APPLICATION. IT IS VERY SIMPLE AND STRAIGHT FORWARD. YOU SIMPLY NEED TO FEED IN THE REQUIRED PARAMETERS AND YOU ARE GOOD TO GO. BELOW IS A DETAILED EXPLANATION OF WHAT EACH FILE DOES.

Project Overview

THIS LIBRARY CONTAINS FILES AND SCRIPTS TO HELP YOU QUICKLY INTEGRATE MPESA API INTO YOUR APPLICATION. IT IS VERY SIMPLE AND STRAIGHT FORWARD. YOU SIMPLY NEED TO FEED IN THE REQUIRED PARAMETERS AND YOU ARE GOOD TO GO. BELOW IS A DETAILED EXPLANATION OF WHAT EACH FILE DOES.

The library has an easy to use setup and management interface for your usage. Simply hit the index.php to get started.

B2C.PHP

This code is used to initiate a B2C request.Kindly provide the following parameters: shortcode,key,secret,username,password,confirmation_url,timeout_url. On the $response provide the recipient phone number and amount. The URLs here can point to b2ccallback.php or suggest any different URL if you purpose to separate them.

B2CCALLBACK.PHP

This code contains extracted parameters from the B2C callback response sent from Safaricom. You can use these parameters to process your payment data as to your own wish.

BALANCE.PHP

This code is used to initiate B2C balance request.Kindly provide the following parameters: shortcode,key,secret,username,password,confirmation_url,timeout_url.

C2B.PHP

This script is used to process C2B requests.Provide the shortcode,headoffice,key,secret,passkey,validation_url,confirmation_url,callback_url,timeout_url.

This is where you will do your validationconfirmationsimulationstk push, and registration of callback URLs.

For this case, your validation URL will be yourdomain.com/c2b.php?action=validate. Replace yourdomain.com with the actual domain and location of this file.

Your confirmation URL will be yourdomain.com/c2b.php?action=confirm

Your callback URL will be yourdomain.com/c2bcallback.php same as your timeout URL.

To initiate an STK push request you will need to hit yourdomain.com/c2b.php?action=push☎=0700000000&amount=10&reference=abcd This URL contains several parameters; phone, amount, and reference. Replace the values after the = sign with actual values to be used.

To register your c2b URLs you simply need to hit yourdomain.com/c2b.php?action=register

C2BCALLBACK.PHP

This code contains extracted parameters from the C2B callback response sent from Safaricom. You can use these parameters to process your payment data as to your own wish.

MpesaB2C.php

This file contains methods that perform B2C operations. Kindly provide the following parameters: shortcode,key,secret,username,password,confirmation_url,timeout_url.

MpesaC2B.php

This file contains methods that perform C2B operations. Provide the shortcode, head office, key, secret, passkey, username.

All this is just to help you have an easier time when integrating and interacting with the files, in case you face any challenges kindly get in touch payherokenya@gmail.com or call +254765344101

Buy my product

Want me to help with your project?

I am currently taking on freelance projects. Contact me if you wish to have me create your next big project!!!