Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karson/mpesa-php-sdk
A PHP sdk for the new Vodacom Mpesa RESTful APIs :mozambique:
https://github.com/karson/mpesa-php-sdk
mpesa mpesa-api mpesa-apis mpesa-online mpesa-php-sdk mpesa-sdk online-payments payment-gateway php sdk
Last synced: about 2 months ago
JSON representation
A PHP sdk for the new Vodacom Mpesa RESTful APIs :mozambique:
- Host: GitHub
- URL: https://github.com/karson/mpesa-php-sdk
- Owner: karson
- License: mit
- Created: 2020-01-14T18:14:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T05:40:52.000Z (over 2 years ago)
- Last Synced: 2024-07-11T18:26:55.781Z (2 months ago)
- Topics: mpesa, mpesa-api, mpesa-apis, mpesa-online, mpesa-php-sdk, mpesa-sdk, online-payments, payment-gateway, php, sdk
- Language: PHP
- Homepage:
- Size: 48.8 KB
- Stars: 15
- Watchers: 4
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Mpesa Mozambique PHP SDK
[![Latest Version on Packagist](https://img.shields.io/packagist/v/karson/mpesa-php-sdk.svg?style=flat-square)](https://packagist.org/packages/karson/mpesa-php-sdk)
[![Build Status](https://img.shields.io/travis/karson/mpesa-php-sdk/master.svg?style=flat-square)](https://travis-ci.org/karson/mpesa-php-sdk)
[![Quality Score](https://img.shields.io/scrutinizer/g/karson/mpesa-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/karson/mpesa-php-sdk)
[![Total Downloads](https://img.shields.io/packagist/dt/karson/mpesa-php-sdk.svg?style=flat-square)](https://packagist.org/packages/karson/mpesa-php-sdk)This package seeks to help php developers implement the various Mpesa APIs without much hustle. It is based on the REST API whose documentation is available on https://developer.mpesa.vm.co.mz/.
## Installation
You can install the package via composer:
```bash
composer require karson/mpesa-php-sdk
```## Usage
``` php
// Set the api and public key as follows . Copy it from Mpesa Developer Console (https://developer.mpesa.vm.co.mz/) .
$mpesa = new \Karson\MpesaPhpSdk\Mpesa();
$mpesa->setApiKey('your api key');
$mpesa->setPublicKey('your public key');
$mpesa->setServiceProviderCode('your public key');
$mpesa->setEnv('test');// 'live' production environment//This creates transaction between an M-Pesa service provider code to a phone number registered on M-Pesa.
$invoice_id = "FT0001"; // Eg: Invoice number
$phone_number = "258841234567"; // Prefixed with country code (258)
$amount = "10"; // Payment amount
$reference_id = "XBRAND001"; // Should be unique for each transaction$result = $mpesa->c2b($invoice_id, $phone_number, $amount, $reference_id);
var_dump($result);
```
### Instalation in Laravel``` php
// Set the api, public key, provider and environment secret as follows in your .env fileMPESA_API_KEY ="Your API Key";
MPESA_PUBLIC_KEY='You Public Key'
MPESA_ENV='test' // 'live' production environment
MPESA_SERVICE_PROVIDER_CODE=171717
```### Testing
``` bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Karson Adam](https://github.com/karson)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).