cray/laravel-sdk

Cray Laravel SDK for Card and MoMo payments

Maintainers

Package info

github.com/noibilism/cray-laravel-sdk

pkg:composer/cray/laravel-sdk

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-11-10 11:12 UTC

This package is auto-updated.

Last update: 2026-03-10 12:11:43 UTC


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)