M-Pesa API Package for PHP
# M-PESA API Package
This is a PHP package for the Safaricom's M-Pesa API.
The API allows a merchant to initiate C2B online checkout (paybill via web) transactions.
The merchant submits authentication details, transaction details, callback url 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 merchant. Otherwise the transaction is processed and its status is made through a callback.
If you enjoy using this package, please take a moment and buy me some coffee.
## Installation
Pull in the package through Composer.
### Native Addon
When using vanilla PHP, modify your `composer.json` file to include:
```json
"scripts": {
"post-update-cmd": [
"SmoDav\\Mpesa\\Support\\Installer::install"
]
},
```
This script will copy the default configuration file to a config folder in the root directory of your project.
Now proceed to require the package.
### General Install
Run `composer require smodav/mpesa` to get the latest stable version of the package.
## Migration from previous versions
v5 of the package changes the implementation and introduces some breaking changes. Please have a look at the CHANGELOG.
v4 of this package uses a new configuration setup. You will need to update your config file in order to upgrade v3 to v4. v2 is still incompatible since it uses the older API version.
### Laravel
When using Laravel 5.5+, the package will automatically register. For laravel 5.4 and below,
include the service provider and its alias within your `config/app.php`.
```php
'providers' => [
SmoDav\Mpesa\Laravel\ServiceProvider::class,
],
'aliases' => [
'STK' => SmoDav\Mpesa\Laravel\Facades\STK::class,
'Simulate' => SmoDav\Mpesa\Laravel\Facades\Simulate::clas …