RazCrypto USDT Gateway

Complete USDT BEP20 Integration Documentation WITH SIMPLE STEPS

1. Sign Up & Credentials

To start using RazCrypto Payment Gateway:

  1. Register at RazCrypto Dashboard
  2. Go to Gateway Apps โ†’ Add Platform
  3. Get your credentials:
    {
      "gateway_id": "UID0001",
      "secret_key": "d4e2c4d95e87e3a0a1d353479a371b10"
    }
โš ๏ธ Important: Store secret_key securely. Never expose it in client-side code.

2. Frontend Integration

Create a simple HTML form to collect payment details:

HTML Form (recharge.html)

<form action="recharge_process.php" method="POST">
  <input type="number" name="amount" placeholder="USDT Amount" required>
  <input type="text" name="username" placeholder="Username">
  <input type="email" name="email_id" placeholder="Email">
  <button>Pay Now</button>
</form>
๐Ÿ’ก Note: Style this form with CSS to match your website's design. OR This form is just a sample. In real integration, you can remove extra input fields. Only the amount is required from the user โ€” other details (like email, username, etc.) can be sent from your own system.

3. Backend API Integration

Process the form submission and call RazCrypto API: ( https://razcryptogateway.xyz/user/create_payment.php )

Required Parameters

Parameter Type Description
gateway_id string From your dashboard
secret_key string From your dashboard
amount float USDT amount (min 1)

Sample API Call (recharge_process.php)

<?php
$postData = [
    // Required
    'gateway_id' => 'UID0001',
    'secret_key' => 'd4e2c4d95e87e3a0a1d353479a371b10',
    'amount' => $_POST['amount'],
    
    // Optional
    'username' => $_POST['username'] ?? null,
    'email_id' => $_POST['email_id'] ?? null,
    'mobile_number' => $_POST['mobile'] ?? null,
    'product_id' => $_POST['product_id'] ?? null,
    'callback_url' => 'https://yourdomain.com/webhook.php'
];


$response = file_get_contents(
    "https://razcryptogateway.xyz/user/create_payment.php", 
    false,
    stream_context_create(['http' => [
        'method'  => 'POST',
        'header'  => 'Content-Type: application/x-www-form-urlencoded',
        'content' => http_build_query($postData)
    ])
);
header("Location: " . json_decode($response)->redirect_url);
?>

Developer JSON Response (When return_json=true)

If you include return_json=true parameter, you'll receive this JSON response instead of redirect:

{
  "amount": 1.00051234,
  "address": "0xAdminWalletAddress...",
  "qr_url": "https://gateway.com/generate_qr.php?..."
}
๐Ÿ’ก Developer Note: Use these fields to build your own payment interface:
  • amount - Exact USDT amount to send
  • address - Our BEP20 wallet address
  • qr_url - QR code image URL for easy scanning

4. Optional Parameters

Additional fields you can include for better tracking:

Parameter Type Storage Table Usage Example
username string transactions_temp User identification
email_id string transactions_temp Email receipts
mobile_number string transactions_temp SMS notifications
product_id string transactions_temp Game/item tracking
subscription_id string transactions_temp Recurring billing

5. Payment Flow

sequenceDiagram User->>Frontend: Submits Form Frontend->>Backend: POST /recharge_process.php Backend->>RazCrypto: API Call RazCrypto -->>Backend: payment_id Backend->>User: Redirect to payment_view.php User->>Blockchain: Pays USDT Blockchain->>RazCrypto: Confirms TX RazCrypto->>Webhook: Sends JSON Data
๐Ÿ’ก Note: The entire process typically completes within 2-5 minutes depending on blockchain confirmation time.

6. Webhook Handling

RazCrypto will send payment confirmation to your callback URL:

Sample Response

{
  "status": "success",
  "amount": 0.15031342,
  "tx_hash": "0x....",
  "gateway_id": "UID0xxx",
  "secret_key": "e08242....",
  "payment_id": "payid_fc61830....",
  "timestamp": "2025-07-19 01:36:16",
  "invoice_url": "https://razcryptogateway.xyz/public/invoice_template.php?payment_id=payid_fc61830..."
}

Webhook Processor (webhook.php)

<?php
// ๐Ÿ” Step 0: Verify Signature (Highly Recommended)
// Replace this with your real secret_key
$your_secret_key = 'd4e2c4d95e87e3a0a1d353479a371b10';

// Step 0.1: Read header
$signature = $_SERVER['HTTP_X_RAZCRYPTO_SIGNATURE'] ?? '';

// Step 0.2: Read raw payload
$payload = file_get_contents('php://input');

// Step 0.3: Generate HMAC-SHA256
$expected_signature = hash_hmac('sha256', $payload, $your_secret_key);

// Step 0.4: Compare signatures
if ($signature !== $expected_signature) {
    file_put_contents('log.txt', "[" . date('Y-m-d H:i:s') . "] โŒ Signature Mismatch\n", FILE_APPEND);
    http_response_code(403);
    echo "Invalid Signature";
    exit;
}

// โœ… If signature valid, continue processing
$data = json_decode($payload, true);

// ๐Ÿ”น Step 1: Check if payment status is 'success'
if ($data['status'] === 'success') {

    // ๐Ÿ”น Step 2: Extract data safely
    $username = $data['username'] ?? null;
    $email    = $data['email_id'] ?? null;
    $mobile   = $data['mobile_number'] ?? null;
    $amount   = floatval($data['amount'] ?? 0);
    $product  = $data['product_id'] ?? 'NA';

    // ๐Ÿ”น Step 3: Log incoming payment details for debugging
    file_put_contents('log.txt', 
        "[" . date('Y-m-d H:i:s') . "] โœ… Received payment: User=$username, Product=$product, Amount=$amount USDT\n", 
        FILE_APPEND
    );

    // ๐Ÿ”น Step 4: Connect to your database
    require_once 'includes/db.php'; // Make sure db.php has $conn = new mysqli(...);

    // ๐Ÿ”น Step 5: Try updating balance using username
    if (!empty($username)) {
        $stmt = $conn->prepare("UPDATE users SET wallet_balance = wallet_balance + ? WHERE name = ?");
        $stmt->bind_param("ds", $amount, $username);
        $stmt->execute();
        $stmt->close();
        file_put_contents('log.txt', "[" . date('Y-m-d H:i:s') . "] ๐Ÿ’ฐ Balance updated by username: $username\n", FILE_APPEND);
    }

    // ๐Ÿ”น Step 6: If username not available, try email
    else if (!empty($email)) {
        $stmt = $conn->prepare("UPDATE users SET wallet_balance = wallet_balance + ? WHERE email = ?");
        $stmt->bind_param("ds", $amount, $email);
        $stmt->execute();
        $stmt->close();
        file_put_contents('log.txt', "[" . date('Y-m-d H:i:s') . "] ๐Ÿ’ฐ Balance updated by email: $email\n", FILE_APPEND);
    }

    // ๐Ÿ”น Step 7: If email not available, try mobile number
    else if (!empty($mobile)) {
        $stmt = $conn->prepare("UPDATE users SET wallet_balance = wallet_balance + ? WHERE phone = ?");
        $stmt->bind_param("ds", $amount, $mobile);
        $stmt->execute();
        $stmt->close();
        file_put_contents('log.txt', "[" . date('Y-m-d H:i:s') . "] ๐Ÿ’ฐ Balance updated by mobile: $mobile\n", FILE_APPEND);
    }

    // ๐Ÿ”น Step 8: Send success response back to gateway
    http_response_code(200);
    echo "OK";

} else {
    // ๐Ÿ”น If payment failed or invalid
    file_put_contents('log.txt', "[" . date('Y-m-d H:i:s') . "] โŒ Invalid or failed webhook\n", FILE_APPEND);
    http_response_code(400);
    echo "Invalid";
}?>
โš ๏ธ Security: Always validate webhook signatures to ensure requests come from RazCrypto & Store $your_secret_key in a separate config.php file or environment variable.

๐Ÿงพ How to Add "Download Invoice" Button

Once you receive the invoice_url from webhook, you can show a downloadable invoice to your end-users using the following code:

<?php
$response = json_decode($webhook_response, true);

if (!empty($response['invoice_url'])) {
    $invoice_url = $response['invoice_url']
                 . '&brand=' . urlencode("MyStore")
                 . '&logo=' . urlencode("https://mygamingstore.com/logo.png")
                 . '&item=' . urlencode("500 Diamonds Pack")
                 . '&client_name=' . urlencode("Your Name")
                 . '&email=' . urlencode("[email protected]");

    echo "<a href='$invoice_url' target='_blank'>๐Ÿงพ Download Invoice</a>";
}
?>
๐Ÿ’ก Note: You can dynamically change the brand, logo, client name, email, and item based on your own user and product data.

Required Fields: payment_id (auto from system)
Optional Branding Fields: brand, logo, item, client_name, email
If any of these fields are not passed, the system will use fallback values from the database.
โš ๏ธ Demo Incoice URL: https://razcryptogateway.xyz/public/invoice_template.php?payment_id=payid_xxxxxx&brand=MyShop&logo=https://myshop.com/logo.png&item=VIP%20Recharge& client_name=Ankit%[email protected]

7. Embed Payment

Alternative to redirect - embed payment page in your site:

Iframe Integration

<iframe 
    src="https://razcryptogateway.xyz/user/payment_view.php?payment_id=<?= $payment_id ?>" 
    width="500" height="600">
</iframe>
๐Ÿ’ก Pro Tip: Add a loading spinner while the iframe loads for better UX.

8. Security & Testing

Must Do:

  • Validate webhook signatures
  • Use HTTPS for all callbacks
  • Implement IP whitelisting (recommended)

Test Tools:

Use our sandbox environment for testing:

Test Gateway ID: TEST0001
Test Secret Key: test_d4e2c4d95e87e3a0a1d353479a371b10

9. Troubleshooting

Issue Solution
Optional fields missing Check parameter names in API call
Webhook not firing Verify callback_url is HTTPS
Payment stuck as "pending" Check blockchain for transaction confirmation
Invalid secret_key Regenerate key from dashboard

10. Frequently Asked Questions

Q: Can I use multiple currencies?

A: Currently, only USDT (BEP-20) is supported.

Q: How long does payment confirmation take?

A: Typically 2-5 minutes depending on blockchain congestion.

Q: Can I change the callback URL after creating a payment?

A: Yes, pass a new callback_url parameter with each request.

Q: Is there a minimum payment amount?

A: Yes, minimum 1 USDT.

Q: How do I handle refunds?

A: Contact our support team with the payment ID for manual processing.

Download Ready-to-Use Code

11. Developer JSON Response

When using return_json=true parameter, you'll receive this structured response:

{
  "status": "success",
  "amount": 1.00051234,
  "address": "0xAdminWalletAddress...",
  "qr_url": "https://gateway.com/generate_qr.php?...",
  "payment_id": "payid_abc123...",
  "timestamp": "2025-07-19 12:34:56"
}

Response Fields

Field Type Description
amount float Exact USDT amount with transaction fee included
address string Our BEP20 wallet address for payment
qr_url string QR code image URL containing payment details
payment_id string Unique transaction reference ID
Implementation Example:

To use this in your frontend:

// After API call
const response = {
  "amount": 1.00051234,
  "address": "0xAdminWalletAddress...",
  "qr_url": "https://gateway.com/generate_qr.php?..."
};

document.getElementById('wallet-address').innerText = response.address;
document.getElementById('payment-amount').innerText = response.amount;
document.getElementById('qr-code').src = response.qr_url;