cray/laravel-sdk
Composer 安装命令:
composer require cray/laravel-sdk
包简介
Cray Laravel SDK for Card and MoMo payments
README 文档
README
- Package name:
cray/laravel-sdk - Installation:
composer require cray/laravel-sdk - Supported Frameworks: Laravel 8, 9, 10, 11 (PHP 8.1+)
- Auto-Discovery: Enabled by default
- Manual Registration (Lumen or Custom): Add
Cray\\LaravelSDK\\CrayServiceProviderto providers and aliasCraytoCray\\LaravelSDK\\Facades\\Cray.
Environment Configuration
Publish config:
php artisan vendor:publish --provider="Cray\\LaravelSDK\\CrayServiceProvider" --tag="config"
Add to .env:
CRAY_PUBLIC_KEY=your_public_key
CRAY_SECRET_KEY=your_secret_key
CRAY_TIMEOUT=30
Environment switching (automatic):
- Uses
APP_ENVto select base URL and environment. - When
APP_ENVisproduction/prod/live→ base URLhttps://pay.connectramp.com, envproduction. - Otherwise (e.g.,
staging,sandbox,local,testing) → base URLhttps://dev-gateman.v3.connectramp.com, envsandbox. − No need to setCRAY_BASE_URLorCRAY_ENV— they are derived. You may still overrideCRAY_BASE_URLif required.
SDK Usage Examples
Card Payment Flow
Initiate a Card Transaction
use Cray\LaravelSDK\Facades\Cray; use Illuminate\Support\Str; $transaction = Cray::card()->initiate([ 'reference' => (string) Str::uuid(), 'amount' => '100.00', 'currency' => 'USD', 'narration' => 'Payment for Order #12345', 'card_data' => [ 'pan' => '5399832641760090', 'cvv' => '146', 'expiryMonth' => '05', 'expiryYear' => '50', ], 'callback_url' => route('cray.callback'), 'customer_information' => [ 'email' => 'customer@example.com', 'firstName' => 'John', 'lastName' => 'Doe', 'mobilePhone' => '+15551234567', ], ]);
Charge the Transaction
if ($transaction['status'] ?? false) { $txId = $transaction['data']['transaction_id'] ?? null; if ($txId) { $charge = Cray::card()->charge($txId); } }
Query a Transaction
$status = Cray::card()->query('87c89286-afbc-4776-adfd-665c9927b2db');
Refund a Transaction
$refund = Cray::refund()->refund('87c89286-afbc-4776-adfd-665c9927b2db', 50.00);
Query Refund Status
$refundStatus = Cray::refund()->queryRefund('87c89286-afbc-4776-adfd-665c9927b2db');
MoMo Payment Flow
Initiate a MoMo Transaction
use Cray\LaravelSDK\Facades\Cray; use Illuminate\Support\Str; $momo = Cray::momo()->initiate([ 'customer_reference' => (string) Str::uuid(), 'amount' => '200', 'currency' => 'GHS', 'phone_no' => '233801234567', 'payment_provider' => 'MTN', 'firstname' => 'John', 'lastname' => 'Doe', ]);
Query MoMo Transaction
$requery = Cray::momo()->query('ad75b9bb-2501-4761-8980-42b525e21c37');
Key Features
- Unified SDK for Card and MoMo APIs
- Supports refunding and querying across both transaction types
- Sandbox and production environment toggling
- Standardized response structure and built-in error handling
- Logging, retries, and correlation IDs included
CI/CD and Versioning
- CI Matrix: PHP 8.1–8.3, Laravel 8–11
- Unit Tests: PHPUnit/Larastan static analysis
- Versioning: Semantic Versioning (v1.0.0)
cray/laravel-sdk 适用场景与选型建议
cray/laravel-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cray/laravel-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cray/laravel-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-10