How To Use M-Pesa PHP Package Version 3

23rd Oct 2017

The popular package SmoDav M-Pesa has been updated to use the current API provided by Safaricom. Being a major upgrade, this version will not be 100% backward compatible with version 2. So what are we waiting for, let's get started!

So far We've implemented the C2B section of the API by providing Register URL, Identity and STK Push. Just as the previous versions, this package works with both Laravel and Vanilla PHP or any other framework. When using vanilla PHP, we have a helper script that will copy the required files to ease the configuration process. You can either run it manually or leverage composer to do it for you as a post-update command:


  "scripts": {
        "post-update-cmd": [
            "SmoDav\\Mpesa\\Support\\Installer::install"
        ]
  }

How To Use M-Pesa PHP Package Version 2

19th Oct 2017

We created a good PHP package to interact with M-Pesa API. This package can be pulled in via composer or directly downloaded from github. The API allows a merchant to initiate C2B online checkout (PayBill via web) transactions. The merchant submits authentication details, transaction details, callback URI and callback method. After request submission, the merchant receives instant feedback with validity status of their requests. The C2B API handles customer validation and authentication via USSD push. The customer then confirms the transaction. If the validation of the customer fails or the customer declines the transaction, the API makes a callback to the merchant. Otherwise, the transaction is processed and its status is made through a callback.

Installing the package.

When you're using vanilla php, you can leverage the installer script included in the package by adding the following to the scripts section of composer.json:

"scripts": {
    "post-update-cmd": [
        "SmoDav\\Mpesa\\Support\\Installer::install"
    ]
}