worldxgrowth / razcrypto-php-sdk
Official PHP SDK for RazCrypto Gateway: payments, payment links, Standard Webhooks and checkout signature verification.
Requires
- php: >=8.1
- ext-hash: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-29 12:14:58 UTC
README
Accept USDT & crypto payments in Laravel and Core PHP — the official PHP client for RazCrypto Gateway.
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,
429and5xx - 🔐 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
/v1API. Pin the previous major version only if you still use the old gateway.
🔄 How it works
- Your server creates a payment with your secret key (
sk_…). - The customer pays on the RazCrypto checkout (QR code or wallet link).
- RazCrypto sends a signed
payment.paidwebhook to your server. - You verify the webhook and mark the order as paid.
💡 Trust the webhook, not the browser. The redirect and
onSuccessare 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\ApiErrorwith the HTTP status,code,paramand 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
- 🟢 Node.js — Express / Next.js
- 🐍 Python — Django / Flask / FastAPI
- 🌐 Checkout JS — any website
- 💙 Flutter — Android & iOS
- ⚛️ React Native — Android & iOS
Built and maintained by Worldxgrowth — Software Development Agency
Released under the MIT License.