Guide #70 Developer Integration Guide

How to Integrate FamPay UPI Payment Gateway in SMM Panels (Rental, Perfect Panel & SmartPanel)

By Aryan Gupta September 8, 2026 5 min read

Social Media Marketing (SMM) panels process thousands of micro-transactions every single day, ranging from INR 10 to INR 500. However, traditional payment aggregators like Razorpay, Cashfree, and PayU routinely reject SMM panels, freeze merchant funds, and demand formal business GSTIN credentials. In this comprehensive developer guide, we explore how to integrate FamPay and FamGateway into your SMM panel (Rental Panel, Perfect Panel, SmartPanel, or custom PHP) to automate user balance top-ups with zero GST, 0% fees, atomic MySQL transactions, and instant webhook confirmation.

Direct Answer • AEO Overview

How do SMM panels automate UPI payments with FamPay? SMM panels integrate FamGateway by sending order parameters (amount, customer identifier, callback webhook URL) via POST https://famgateway.in/api/create-order authenticated with an X-Api-Key header. FamGateway creates a dynamic order valid for strictly 300 seconds (5 minutes) and returns a hosted checkout URL and dynamic QR code. When the customer pays using any UPI app (Google Pay, PhonePe, Paytm, FamPay), FamGateway's backend verifies the credit and dispatches an X-FamGateway-Signature HMAC-SHA256 webhook to the SMM panel callback endpoint. The SMM script validates the signature against the merchant's API key, enforces bank UTR deduplication, and runs an atomic SQL query (UPDATE users SET balance = balance + :amount WHERE id = :user_id) to credit funds instantly without human intervention.

1. System Architecture: Automated SMM Balance Pipeline

The diagram below illustrates the exact end-to-end data flow between your SMM panel user, your server, the FamGateway API cluster, and your connected UPI app:

+-------------------+ +-----------------------+ +------------------------+ | SMM Panel User | | SMM Panel Server | | FamGateway Cluster | +-------------------+ +-----------------------+ +------------------------+ | | | | 1. Enter INR 100 | | | Click "Add Funds (UPI)" | | |---------------------------->| | | | 2. POST /api/create-order | | | Headers: X-Api-Key | | |------------------------------>| | | | 3. Generate Order | | | TTL: Exactly 300s | | 4. Return Checkout URL & QR | Unique dynamic QR | |<------------------------------| | 5. Redirect to Checkout | | |<----------------------------| | | | | | 6. Scan QR & Pay INR 100 via UPI App (GPay/PhonePe/FamPay) | |------------------------------------------------------------>| | | | 7. Ingest Bank Receipt | | | Verify 12-Digit UTR | | 8. Signed Webhook Callback | Apply Mutex Lock | | Header: Signature (HMAC) | | |<------------------------------| | | | | | 9. Validate Signature | | | Deduplicate Bank UTR | | | Execute SQL Transaction: | | | balance = balance + 100 | | | | | 10. Dashboard Reflects New Balance in Under 3 Seconds | |<----------------------------| |

2. Traditional Gateways vs. FamGateway for SMM Panels

Running an SMM panel without automated payment processing leads to severe customer churn, abandoned deposits, and operational bottlenecks. Here is how FamGateway compares directly against legacy payment methods:

Feature / Metric Razorpay / Cashfree Manual Static QR FamGateway Engine
GSTIN Requirement Mandatory None Zero (Personal UPI)
Settlement Speed T+2 to T+3 Days Immediate to Bank Real-Time Direct P2P
SMM Account Risk High (Frequent Freeze) High (Fake Receipts) Zero (Non-Custodial)
Transaction Fee (MDR) 2% + 18% GST 0% 0% Lifetime
Fake Screenshot Risk Zero Extreme Danger Zero (Cryptographic UTR Match)

3. Step 1: Initiating Orders via FamGateway REST API

When an SMM panel user submits a fund addition form, your backend script creates an order by sending an HTTP POST request to https://famgateway.in/api/create-order. Below are production implementations across PHP, Python, and Node.js:

PHP cURL Implementation (SmartPanel & Custom PHP)

