项目作者: karson

项目描述 :
A PHP sdk for the new Vodacom Mpesa RESTful APIs :mozambique:
高级语言: PHP
项目地址: git://github.com/karson/mpesa-php-sdk.git
创建时间: 2020-01-14T18:14:02Z
项目社区:https://github.com/karson/mpesa-php-sdk

开源协议:MIT License

下载


Mpesa Mozambique PHP SDK

Latest Version on Packagist
Build Status
Quality Score
Total Downloads

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:

  1. composer require karson/mpesa-php-sdk

Usage

  1. // Set the api and public key as follows . Copy it from Mpesa Developer Console (https://developer.mpesa.vm.co.mz/) .
  2. $mpesa = new \Karson\MpesaPhpSdk\Mpesa();
  3. $mpesa->setApiKey('your api key');
  4. $mpesa->setPublicKey('your public key');
  5. $mpesa->setServiceProviderCode('your public key');
  6. $mpesa->setEnv('test');// 'live' production environment
  7. //This creates transaction between an M-Pesa service provider code to a phone number registered on M-Pesa.
  8. $invoice_id = "FT0001"; // Eg: Invoice number
  9. $phone_number = "258841234567"; // Prefixed with country code (258)
  10. $amount = "10"; // Payment amount
  11. $reference_id = "XBRAND001"; // Should be unique for each transaction
  12. $result = $mpesa->c2b($invoice_id, $phone_number, $amount, $reference_id);
  13. var_dump($result);

Instalation in Laravel

  1. // Set the api, public key, provider and environment secret as follows in your .env file
  2. MPESA_API_KEY ="Your API Key";
  3. MPESA_PUBLIC_KEY='You Public Key'
  4. MPESA_ENV='test' // 'live' production environment
  5. MPESA_SERVICE_PROVIDER_CODE=171717

Testing

  1. 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 karson@turbohost.co 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.