定制 cray/laravel-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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\\CrayServiceProvider to providers and alias Cray to Cray\\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_ENV to select base URL and environment.
  • When APP_ENV is production/prod/live → base URL https://pay.connectramp.com, env production.
  • Otherwise (e.g., staging, sandbox, local, testing) → base URL https://dev-gateman.v3.connectramp.com, env sandbox. − No need to set CRAY_BASE_URL or CRAY_ENV — they are derived. You may still override CRAY_BASE_URL if 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 cray/laravel-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-10