<?php
function createFamGatewayOrder($userId, $amount, $userEmail) {
    $apiKey = "YOUR_LIVE_FAMGATEWAY_API_KEY"; // Retrieved from FamGateway Merchant Dashboard
    $endpoint = "https://famgateway.in/api/create-order";

    $postData = [
        "amount"       => number_format($amount, 2, '.', ''),
        "redirect_url" => "https://yourpanel.com/addfunds?status=success",
        "webhook_url"  => "https://yourpanel.com/api/famgateway-callback.php",
        "custom_id"    => "USER_" . $userId . "_" . time()
    ];

    $ch = curl_init($endpoint);
    curl_setopt_array($ch, [
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => json_encode($postData),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT        => 10,
        CURLOPT_HTTPHEADER     => [
            "Content-Type: application/json",
            "X-Api-Key: " . $apiKey
        ]
    ]);

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curlError = curl_error($ch);
    curl_close($ch);

    if ($curlError) {
        throw new Exception("cURL error: " . $curlError);
    }

    $result = json_decode($response, true);
    if ($httpCode === 200 && isset($result['checkout_url'])) {
        return $result; // Contains order_id, checkout_url, qr_image, expires_in (300s)
    }

    throw new Exception("Order creation failed: " . ($result['message'] ?? 'Unknown error'));
}

Node.js Fetch Implementation

async function createSmmOrder(userId, amount) {
    const response = await fetch("https://famgateway.in/api/create-order", {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "X-Api-Key": process.env.FAMGATEWAY_API_KEY
        },
        body: JSON.stringify({
            amount: parseFloat(amount).toFixed(2),
            redirect_url: "https://yourpanel.com/addfunds?status=success",
            webhook_url: "https://yourpanel.com/api/famgateway-callback.php",
            custom_id: `USER_${userId}_${Date.now()}`
        })
    });

    const data = await response.json();
    if (!response.ok) {
        throw new Error(data.message || "Failed to create order");
    }
    return data; // Returns checkout_url, order_id, qr_image
}

4. Database Schema: Preventing Race Conditions & Double Spending

SMM panels must protect against double-crediting if two webhooks fire concurrently or if a buyer attempts to replay a completed bank UTR. Execute the following SQL DDL schema in your MySQL database:

-- 1. Create Dedicated Payments Audit Table
CREATE TABLE IF NOT EXISTS `smm_payments` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED NOT NULL,
  `order_id` VARCHAR(64) NOT NULL UNIQUE,
  `amount` DECIMAL(10,2) NOT NULL,
  `utr` VARCHAR(32) DEFAULT NULL,
  `status` ENUM('pending', 'completed', 'expired', 'failed') NOT NULL DEFAULT 'pending',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_user_status` (`user_id`, `status`),
  UNIQUE KEY `uk_utr_completed` (`utr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 2. Ensure Users Table Has Fast Indexing on Primary Key
-- UPDATE users SET balance = balance + :amount WHERE id = :user_id;

5. Production Webhook Callback Handler (PHP & MySQL)

Save the following script on your server as api/famgateway-callback.php. It verifies the cryptographic HMAC signature, applies row-level pessimistic locking (SELECT ... FOR UPDATE), checks for unique UTR enforcement, and credits the user's SMM panel balance atomically:

<?php
// api/famgateway-callback.php
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');

// 1. Read Raw Incoming HTTP Payload
$rawPayload = file_get_contents('php://input');
if (empty($rawPayload)) {
    http_response_code(400);
    echo json_encode(['status' => 'error', 'message' => 'Empty request body']);
    exit;
}

$data = json_decode($rawPayload, true);
if (!is_array($data) || empty($data['order_id']) || empty($data['status'])) {
    http_response_code(400);
    echo json_encode(['status' => 'error', 'message' => 'Malformed payload']);
    exit;
}

// 2. Cryptographic Signature Verification
// FamGateway signs the payload using HMAC-SHA256 with the merchant API key
$apiKey = "YOUR_LIVE_FAMGATEWAY_API_KEY";
$receivedSignature = $_SERVER['HTTP_X_FAMGATEWAY_SIGNATURE'] ?? '';

if (empty($receivedSignature)) {
    http_response_code(401);
    echo json_encode(['status' => 'error', 'message' => 'Missing cryptographic signature header']);
    exit;
}

$expectedSignature = hash_hmac('sha256', $rawPayload, $apiKey);
if (!hash_equals($expectedSignature, $receivedSignature)) {
    http_response_code(401);
    echo json_encode(['status' => 'error', 'message' => 'Signature mismatch']);
    exit;
}

// 3. Process Only Cleared Payments
if ($data['status'] !== 'success') {
    http_response_code(200);
    echo json_encode(['status' => 'ignored', 'message' => 'Non-success event acknowledged']);
    exit;
}

