Skip to content

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.

License

Notifications You must be signed in to change notification settings

Explicador/e2Payments-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Explicador e2Payments PHP SDK

Latest Version on Packagist Build Status Quality Score Total Downloads

Plataforma e2Payments

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.

Installation

You can install the package via composer:

composer require explicador/e2payments-php-sdk

Usage

// 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);

Example

// 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);

Common HTTP Status Codes

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.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages