praisedare/monnify-sdk
Composer 安装命令:
composer require praisedare/monnify-sdk
包简介
PHP SDK for Monnify Payment Gateway Integration
README 文档
README
A comprehensive PHP SDK for integrating with the Monnify Payment Gateway. This SDK provides a clean, object-oriented interface for all Monnify API operations including payment initiation, verification, refunds, and webhook handling.
Features
- 🚀 Easy Integration: Simple and intuitive API
- 🔒 Secure: Built-in security features and validation
- 📦 Complete Coverage: All Monnify API endpoints supported
- 🧪 Well Tested: Comprehensive test suite
- 📚 Well Documented: Clear documentation and examples
- 🔄 Webhook Support: Built-in webhook verification and handling
- 💰 Multiple Payment Methods: Card, Bank Transfer, USSD, etc.
Installation
composer require praisedare/monnify-sdk
Quick Start
1. Initialize the SDK
use PraiseDare\Monnify\Monnify; $monnify = new Monnify([ 'secret_key' => 'your_secret_key', 'api_key' => 'your_api_key', 'contract_code' => 'your_contract_code', 'environment' => 'sandbox', // or 'live' ]);
2. Initialize a Payment
$paymentData = [ 'amount' => 1000.00, 'customerName' => 'John Doe', 'customerEmail' => 'john@example.com', 'paymentReference' => 'TXN-' . uniqid(), 'paymentDescription' => 'Payment for services', 'currencyCode' => 'NGN', 'contractCode' => 'your_contract_code', 'redirectUrl' => 'https://yourwebsite.com/callback', 'paymentMethods' => ['CARD', 'ACCOUNT_TRANSFER', 'USSD'] ]; $response = $monnify->payment()->initialize($paymentData);
3. Verify Payment
$transactionReference = 'MNFY|20240101|123456789'; $response = $monnify->payment()->verify($transactionReference);
4. Handle Webhooks
$webhookData = $request->getContent(); $signature = $request->header('MNFY-SIGNATURE'); if ($monnify->webhook()->verify($webhookData, $signature)) { $payload = json_decode($webhookData, true); // Process the webhook data }
Configuration
Environment Variables
MONNIFY_SECRET_KEY=your_secret_key MONNIFY_API_KEY=your_api_key MONNIFY_CONTRACT_CODE=your_contract_code MONNIFY_ENVIRONMENT=sandbox
Configuration Array
$config = [ 'secret_key' => env('MONNIFY_SECRET_KEY'), 'api_key' => env('MONNIFY_API_KEY'), 'contract_code' => env('MONNIFY_CONTRACT_CODE'), 'environment' => env('MONNIFY_ENVIRONMENT', 'sandbox'), 'timeout' => 30, // HTTP timeout in seconds 'verify_ssl' => true, // SSL verification ];
API Reference
Payment Methods
Initialize Payment
$response = $monnify->payment()->initialize([ 'amount' => 1000.00, 'customerName' => 'John Doe', 'customerEmail' => 'john@example.com', 'paymentReference' => 'TXN-' . uniqid(), 'paymentDescription' => 'Payment for services', 'currencyCode' => 'NGN', 'contractCode' => 'your_contract_code', 'redirectUrl' => 'https://yourwebsite.com/callback', 'paymentMethods' => ['CARD', 'ACCOUNT_TRANSFER', 'USSD'] ]);
Verify Payment
$response = $monnify->payment()->verify('MNFY|20240101|123456789');
Get Transaction Status
$response = $monnify->payment()->getStatus('MNFY|20240101|123456789');
Refund Methods
Initiate Refund
$response = $monnify->refund()->initiate([ 'transactionReference' => 'MNFY|20240101|123456789', 'refundAmount' => 500.00, 'refundReason' => 'Customer request', 'refundReference' => 'REF-' . uniqid() ]);
Get Refund Status
$response = $monnify->refund()->getStatus('REF-' . uniqid());
Settlement Methods
Get Settlement Accounts
$response = $monnify->settlement()->getAccounts();
Get Settlement Transactions
$response = $monnify->settlement()->getTransactions([ 'page' => 1, 'size' => 20, 'fromDate' => '2024-01-01', 'toDate' => '2024-01-31' ]);
Webhook Methods
Verify Webhook
$isValid = $monnify->webhook()->verify($webhookData, $signature);
Parse Webhook
$payload = $monnify->webhook()->parse($webhookData);
Error Handling
try { $response = $monnify->payment()->initialize($paymentData); } catch (PraiseDare\Monnify\Exceptions\MonnifyException $e) { // Handle Monnify-specific errors echo "Error: " . $e->getMessage(); echo "Code: " . $e->getCode(); } catch (Exception $e) { // Handle general errors echo "General Error: " . $e->getMessage(); }
Response Format
All API responses follow a consistent format:
[
'success' => true,
'data' => [
// Response data
],
'message' => 'Operation successful',
'code' => 'SUCCESS'
]
Testing
# Run tests composer test # Run tests with coverage composer test-coverage # Run static analysis composer phpstan
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please contact:
- Email: praisedare27@gmail.com
- Documentation: Monnify API Docs
Changelog
v1.0.0
- Initial release
- Payment initialization and verification
- Refund functionality
- Settlement management
- Webhook handling
- Comprehensive error handling
praisedare/monnify-sdk 适用场景与选型建议
praisedare/monnify-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 92 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「payment」 「sdk」 「gateway」 「Nigeria」 「monnify」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 praisedare/monnify-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 praisedare/monnify-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 praisedare/monnify-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
TrinkPOS Sanal POS (Virtual POS) API client for PHP
ABsurge PHP SDK for feature flags and A/B testing
统计信息
- 总下载量: 92
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-23