PAYMENT API

ALL API ENDPOINTS ACCEPT POST METHOD ONLY

ENDPOINT URL

POST PAYMENT
https://apibd.echostricxpay.asia/payment.php

SUPPORTED METHODS

METHOD DESCRIPTION BADGE
BKASH BKASH MOBILE BANKING PAYMENT BKASH
NAGAD NAGAD MOBILE BANKING PAYMENT NAGAD
ROCKET ROCKET MOBILE BANKING PAYMENT ROCKET

REQUEST PARAMETERS

PARAMETER TYPE DESCRIPTION REQUIRED
api_key STRING YOUR UNIQUE API KEY REQUIRED
method STRING PAYMENT Method : bkash, nagad, or rocket REQUIRED
order_no STRING YOUR UNIQUE ORDER/TRANSACTION/INVOICE ID REQUIRED
amount NUMBER PAYMENT AMOUNT IN BDT (MIN : 100, MAX : 25000) REQUIRED
return_url URL WHERE USER RETURNS AFTER COMPLETING PAYMENT REQUIRED
pass_through_callback_url URL SERVER-TO-SERVER WEBHOOK NOTIFICATION URL REQUIRED

RESPONSES

SUCCESS RESPONSE

{
  "status": true,
  "countryCode": "BD",
  "orderAmount": "100",
  "orderNo": "ORDER_123456",
  "method": "bkash",
  "payType": "bkash",
  "serviceCharge": "2.00%",
  "serviceChargeAmount": "2.00",
  "merchantReceives": "98.00",
  "payUrl": "https://pay.gateway.com/bkash/..."
}

ERROR RESPONSE

{
  "status": false,
  "message": "Amount must be between 100-25000 BDT!"
}

CURL EXAMPLES

1. BKASH PAYMENT

curl -X POST https://apibd.echostricxpay.asia/payment.php \
  -d "api_key=xxxxxxxxxxxxxxxxxxxxxx" \
  -d "method=bkash" \
  -d "order_no=ORDER_1789315990" \
  -d "amount=100" \
  -d "return_url=https://your-site.com/success.php" \
  -d "pass_through_callback_url=https://your-site.com/callback.php"

2. NAGAD PAYMENT

curl -X POST https://apibd.echostricxpay.asia/payment.php \
  -d "api_key=xxxxxxxxxxxxxxxxxxxxxx" \
  -d "method=nagad" \
  -d "order_no=ORDER_1789315990" \
  -d "amount=200" \
  -d "return_url=https://your-site.com/success.php" \
  -d "pass_through_callback_url=https://your-site.com/callback.php"

3. ROCKET PAYMENT

curl -X POST https://apibd.echostricxpay.asia/payment.php \
  -d "api_key=xxxxxxxxxxxxxxxxxxxxxx" \
  -d "method=rocket" \
  -d "order_no=ORDER_1789315990" \
  -d "amount=300" \
  -d "return_url=https://your-site.com/success.php" \
  -d "pass_through_callback_url=https://your-site.com/callback.php"

PHP INTEGRATION

<?php
// PAYMENT API - PHP INTEGRATION EXAMPLE
// CHANGE $method TO : 'bkash', 'nagad', OR 'rocket'

$api_url = 'https://apibd.echostricxpay.asia/payment.php';
$api_key = 'xxxxxxxxxxxxxxxxxxxxxx';
$method = 'bkash'; // CHANGE : bkash / nagad / rocket

$params = [
    'api_key' => $api_key,
    'method' => $method,
    'order_no' => 'INV-' . time() . '-' . rand(1000, 9999),
    'amount' => 100,
    'return_url' => 'https://your-site.com/success.php',
    'pass_through_callback_url' => 'https://your-site.com/callback.php'
];

$ch = curl_init($api_url);
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query($params),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
]);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($response, true);

// Check response
if ($result && isset($result['status']) && $result['status'] === true) {
    // Success - Redirect user to payment page
    header('Location: ' . $result['payUrl']);
    exit;
} else {
    // Error
    echo 'Payment Error: ' . ($result['message'] ?? 'Unknown error');
}
?>