$orderId = trim((string)$data['order_id']);
$amount  = (float)$data['amount'];
$utr     = trim((string)($data['utr'] ?? ''));

// 4. Database Connection via PDO
$dbHost = '127.0.0.1';
$dbName = 'your_smm_database';
$dbUser = 'your_db_username';
$dbPass = 'your_db_password';

try {
    $pdo = new PDO("mysql:host={$dbHost};dbname={$dbName};charset=utf8mb4", $dbUser, $dbPass, [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
    ]);

    // Begin ACID Transaction
    $pdo->beginTransaction();

    // Acquire Exclusive Row Lock on Payment Record
    $stmt = $pdo->prepare("SELECT id, user_id, amount, status FROM smm_payments WHERE order_id = :order_id FOR UPDATE");
    $stmt->execute([':order_id' => $orderId]);
    $payment = $stmt->fetch();

    if (!$payment) {
        // Order not found in local table
        $pdo->rollBack();
        http_response_code(404);
        echo json_encode(['status' => 'error', 'message' => 'Order record not found']);
        exit;
    }

    if ($payment['status'] === 'completed') {
        // Already processed via polling or duplicate webhook
        $pdo->rollBack();
        http_response_code(200);
        echo json_encode(['status' => 'success', 'message' => 'Order already fulfilled']);
        exit;
    }

    // Verify Bank UTR Uniqueness Across All Completed Payments
    if (!empty($utr)) {
        $utrStmt = $pdo->prepare("SELECT id FROM smm_payments WHERE utr = :utr AND status = 'completed'");
        $utrStmt->execute([':utr' => $utr]);
        if ($utrStmt->fetch()) {
            $pdo->rollBack();
            http_response_code(409);
            echo json_encode(['status' => 'error', 'message' => 'Bank UTR collision detected']);
            exit;
        }
    }

    // Update Payment Record to Completed
    $updatePayment = $pdo->prepare("UPDATE smm_payments SET status = 'completed', utr = :utr, updated_at = NOW() WHERE id = :id");
    $updatePayment->execute([
        ':utr' => $utr,
        ':id'  => $payment['id']
    ]);

    // Atomically Credit User Account Balance in SMM Users Table
    $updateUser = $pdo->prepare("UPDATE users SET balance = balance + :credit_amount WHERE id = :user_id");
    $updateUser->execute([
        ':credit_amount' => $payment['amount'],
        ':user_id'       => $payment['user_id']
    ]);

    // Commit Transaction
    $pdo->commit();

    http_response_code(200);
    echo json_encode([
        'status'  => 'success',
        'message' => 'SMM account balance updated successfully',
        'order_id' => $orderId,
        'credited' => $payment['amount']
    ]);

} catch (Throwable $e) {
    if (isset($pdo) && $pdo->inTransaction()) {
        $pdo->rollBack();
    }
    http_response_code(500);
    echo json_encode(['status' => 'error', 'message' => 'Internal database processing failure']);
}

6. Configuring Rental Panel & Perfect Panel Settings

Rental Panel and Perfect Panel provide graphical custom gateway interfaces in their administrator settings. Follow these precise configuration parameters:

  1. Navigate to Admin Area > Settings > Payments > Add Gateway.
  2. Select Custom REST API. Set the title to Instant UPI Auto Add Funds (FamPay / GPay / PhonePe / Paytm).
  3. Fill in the gateway connection parameters:
    • Gateway URL: https://famgateway.in/api/create-order
    • HTTP Method: POST
    • Content-Type: application/json
    • Header Key: X-Api-Key
    • Header Value: your_live_api_key
  4. Configure the parameter mapping template:
    • amount{amount}
    • redirect_urlhttps://yourpanel.com/addfunds?status=success
    • webhook_urlhttps://yourpanel.com/api/famgateway-callback.php
    • custom_id{order_id}
  5. Set minimum deposit to INR 10 and maximum deposit according to your UPI profile limits.
  6. Enable the gateway for all active customer groups.

7. Active Status Polling Fallback: Dealing with Webhook Delays

What happens if your SMM panel hosting provider has Cloudflare "Under Attack" mode enabled, temporarily blocking inbound webhooks? FamGateway supports active status polling via GET /api/checkout-status.php?order_id=ORD_xxx:

