This package seeks to help php developers implement the e2Payments APIs without much hustle. It is based on the REST API whose documentation is available on https://e2payments.explicador.co.mz/docs.
You can install the package via composer:
composer require explicador/e2payments-php-sdk
// Set the consumer key and consumer secret as follows
$mpesa = new \Explicador\E2paymentsPhpSdk\Mpesa();
$mpesa->setClientId('your e2payments client id');
$mpesa->setClientSecret('your e2payments client secret');
$mpesa->setWalletId('your walletId from e2payments');// 'live' production environment
//This creates transaction between an M-Pesa short code to a phone number registered on M-Pesa.
$result = $mpesa->c2b($phone_number, $amount, $reference);
// Your variables
// The e2payments is REST API based platform
// find or create your credential from: https://e2payments.explicador.co.mz/admin/credentials
$client_id = 'oQPGhzqyDRilpzvTT6g0nhSeomVQ9G7zZrvY4v00'; //you must change
$client_secret = '961022ed-08f6-4980-a1b3-f017fd15b800'; //you must change
// find your wallet_id from: https://e2payments.explicador.co.mz/admin/mpesa
// or in the organizations where you were invited
// The wallet_id starts by (#), insert here without (#)
$wallet_id = '111111'; //you must change
// SDK initiation for mpesa transaction
$mpesa = new \Explicador\E2paymentsPhpSdk\Mpesa([
'client_secret' => $client_secret,
'client_id' => $client_id,
'wallet_id' => $wallet_id,
]);
//This creates transaction between an M-Pesa short code to a phone number registered on M-Pesa.
$result = $mpesa->c2b($phone_number, $amount, $reference);
echo var_dump($result);
Status Code | Description | Explanation |
---|---|---|
200 | OK | Request Executed successfully and stored in e2Payments Platform |
201 | Added | The transaction executed successfully and stored in e2Payments Platform |
400 | Bad Request | Wallet, origin or other mpesa issues |
403 | Forbidden | If the Wallet ID does not exists or does not belongs to the user (if walletId belongs to some organization, the user must be invited) |
401 | Unauthenticated | Client ID or Client Secret issues |
500 | Server error | If this happens please, report to Explicador Team. |
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the PHP Package Boilerplate.