Mpesa Integration to website tutorial c2b php free
This mpesa integration article guides you on how to integrate Mpesa with your website with mpesa api code tutorial, you will learn how mpesa integration to website is easy.
Integrating MPesa Paybill or Lipa na Mpesa to any application system or Website Using Safaricom C2B M-Pesa API. The new Daraja Mpesa API integration to website has so many advantages and many of website and web developers can take advantage of it thanks to Safaricom. Though Safaricom wont help you in developing the Lipa na Mpesa Integration to your website, we can take that burden by guiding you on how to integrate the Lipa na Mpesa API to your application, website, e-commerce, software android.
We make it easier to develop Mpesa integration to website then send Bulk SMS whenever a customer pays through the Lipa na Mpesa Till number or Paybill number. The mpesa website Integration is more to work on receiving the transaction details on database. It needs more logic developing the website to do automatic transaction like deposting in accounts, withdrawing money to Mpesa, buying credit.
We will simply guide you on how to integrate your android application, web system or website with Mpesa API – C2B. For those who want on how to do Mpesa integration to a website on php, we can do it for free if you are our Bulk SMS client. All our bulk SMS clients are eligible for free Mpesa integration to website – specifically mpesa c2b integration.
Web developers and software Developers who needs to Lipa na M-pesa to website integration can follow just some few steps or Mpesa API tutorial assuming we are working with Mpesa integration in PHP.
Step guide on Mpesa integration to website
Prerequisites for integrating mpesa to website or any other application.
When you want to integrate Mpesa with Application your application or URL that are receiving the Mpesa transactions must be only.
Assuming we are inegrating your website in php, we must have a domain name, hosting configured in Apache and PHP and MySql database, SSL,
We can guide you to simply use a sub folder in your domain if its secure to use it in Mpesa to website intgration. Like for use we use use www.movesms.co.ke . If you are starting You can buy a domain which only costs Ksh 700 at Move Host . The domain is supposed to come with hosting package to host your Mpesa API integration files and then for Mpesa Integration database.
If you hosting is configured well for mpesa to website integration in php then we can go to Safaricom Portal
Create an account at Safaricom Developer Portal
Enter details as requested on Safaricom Daraja API portal
After creating login to Safaricom API portal and access Menu My APPs
You will be required to get Consumer Secret and Key
This is the stage for creating an app for mpesa integration to website.
Add your new app so that you can use it in Mpesa website intgration.Check on Sandbox for c2b, b2c, b2b. then allocate that app name e.g. MoveSMS. You can check this stage for Mpesa API integration to website stage below.
You can explore your app after creating them. Kindly note that for mpesa integration to website the app must be approved.
After clicking on your your Mpesa integration app that you will use you will see consumer key and secret. You can save your detail on your email as you will require the consumer secret and key in mpesa integration to website later on Mpesa website API.
After that Mpesa website integration you can create a token to ensute transactions are not compromised.
You can any security toke that will be unique but which hackers cant guess. As the Mpesa website API integration is online so many hackers will be trying those URL, so a token can be used as security on the Mpesa to website inetgration platform.
After that stage on Lipa na Mpesa to website intrration, go ahead and get the Shortcode for testing.
This Mpesa API url will take you to Shortcode test generation
The Shortcode is a 6 numbers
Now you can go to PHPMYADMIN to create the database
All the Mpesa integration transaction codes will be saved in the integration database.
Go to Control Panel of your account,
- Creating a database eg movesms
- Creating a database username
- Giving your database user access to work with your database
Mpesa integration to website will be directing the mpesa transaction code on that database
Create a table on that database e.g movesms.
The details needed by Safaricom are
Number Auto Number
FName Varchar 25
MName Varchar 25
LName Varchar 25
TransactionType Varchar 40
TransID Varchar 40
TransTime Varchar 40
ShortCode Varchar 15
BillRefNumber Varchar 30
InvoiceNumber Varchar 30
ThirdPartyTransID Varchar 40
MSISDN Varchar 20
Now it will depend on where you want to store the needed URL by Safarciom. For Mpesa to website integration to occur we need two URL that is Validation and Confirmation urls. You can decide to put them straight on public html or on sub folder.
Validation URL is to receive the M-Pesa transaction once sent to your Lipa na Mpesa Paybill number or Till Number.
Next we need to create a folder for holding Mpesa website API call back URL’s. When a customer makes payment to your till or Paybill number, Mpesa will first send the transaction details on your validation URL.
You can even create a subfolder to put your 2 URLs for mpesa to website integration, eg a folder like www.movesms.co.ke/mpesaapi/ .
Go direct to MPESA API github and download the 2 files validation and comfirmation https://github.com/safaricom/mpesa_c2b_php_confirmation_validation
Download those 2 URL and upload them on your public html/root or subfolder
After that you can go to Safaricom API portal and register validation and confirmation call back urls.
Create another file called register.php and upload it on the folder. It will look like www.movesms.co.ke/mpesaapi/register.php
Now use php to register the validation and confirmation URL’s.
Copy the contents of the register URL on this MPesa API Github here https://github.com/movetechke/mpesa
Now you can go to web browser to register your URL example we visit www.movesms.co.ke/mpesaapi/register.php so that our urls will be registered on Safricom API portal automatically.
If all goes well then you are good to go live.
Finish on all test cases, submit and let Safricom approve. With that MPesa API integration you are ready to go to production.
Move Your System to Live
Now after finishing on logical Mpesa integration you can move your system to live.
How to Develop Mpesa Integration to Website
By following this Mpesa API integration php tutorial you can easily develop a C2B, B2C, B2B Mpesa Integration to your android application or website system. Safaricom MPESA API tutorials also offers guide on how to use all the Lipa na Mpesa API integration in so many languages from android, php, Java, Python. If unable then we can easily guide you on the Mpesa integration without hustle. We take few days for the integration of Mpesa to website to work. We can even offer Laravel Mpesa integration for free if you are buying bulk SMS from Us.