Download the PHP package crysoft/mpesa-bundle without Composer
On this page you can find all versions of the php package crysoft/mpesa-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mpesa-bundle
SYMFONY M-PESA API Bundle
This is a Symfony Bundle for the integration Safaricom's M-Pesa Online API. The API allows a merchant to initiate Online C2B (Paybill via web) transactions. The merchant submits authentication details, transaction details, callback url and callback method.
Normally after request submission, the merchant receives instant feedback with validity status of their requests but this bundle implements a custom request for that status. The C2B API handles customer validation and authentication via USSD push. The customer then confirms the transaction.
Requirements
- PHP 5.6 or above
- Symfony 2.6 or above
Installation
To install this bundle, run the command below and you will get the latest version by [Packagist][4].
Load the Bundle
Load bundle in AppKernel.php:
Configuration of the Bundle
Configuration in config.yml:
Config Options
The M-Pesa API Endpoint. Confirm this as it might change at some point
- callback_url: http://yourcallbackurl.com/successurl
The fully qualified callback URL to be queried by Safaricom on transaction completion.
- callback_method: POST
The callback method to be used. Can also be GET
- paybill_number: 123456
The merchant's Paybill number.
- pass_key: verysecretlongkey
The SAG Passkey given by Safaricom on registration. You probably have to ask for it.
Usage
Usage of the Bundle is simple. Use it in your controller you have access to the Service Container using "$this->container" which in turn accesses the config variables.
In your controller do:
You can just chain the method calls into one single call as shown above. This Bundle comes with a handy method named "generateTransactionNumber()" that generates a random transaction number for you to use. Take note of the generated transaction id/number as you will use it to query the status of the transaction isntead of waiting for Safaricom to make the callback.
Requesting for the Status is trivial as this bundle also provides a simple way of doing that:
You dont have to name your variables as we have named them, you can name them anything. And that's it. You are good to go
Testing
Be careful when testing this, Paybill will deduct the amount from Mpesa. You can use kes 10 which is the minimum allowed.
License
The M-Pesa Package is open-sourced software licensed under the MIT license.