承接 cray/laravel-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cray/laravel-sdk

最新稳定版本:v1.0.0

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)

统计信息

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

GitHub 信息

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

其他信息

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