karson / mpesa-php-sdk
1.5.0
2022-06-15 05:39 UTC
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.3.3
README
此包旨在帮助 PHP 开发者轻松实现各种 Mpesa API。它基于 REST API,其文档可在 https://developer.mpesa.vm.co.mz/ 查找。
安装
您可以通过 composer 安装此包
composer require karson/mpesa-php-sdk
用法
// 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);
Laravel 中的安装
// Set the api, public key, provider and environment secret as follows in your .env file MPESA_API_KEY ="Your API Key"; MPESA_PUBLIC_KEY='You Public Key' MPESA_ENV='test' // 'live' production environment MPESA_SERVICE_PROVIDER_CODE=171717
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志。
贡献
有关详细信息,请参阅 贡献指南。
安全性
如果您发现任何与安全相关的问题,请通过电子邮件 karson@turbohost.co 而不是使用问题跟踪器。
鸣谢
许可协议
MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件。
PHP 包模板
此包是使用 PHP 包模板 生成的。