abgorad / usdt-sdk
Official PHP Client SDK for USDT Payment Gateway Integration
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Official PHP Client SDK for integrating the USDT BEP20 Payment Gateway into any PHP application (Laravel, CodeIgniter, Symfony, WordPress, or Native PHP).
🌟 Key Features
- ⚡ Simple & Lightweight: Built using native cURL with zero heavy external dependencies.
- 🔐 Secure Authentication: Native API Key header verification (
X-API-KEY). - 💳 Deposit Address Generation: Instantly generate or fetch unique deposit addresses, QR codes, and checkout links.
- 🔄 Blockchain Transaction Sync: Query and sync transactions from BSC on-demand.
- 💸 Automated USDT PayOUTs: Trigger outbound BEP20 token transfers with reference tracking.
- 📦 PSR-4 Compliant: Drop-in autoloader compatibility for any modern PHP project.
📋 Requirements
- PHP:
7.4or higher - PHP Extensions:
ext-curl,ext-json
🚀 Installation
Option 1: Via Composer (Standard)
composer require abgorad/usdt-sdk
Option 2: Via Direct GitHub Repository (Without Packagist)
Add the repository configuration to your project's composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/abgorad/usdt-sdk"
}
],
"require": {
"abgorad/usdt-sdk": "^1.0"
}
}
Then update composer:
composer update
🔑 Initialization & Setup
Option A: Standard Usage (Composer Autoloading)
When installed via Composer, only require vendor/autoload.php:
require_once 'vendor/autoload.php'; use UsdtPay\UsdtPayClient; use UsdtPay\Exception\UsdtPayException; // Gateway Configuration $gatewayUrl = 'https://your-payment-gateway-domain.com/'; $apiKey = 'YOUR_GATEWAY_API_KEY'; // Generated in Admin Dashboard -> Developer -> API Key $username = 'abGorad'; // Required username // Initialize Client ($username is required, default timeout is 30 seconds) $client = new UsdtPayClient($gatewayUrl, $apiKey, $username, 30); // Getters & Setters echo $client->getBaseUrl(); // Returns configured Base URL echo $client->getApiKey(); // Returns API Key echo $client->getUsername(); // Returns Username echo $client->getTimeout(); // Returns timeout in seconds // Update configuration dynamically if needed: $client->setUsername('newUsername'); $client->setApiKey('NEW_API_KEY'); $client->setBaseUrl('https://new-gateway-domain.com/'); $client->setTimeout(60);
Option B: Standalone Usage (Without Composer)
If using without Composer, include source files directly:
require_once 'path/to/sdk/src/UsdtPayClient.php'; require_once 'path/to/sdk/src/Exception/UsdtPayException.php'; use UsdtPay\UsdtPayClient; use UsdtPay\Exception\UsdtPayException;
📚 API Reference & Method Documentation
1. getChainList()
Fetches all active blockchain networks configured in the gateway.
$response = $client->getChainList();
Sample Response:
{
"status": true,
"message": "Chain List Fetched Successfully",
"data": [
{
"id": 1,
"name": "Binance Smart Chain (BEP20)",
"active": "1"
}
]
}
2. getAddress($chainId, $username, $type = 1)
Generates or retrieves the assigned BEP20 USDT deposit address, checkout URL, and QR code for a given user.
| Parameter | Type | Required | Description |
|---|---|---|---|
$chainId |
int |
Yes | System Blockchain ID (e.g. 1 for BSC BEP20) |
$username |
string |
Yes | User identifier (minimum 3 alphanumeric characters) |
$type |
int |
No | 1 for standard user (default), 0 for admin account |
$response = $client->getAddress(1, 'abGorad', 1); $address = $response['data']['address']; // e.g. 0x0000000000000000000000000000000000000000 $checkoutUrl = $response['data']['checkout_url']; // e.g. https://domain.com/checkout/0x... $qrCodeUrl = $response['data']['qrcode_url']; // e.g. QR Code Image URL
3. getAddressBalance($chainId, $address)
Retrieves the real-time USDT token balance for a specific wallet address.
| Parameter | Type | Required | Description |
|---|---|---|---|
$chainId |
int |
Yes | System Blockchain ID (1) |
$address |
string |
Yes | 42-character hex BEP20 wallet address (0x...) |
$response = $client->getAddressBalance(1, '0x0000000000000000000000000000000000000000'); $usdtBalance = $response['data']['usdt']; // e.g. 150.00
4. syncTransactions($chainId, $username, $address = null, $type = 1)
Queries BSC on-chain transfers, registers new incoming transactions, and triggers processing queues.
| Parameter | Type | Required | Description |
|---|---|---|---|
$chainId |
int |
Yes | System Blockchain ID (1) |
$username |
string |
Yes | User identifier |
$address |
string |
No | Optional specific address to check |
$type |
int |
No | 1 for user, 0 for admin |
$response = $client->syncTransactions(1, 'abGorad');
5. getTransactions($chainId, $username, $address = null, $page = 1, $type = 1)
Fetches paginated transaction history for a user.
| Parameter | Type | Required | Description |
|---|---|---|---|
$chainId |
int |
Yes | System Blockchain ID (1) |
$username |
string |
Yes | User identifier |
$address |
string |
No | Optional filter by wallet address |
$page |
int |
No | Page number (default: 1) |
$type |
int |
No | Account type (1 or 0) |
$response = $client->getTransactions(1, 'abGorad', null, 1);
6. getTransactionDetails($chainId, $username, $transactionId)
Retrieves full details and settlement status for a specific transaction ID.
$response = $client->getTransactionDetails(1, 'abGorad', 105); $hash = $response['data']['hash']; // On-chain Tx Hash $settled = $response['data']['settled']; // '1' = Settled, '0' = Pending
7. transferToken($chainId, $username, $targetAddress, $amount, $referenceId = null)
Initiates an outbound USDT PayOUT transaction from the system/user wallet.
| Parameter | Type | Required | Description |
|---|---|---|---|
$chainId |
int |
Yes | System Blockchain ID (1) |
$username |
string |
Yes | Sender username |
$targetAddress |
string |
Yes | Destination BEP20 wallet address (0x...) |
$amount |
float |
Yes | Amount of USDT to transfer |
$referenceId |
string |
No | Unique reference ID to prevent duplicates |
$response = $client->transferToken( 1, 'abGorad', '0x0000000000000000000000000000000000000000', 25.50, 'PAYOUT-ORD-9901' ); $transactionId = $response['data'][0]['id'];
🛠️ Error Handling
All client methods throw a UsdtPay\Exception\UsdtPayException on cURL failures, HTTP errors, or malformed gateway responses.
use UsdtPay\UsdtPayClient; use UsdtPay\Exception\UsdtPayException; try { $client = new UsdtPayClient('https://your-domain.com/', 'INVALID_API_KEY'); $result = $client->getAddress(1, 'abGorad'); } catch (UsdtPayException $e) { // Handle SDK Error echo "Gateway Exception: " . $e->getMessage(); } catch (Throwable $e) { // Handle General Exception echo "General Exception: " . $e->getMessage(); }
💡 Framework Integrations
Laravel Example
Create a service or helper in Laravel:
namespace App\Services; use UsdtPay\UsdtPayClient; class UsdtPaymentService { protected UsdtPayClient $client; public function __construct() { $this->client = new UsdtPayClient( config('services.usdt.url'), config('services.usdt.key') ); } public function generateDeposit(string $username) { return $this->client->getAddress(1, $username); } }
📞 Support & Author Details
For technical support, integration help, custom extensions, or consultation:
- 🌐 Website: https://akshaygorad.com
- 💬 WhatsApp: +91 9960 331 778
- 📅 Book Consultation: Book a Free Discovery Call
- 📲 Social Connect:
📄 License
This SDK is open-sourced software licensed under the MIT License.