This library provides easy way to integrate PHP applications with the M-Pesa API.
Install using composer:
composer require abdulmueid/mpesa
-
Load the configuration from file.
$config = \abdulmueid\mpesa\Config::loadFromFile('/path/to/config.php');
See sample configuration file in examples folder.
-
Create a Transaction using the configuration.
$transaction = new \abdulmueid\mpesa\Transaction($config);
-
Execute API operations and pass appropriate parameters.
(See Class documentation in docs/ folder for parameter details.)
-
Initiate a payment.
$payment = $transaction->payment(...);
-
Initiate a refund.
$refund = $transaction->refund(...);
-
Query a transaction.
$query = $transaction->query(...);
-
- Update tests/config.test.php with required parameters
- Enter the test MSISDN in tests/MPesaTest.php on line 35
- Run PHPUnit 7 phar archive in the project folder (https://phar.phpunit.de/phpunit-7.phar)
- Check the phone for M-Pesa payment requests
The test case currently creates a new transaction, queries the transaction status and refunds the transaction. Tests may be billable when running on production.
- Run phpDocumentor 2.9 phar archive in the project folder (http://phpdoc.org/phpDocumentor.phar)
This library is release under the MIT License. See LICENSE file for details.
- Improve documentation
- Add more examples
- Improve test suite and test automation