moncashconnect/php-sdk
Composer 安装命令:
composer require moncashconnect/php-sdk
包简介
PHP SDK for MonCashConnect — independent MonCash payment integration platform for Haiti.
README 文档
README
Official PHP SDK for the MonCashConnect payment platform.
Note: MonCashConnect is not affiliated with Digicel or the official MonCash service.
Requirements
- PHP 7.4+
ext-curlext-json
Installation
composer require moncashconnect/php-sdk
Quick Start
use MonCashConnect\Client; use MonCashConnect\Exception\MonCashException; $client = new Client($_ENV['MCC_SECRET_KEY']); try { $payment = $client->createPayment(1500, 'ORDER-001', [ 'return_url' => 'https://yoursite.com/payment/success', 'customer_name' => 'Jean Dupont', ]); // Redirect the customer to MonCash header('Location: ' . $payment['paymentUrl']); exit; } catch (MonCashException $e) { echo 'Payment error: ' . $e->getMessage(); }
Your secret key starts with sk_proj_ — get it from Developer → Projects in your dashboard.
Check Payment Status
$tx = $client->getPaymentStatus('ORDER-001'); echo $tx['status']; // "pending" | "completed" | "failed" echo $tx['netAmount']; // Amount after commission deduction
Get Account Balance
$balance = $client->getBalance(); echo $balance['balanceHtg']; // Total available echo $balance['withdrawableHtg']; // Can withdraw now
Webhooks
Configure a webhook URL in your project. MonCashConnect sends a signed POST when a payment is finalized.
Always read the raw body before any json_decode().
use MonCashConnect\Webhook; use MonCashConnect\Exception\MonCashException; $rawBody = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_MCC_SIGNATURE'] ?? ''; $timestamp = $_SERVER['HTTP_X_MCC_TIMESTAMP'] ?? ''; try { $event = Webhook::constructEvent( $rawBody, $signature, $timestamp, $_ENV['MCC_WEBHOOK_SECRET'] ); } catch (MonCashException $e) { http_response_code($e->getCode() ?: 400); exit($e->getMessage()); } switch ($event['event']) { case 'payment.completed': // Mark order as paid in your database markOrderPaid($event['reference']); break; case 'payment.failed': // Handle failure markOrderFailed($event['reference']); break; } http_response_code(200); echo 'OK';
Laravel
// routes/api.php Route::post('/webhooks/moncash', [MonCashWebhookController::class, 'handle']); // app/Http/Controllers/MonCashWebhookController.php public function handle(Request $request): Response { $event = Webhook::constructEvent( $request->getContent(), $request->header('X-MCC-Signature', ''), $request->header('X-MCC-Timestamp', ''), config('services.moncash.webhook_secret') ); if ($event['event'] === 'payment.completed') { Order::where('reference', $event['reference'])->update(['status' => 'paid']); } return response('OK'); }
Error Handling
catch (MonCashException $e) { $e->getMessage(); // "referenceId already exists for this project" $e->getCode(); // HTTP status: 400, 401, 409, 429, 502… $e->getContext(); // Full API response array, or null }
License
MIT
moncashconnect/php-sdk 适用场景与选型建议
moncashconnect/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「sdk」 「mobile-money」 「moncash」 「haiti」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 moncashconnect/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moncashconnect/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 moncashconnect/php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is simple PHP Package to interact with Moneroo API.
Pesa PHP SDK
Modern Laravel package for Flutterwave v4 API integration
Shoket is a PHP client for the Shoket Payment API.
Modern Laravel package for Safaricom M-Pesa Daraja API integration with comprehensive B2C, B2B, STK Push, and Balance inquiry support
Laravel package for Beem API integration - SMS, Airtime, OTP, Payment Checkout, Collections, Contacts, Moja, and International SMS services
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07