explicador/e2payments-php-sdk

Pacote de integração de pagamentos online por MPesa, eMola, MKesh, conta móvel, BIM, Master Card e mais

v1.0.4 2022-04-19 22:46 UTC

This package is auto-updated.

Last update: 2024-04-20 03:02:52 UTC


README

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 developers@explicador.co.mz 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.