angstrom/mtn-momo
Composer 安装命令:
composer require angstrom/mtn-momo
包简介
A Laravel package for MTN Mobile Money API integration (Collections, Disbursements, and Remittances)
README 文档
README
A Laravel package for MTN Mobile Money API integration that supports Collections, Disbursements, and Remittances.
Features
- Collections API for receiving payments
- Disbursements API for sending payments
- Remittances API for international transfers
- Token management and caching
- Account balance checking
- Account holder verification
- Exchange rate queries (for Remittances)
Requirements
- PHP ^8.1
- Laravel ^10.0
- Guzzle ^7.8
Installation
You can install the package via composer:
composer require angstrom/mtn-momo
The package will automatically register its service provider.
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="Angstrom\MoMo\MoMoServiceProvider"
This will create a config/momo.php file. Update it with your MTN MoMo API credentials:
return [ 'api_key' => env('MOMO_API_KEY'), 'api_user' => env('MOMO_API_USER'), 'api_base_url' => env('MOMO_API_BASE_URL', 'https://sandbox.momodeveloper.mtn.com'), 'environment' => env('MOMO_ENVIRONMENT', 'sandbox'), ];
Add these variables to your .env file:
MOMO_API_KEY=your-api-key MOMO_API_USER=your-api-user MOMO_API_BASE_URL=https://sandbox.momodeveloper.mtn.com MOMO_ENVIRONMENT=sandbox
Usage
Collections
use Angstrom\MoMo\Collections; $collections = new Collections(); // Request to pay $result = $collections->requestToPay( amount: 100, currency: 'EUR', externalId: 'unique-transaction-id', partyId: '256772123456', // Phone number partyIdType: 'MSISDN', payerMessage: 'Payment for order #123', payeeNote: 'Order #123' ); // Check transaction status $status = $collections->getTransactionStatus($result['referenceId']); // Get account balance $balance = $collections->getAccountBalance(); // Check if account holder is active $status = $collections->checkAccountHolderStatus('256772123456');
Disbursements
use Angstrom\MoMo\Disbursements; $disbursements = new Disbursements(); // Transfer money $result = $disbursements->transfer( amount: 100, currency: 'EUR', externalId: 'unique-transaction-id', payeeId: '256772123456', payeeIdType: 'MSISDN', payerMessage: 'Salary payment', payeeNote: 'Salary for January' ); // Check transfer status $status = $disbursements->getTransferStatus($result['referenceId']); // Get account balance $balance = $disbursements->getAccountBalance();
Remittances
use Angstrom\MoMo\Remittances; $remittances = new Remittances(); // International transfer $result = $remittances->transfer( amount: 100, currency: 'EUR', externalId: 'unique-transaction-id', payeeId: '256772123456', payeeIdType: 'MSISDN', payerMessage: 'International transfer', payeeNote: 'Family support' ); // Check transfer status $status = $remittances->getTransferStatus($result['referenceId']); // Get exchange rate $rate = $remittances->getExchangeRate('EUR', 'UGX');
Using the Facade
You can also use the provided facade:
use Angstrom\MoMo\Facades\MoMo; // Collections $result = MoMo::collections()->requestToPay(...); // Disbursements $result = MoMo::disbursements()->transfer(...); // Remittances $result = MoMo::remittances()->transfer(...);
Testing
composer test
Security
If you discover any security-related issues, please email info@angstrom-technologies.ug instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
angstrom/mtn-momo 适用场景与选型建议
angstrom/mtn-momo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 angstrom/mtn-momo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 angstrom/mtn-momo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-17