1. Sign Up & Credentials
To start using RazCrypto Payment Gateway:
- Register at RazCrypto Dashboard
- Go to Gateway Apps โ Add Platform
- Get your credentials:
{ "gateway_id": "UID0001", "secret_key": "d4e2c4d95e87e3a0a1d353479a371b10" }
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>
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
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";
}?>
๐งพ 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>";
}
?>
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.
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>
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
A: Currently, only USDT (BEP-20) is supported.
A: Typically 2-5 minutes depending on blockchain congestion.
A: Yes, pass a new callback_url
parameter with each request.
A: Yes, minimum 1 USDT.
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 |
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;