Search by

worldxgrowth / razcrypto-php-sdk

Worldxgrowth

Official PHP SDK for RazCrypto Gateway: payments, payment links, Standard Webhooks and checkout signature verification.

Package info

github.com/WorldxGrowth/razcrypto-php-sdk

pkg:composer/worldxgrowth/razcrypto-php-sdk

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v3.0.0 2026-10-04 11:18 UTC

This package is not auto-updated.

Last update: 2026-11-29 12:14:58 UTC


README

RazCrypto%20PHP%20SDK

Accept USDT & crypto payments in Laravel and Core PHP — the official PHP client for RazCrypto Gateway.

PHP 8.1+ Laravel No dependencies USDT BEP-20 MIT

Install • Create payment • API • Webhooks • Test mode

✨ Features

  • 🔌 Plug & play — works with Laravel, Symfony and plain PHP
  • 📦 Zero dependencies — only PHP ≥ 8.1 and cURL
  • 🔁 Safe retries — idempotency keys + automatic retry on network errors, 429 and 5xx
  • 🔐 Webhook verification — Standard Webhooks signatures, PSR-7 and Laravel header bags supported
  • 🧪 Test mode — simulate a full payment, webhooks included

📥 Installation

composer require worldxgrowth/razcrypto-php-sdk
Composer worldxgrowth/razcrypto-php-sdk
Requires PHP ≥ 8.1, cURL
License MIT

Upgrading? This major version is for the new RazCrypto Gateway: initialise with only your secret key (Dashboard → API apps) and use the new /v1 API. Pin the previous major version only if you still use the old gateway.

🔄 How it works

  1. Your server creates a payment with your secret key (sk_…).
  2. The customer pays on the RazCrypto checkout (QR code or wallet link).
  3. RazCrypto sends a signed payment.paid webhook to your server.
  4. You verify the webhook and mark the order as paid.

💡 Trust the webhook, not the browser. The redirect and onSuccess are only for a fast "Paid" screen.

🚀 Create a payment

<?php
require 'vendor/autoload.php';

$rc = new \RazCrypto\Client(getenv('RAZCRYPTO_SECRET_KEY')); // sk_test_… or sk_live_…

$payment = $rc->payments()->create([
    'amount'       => '49.00',
    'currency'     => 'USD',
    'reference_id' => $order->id,
    'redirect_url' => 'https://shop.example/thanks',
], $order->id); // idempotency key — safe to retry

header('Location: ' . $payment['checkout_url']);

📚 API reference

Payments

  • $rc->payments()->create($params, $idempotencyKey)
  • retrieve($id) · all($params) · cancel($id)
  • methods($id) · quote($id, $chain, $coin)
  • simulate($id, $outcome) — test mode only

Payment links

  • $rc->paymentLinks()->create(...) · retrieve · all · update · deactivate

Others

  • $rc->chains() · $rc->rates(['USDT','BNB'], 'USD') · $rc->merchant() · $rc->event($id)

Errors

  • API errors throw RazCrypto\Exception\ApiError with the HTTP status, code, param and request id.
  • Network problems throw RazCrypto\Exception\ConnectionError.

Options

new Client($key, ['timeout' => 30, 'max_retries' => 2]);

The client talks to https://razcryptogateway.com by default. api_base (or env RAZCRYPTO_API_BASE) is only for staging or a self-hosted gateway.

🔐 Verify webhooks

Standard Webhooks signatures:

use RazCrypto\Webhook;
use RazCrypto\Exception\SignatureVerificationError;

$raw = file_get_contents('php://input');
try {
    $event = Webhook::verify($raw, getallheaders(), getenv('RAZCRYPTO_WEBHOOK_SECRET')); // whsec_…
} catch (SignatureVerificationError $e) {
    http_response_code(400);
    exit;
}
if ($event['type'] === 'payment.paid') {
    markOrderPaid($event['data']['reference_id']);
}
http_response_code(200);

Webhook::verify() also accepts Laravel/Symfony header bags ($request->headers->all()) and PSR-7 requests.

✅ Verify the checkout signature

use RazCrypto\CheckoutSignature;

// Redirect query: ?payment_id=…&reference_id=…&status=…&signature=…
if (!CheckoutSignature::isValid($_GET, getenv('RAZCRYPTO_WEBHOOK_SECRET'))) {
    // do not trust it — wait for the webhook
}

🧪 Test mode

  • Use sk_test_… keys.
  • $rc->payments()->simulate($id, 'paid') runs the full flow, webhooks included.
php tests/client.php   # no PHPUnit needed

🛒 WooCommerce store? A RazCrypto WooCommerce plugin is available — ask us at worldxgrowth@gmail.com.

🧩 Other RazCrypto SDKs

Built and maintained by Worldxgrowth — Software Development Agency

Get API keys Support

Released under the MIT License.