WEBHOOK SYSTEM

CALLBACK SYSTEM

WEBHOOK REAL-TIME
AUTOMATIC NOTIFICATION : WHEN PAYMENT STATUS CHANGES (success/failed), OUR SERVER AUTOMATICALLY SENDS A POST REQUEST TO YOUR pass_through_callback_url WITH PAYMENT DETAILS AND HMAC-SHA256 SIGNATURE

HOW WEBHOOK WORKS

1. SEND PAYMENT REQUEST
2. USER COMPLETES PAYMENT
3. GATEWAY CONFIRMS
4. WEBHOOK SENT TO CALLBACK URL

WEBHOOK PAYLOAD PARAMETERS

PARAMETER TYPE DESCRIPTION REQUIRED
order_no STRING YOUR ORDER ID THAT YOU SENT IN PAYMENT REQUEST REQUIRED
amount FLOAT ACTUAL AMOUNT PAID BY CUSTOMER REQUIRED
status STRING PAYMENT STATUS : success or failed REQUIRED
signature STRING HMAC-SHA256 HASH FOR SECURITY VERIFICATION REQUIRED
SIGNATURE VERIFICATION FORMULA
signature = HMAC-SHA256(order_no + amount, api_key)

ALWAYS VERIFY THIS SIGNATURE TO ENSURE THE WEBHOOK IS AUTHENTIC AND NOT TAMPERED WITH!

YOUR CALLBACK PHP SCRIPT

<?php
// callback.php - Your Webhook Receiver
// Place this file at your pass_through_callback_url

// ============ CONFIGURATION ============
$api_key = 'xxxxxxxxxxxxxxxxxxxxxx';  // Your API key
// =====================================

// Receive POST data from gateway
$received_signature = $_POST['signature'] ?? '';
$order_no = $_POST['order_no'] ?? '';
$amount = $_POST['amount'] ?? '';
$status = $_POST['status'] ?? '';

// Validation
if (empty($received_signature) || empty($order_no) || empty($amount)) {
    http_response_code(400);
    echo "MISSING PARAMETERS";
    exit;
}

// Verify Signature
// Formula: HMAC-SHA256(order_no + amount, api_key)
$formatted_amount = (float)$amount;
$expected_signature = hash_hmac('sha256', $order_no . $formatted_amount, $api_key);

if (hash_equals($expected_signature, $received_signature)) {
    // Signature valid - Payment is authentic!
    
    if ($status == 'success') {
        // ==========================================
        // PAYMENT SUCCESSFUL
        // ==========================================
        
        // TODO: Add your business logic here
        // - Update order status to "PAID"
        // - Add balance to user account
        // - Send confirmation email/SMS
        // - Log transaction
        
        // Example: Log to file
        $log = date('Y-m-d H:i:s') . " | SUCCESS | ORDER : {$order_no} | AMOUNT : ৳{$amount}\n";
        file_put_contents(__DIR__ . '/payments.log', $log, FILE_APPEND);
        
        echo "Success";
        
    } elseif ($status == 'failed') {
        // ==========================================
        // PAYMENT FAILED
        // ==========================================
        
        // TODO: Handle failed payment
        // - Mark order as "FAILED"
        // - Notify user
        
        $log = date('Y-m-d H:i:s') . " | FAILED | ORDER : {$order_no} | AMOUNT : ৳{$amount}\n";
        file_put_contents(__DIR__ . '/payments.log', $log, FILE_APPEND);
        
        echo "Success";
    } else {
        echo "Success";
    }
    
} else {
    // Invalid signature - Possible fraud!
    error_log("WEBHOOK : INVALID SIGNATURE FOR ORDER {$order_no}");
    http_response_code(403);
    echo "INVALID SIGNATURE";
}

// IMPORTANT: Always return "Success" so our server knows you received the webhook.
// Our system retries up to 3 times if no "Success" response is returned.
?>

SUPPORT

TELEGRAM SUPPORT : @SABBIR_ZAYAN AVAILABLE : 24/7