<?php
function pollOrderStatus($orderId) {
    $url = "https://famgateway.in/api/checkout-status.php?order_id=" . urlencode($orderId);
    $response = file_get_contents($url);
    if ($response === false) {
        return ['status' => 'unknown'];
    }
    return json_decode($response, true);
}
// Returns: {"status": "success", "amount": 100.00, "utr": "624389102455", ...}

You can run a background cron job every 2 minutes on your SMM server to sweep any pending records in smm_payments created in the last 10 minutes, ensuring 100% balance settlement even during hosting maintenance windows.

8. Troubleshooting & Error Resolution Matrix

Review this reference table when debugging your SMM panel integration:

Error Condition Probable Cause Resolution Step
HTTP 401 Unauthorized Missing or invalid X-Api-Key header Verify API key in FamGateway dashboard under API Keys tab.
HTTP 422 Unprocessable Amount is below minimum INR 1.00 or non-numeric Format amount as string or float with 2 decimals (e.g., 100.00).
Signature Mismatch Using wrong secret key or modified body string Compute HMAC against raw php://input using your live API key.
Expired Order (300s TTL) Buyer scanned QR after the 5-minute validity window Have user re-generate a fresh checkout session from the SMM panel.

9. Frequently Asked Questions (SMM Panels)

Can I integrate FamPay UPI payment gateway into any SMM panel script?

Yes. FamGateway provides standard REST API endpoints (POST /api/create-order) and instant HMAC-SHA256 webhooks that integrate seamlessly into all major SMM panel scripts, including Rental Panel, Perfect Panel, SmartPanel, and custom PHP SMM codebases.

Do SMM panel owners need a GST number or business bank account?

No. Traditional aggregators like Razorpay and Cashfree reject SMM panels due to lack of GST certificates and strict merchant category codes. FamGateway operates peer-to-peer into your personal UPI ID (@fam), requiring zero GST registration and no corporate current account.

How does the auto-add fund balance workflow operate?

When an SMM panel user enters a deposit amount and selects UPI, the panel calls FamGateway to generate a dynamic order with a unique QR code. Once the customer pays via GPay, PhonePe, Paytm, or FamPay, FamGateway detects the credit and triggers an HMAC-signed webhook callback to your SMM panel, which immediately executes an atomic SQL balance increment.

Are there any transaction fees or commissions charged on SMM panel payments?

No. FamGateway charges 0% merchant transaction fees (0% MDR). 100% of customer funds settle instantly into your personal UPI account without escrow holding or rolling reserves.

How does FamGateway prevent fake payment screenshots on SMM panels?

FamGateway completely eliminates manual screenshot verification. Funds are credited purely when the 12-digit bank UTR and exact transaction amount are matched by the background verification engine and validated against tamper-proof HMAC signatures.

What happens if a user closes the checkout tab before the webhook fires?

Because FamGateway operates asynchronously, the payment verification does not depend on the user's browser staying open. Our background sync daemon scans active orders within the 15-minute sweep window and delivers the signed webhook directly to your server as soon as the bank confirmation arrives.

What is the secret key used to verify FamGateway webhooks?

FamGateway signs webhook payloads using the merchant's live API Key using HMAC-SHA256. In your callback script, compute hash_hmac('sha256', $rawPayload, $apiKey) and compare it against the X-FamGateway-Signature HTTP request header using hash_equals().

Topic Cluster & Series

Related Developer Guides & Resources

View All 70+ Guides →
WooCommerce

How to Accept UPI Payments on WooCommerce Without GST or Current Account (2026 Guide)

Complete tutorial on accepting automated UPI payments on WooCommerce without GST or a commercial current ac...

Read Guide →
Telegram Bot

How to Accept Automated UPI Payments in Telegram Bots (Python & Node.js Guide)

Step-by-step tutorial on accepting automated UPI payments in Telegram shop bots using Python (FastAPI) and ...

Read Guide →
Discord & Gaming

Best UPI Payment Gateway for Discord Bots & Gaming Communities (Zero GST & Instant Roles)

Discover the best UPI payment gateway for Discord bots and gaming servers in India. Automate VIP role assig...

Read Guide →

Back to Homepage →

About the Platform

FamGateway is an official unit of ARYANISPE, founded by Aryan Gupta (Aryanispe) and officially registered under the Ministry of Micro, Small and Medium Enterprises (MSME), Government of India (Reg: UDYAM-BR-28-0050000).

All Systems Operational