ChaoPaoPay API v1.0 REST API Reference Merchant Login

API Documentation

Integrate PayIn and PayOut into your application using our simple REST API. All responses are JSON.

REST HMAC-SHA256 BDT Sandbox available
Download PHP Kit Includes ready PayIn, PayOut and signature_v2 webhook verifier.

◈ Overview

Base URL

URL
http://www.chaopaopay.site/api/v1/

Request Format

All requests must be POST with Content-Type: application/json body. Responses are always JSON.

◇ Sandbox (Test Mode)

Test your integration end-to-end without moving real money. The sandbox mirrors the live API exactly — same endpoints, same callback signature.

Sandbox Base URL

URL
https://sandbox.chaopaopay.site/api/v1/

Demo Credentials

FieldValue
Merchant IDM-SANDBOX
API Keypk_test_demo1234567890ab
Secret Keysk_test_demo1234567890ab
Sandbox API keys always start with pk_test_. Live keys are rejected in the sandbox and vice versa. Payins return a hosted checkout page that auto-completes the payment and fires a signed callback to your callback_url — verify it the same way as live.

◆ Authentication

All API requests require the following HTTP headers.

HeaderValueRequired
X-API-KeyYour API Key (from merchant panel)Yes
X-Merchant-IDYour Merchant ID e.g. M2024XXXXXXYes
Content-Typeapplication/jsonYes
Secret Key is not needed for API calls — only for verifying incoming callbacks.

Example Headers

HTTP
X-API-Key: your_api_key_here
X-Merchant-ID: M2024XXXXXX
Content-Type: application/json

▦ Payment Channels

ChannelCodePayInPayOut
bKash 101 Supported Supported
Nagad 102 Supported Supported
Rocket 103 Supported Supported

Currency is always BDT. More channels may be added in the future.

↑ PayIn — Create Payment

POST /api/v1/payin/create.php

Create a payment request and redirect your customer to the payment page.

Request Parameters

ParameterTypeDescriptionRequired
trx_idstringYour unique transaction IDYes
amountdecimalPayment amount e.g. 100.50Yes
method_codeinteger101=bKash, 102=Nagad, 103=RocketYes
customer_namestringCustomer full nameYes
callback_urlstringWebhook URL for status notificationsYes
return_urlstringRedirect URL after payment completesYes
customer_emailstringCustomer emailOptional
customer_phonestringCustomer phone numberOptional
customer_addressstringCustomer addressOptional
descriptionstringPayment description / noteOptional

Example Request

PHP
$data = [
    'trx_id'         => 'PAY-' . time(),
    'amount'         => 1500.00,
    'method_code'    => 101,
    'customer_name'  => 'John Doe',
    'callback_url'   => 'https://yourdomain.com/webhook/payin',
    'return_url'     => 'https://yourdomain.com/success',
    'customer_email' => 'john@example.com',
    'customer_phone' => '+8801234567890',
];

$ch = curl_init('http://www.chaopaopay.site/api/v1/payin/create.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: YOUR_API_KEY',
    'X-Merchant-ID: YOUR_MERCHANT_ID',
]);
$result = json_decode(curl_exec($ch), true);

if ($result['success']) {
    header('Location: ' . $result['data']['payment_url']);
}

Success Response

JSON
{
    "success": true,
    "message": "Payment request created",
    "data": {
        "transaction_id": "TRX20241201ABC123",
        "trx_id": "PAY-123456",
        "amount": 1500.00,
        "currency": "BDT",
        "status": "pending",
        "payment_url": "https://gateway.chaopaopay.dev/pay/..."
    }
}

↓ PayOut — Withdrawal

POST /api/v1/payout/create.php

Submit a payout request to send funds to a bKash or Nagad account.

Request Parameters

ParameterTypeDescriptionRequired
trx_idstringYour unique transaction IDYes
amountintegerWithdrawal amount in BDT. Must be a whole number (e.g. 1000). Decimal amounts are not supported — the fractional part is dropped (e.g. 122.40 becomes 122.00).Yes
method_codeinteger101=bKash, 102=Nagad, 103=RocketYes
account_numberstringRecipient wallet numberYes
account_namestringRecipient full nameYes
notify_urlstringWebhook URL for status updatesYes
descriptionstringPayout note / referenceOptional
Amount rules: Payout amounts must be whole numbers (decimals are dropped). The recipient receives exactly amount; the merchant is charged amount + fee from their available balance. Gateway charges are separate and reported as gateway_fee in the callback.

Example Request

PHP
$data = [
    'trx_id'         => 'WIT-' . time(),
    'amount'         => 1000.00,
    'method_code'    => 101,
    'account_number' => '01712345678',
    'account_name'   => 'John Doe',
    'notify_url'     => 'https://yourdomain.com/webhook/payout',
    'description'    => 'Commission payout',
];

$ch = curl_init('http://www.chaopaopay.site/api/v1/payout/create.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: YOUR_API_KEY',
    'X-Merchant-ID: YOUR_MERCHANT_ID',
]);
$result = json_decode(curl_exec($ch), true);

Success Response

JSON
{
    "success": true,
    "message": "Payout request submitted",
    "data": {
        "transaction_id": "TRX20241201PAY456",
        "trx_id": "WIT-001",
        "amount": 1000.00,
        "fee": 20.00,
        "net_amount": 1000.00,
        "currency": "BDT",
        "status": "pending",
        "account_number": "017***5678"
    }
}

⊙ Check Status

POST /api/v1/transaction/status.php

Query the current status of any transaction.

Request

JSON
// By system transaction_id
{ "transaction_id": "TRX20241201ABC123" }

// OR by your own trx_id
{ "trx_id": "PAY-123456" }

Transaction Status Values

  • pending Awaiting payment or processing
  • processing Payment in progress
  • completed Successfully completed
  • failed Payment failed
  • cancelled Payout cancelled
  • refunded Amount refunded

↺ Webhook / Callback

We send a POST request with a JSON body to your callback_url whenever a transaction status changes.

Always verify the signature_v2 to ensure the callback is genuinely from us. Return HTTP 200 with {"success":true} to acknowledge.

Callback Payload — PayIn Success

JSON
{
    "transaction_id": "TRX20241201ABC123",
    "trx_id": "PAY-123456",
    "type": "payin",
    "amount": 1500.00,
    "paid_amount": 1500.00,
    "fee": 52.50,
    "net_amount": 1447.50,
    "currency": "BDT",
    "status": "completed",
    "gateway_trx_id": "COW-987654321",
    "gateway_payment_trx_id": "TXN-COW-11223344",
    "customer_name": "John Doe",
    "updated_at": "2024-12-01T14:35:00+06:00",
    "signature": "legacy_sha256",
    "signature_version": 2,
    "signature_v2": "hmac_sha256"
}

Callback Payload — PayOut Success

JSON
{
    "transaction_id": "TRX20241201PAY456",
    "trx_id": "WIT-001",
    "type": "payout",
    "amount": 1000.00,
    "paid_amount": 1000.00,
    "fee": 20.00,
    "net_amount": 1000.00,
    "currency": "BDT",
    "status": "completed",
    "gateway_trx_id": "COW-987654322",
    "gateway_payment_trx_id": "TXN-COW-11223345",
    "updated_at": "2024-12-01T14:40:00+06:00",
    "signature": "legacy_sha256",
    "signature_version": 2,
    "signature_v2": "hmac_sha256"
}

Field Reference

FieldTypeDescription
transaction_idstringSystem transaction ID (our side)
trx_idstringYour merchant order ID
typestringpayin or payout
amountdecimalOriginal order amount
paid_amountdecimalActual amount collected / sent by gateway (may differ on partial payment)
feedecimalPayIn: merchant fee deducted from paid_amount.
PayOut: merchant fee charged on top of amount (deducted separately from the merchant's available balance).
net_amountdecimalPayIn: merchant settlement = paid_amount − fee.
PayOut: amount received by recipient = paid_amount. The merchant's total deduction is amount + fee.
currencystringAlways BDT
statusstringcompleted, failed, cancelled, pending
gateway_trx_idstringGateway-side order ID
gateway_payment_trx_idstringGateway payment transaction ID
customer_namestringCustomer name (PayIn only)
updated_atstringCallback generation time (ISO 8601)
signaturestringLegacy SHA-256 field; retained for compatibility
signature_versionintegerAlways 2
signature_v2stringHMAC-SHA256 signature over all financial fields (see below)
Secret Key is different from your API Key. Find it in your Merchant Panel under API Settings. signature_v2 is hash_hmac('sha256', json_encode($fields, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), secret_key) over the exact field order below — not a simple concatenation. Money fields must be formatted with exactly 2 decimals.
Webhook integration: point callback_url / notify_url to your HTTPS webhook, decode JSON, rebuild the signed field array, compare with signature_v2 using hash_equals, then update your own order idempotently. Use paid_amount for actual settlement; treat unsigned fields like customer_name and updated_at as informational only. Return HTTP 200 only after your update succeeds.

signature_v2 Fields (in exact order)

ORDER
[
    transaction_id,
    trx_id,
    type,
    currency,
    status,
    amount,           // formatted: number_format($amount, 2, '.', '')
    paid_amount,      // null or number_format($paid, 2, '.', '')
    fee,              // number_format($fee, 2, '.', '')
    net_amount,       // number_format($net, 2, '.', '')
    gateway_trx_id,
    gateway_payment_trx_id
]

Verify Signature (PHP)

PHP
// Your secret key from Merchant Panel → API Settings
$secretKey = 'YOUR_SECRET_KEY_FROM_MERCHANT_PANEL';

$raw  = file_get_contents('php://input');
$data = json_decode($raw, true);

// Rebuild the exact signed fields array
$fields = [
    $data['transaction_id'],
    $data['trx_id'],
    $data['type'],
    $data['currency'],
    $data['status'],
    number_format((float)$data['amount'], 2, '.', ''),
    $data['paid_amount'] === null ? null : number_format((float)$data['paid_amount'], 2, '.', ''),
    number_format((float)$data['fee'], 2, '.', ''),
    number_format((float)$data['net_amount'], 2, '.', ''),
    $data['gateway_trx_id'],
    $data['gateway_payment_trx_id'],
];

$expected = hash_hmac(
    'sha256',
    json_encode($fields, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR),
    $secretKey
);

if (hash_equals($expected, $data['signature_v2'] ?? '')) {
    // Valid — update your order
    http_response_code(200);
    echo json_encode(['success' => true]);
} else {
    http_response_code(400);
    echo json_encode(['success' => false, 'error' => 'INVALID_SIGNATURE']);
}
Callbacks may be delivered more than once (retries). Always treat transaction_id + status as idempotent keys — update only if the status actually changed.

⚠ Error Codes

CodeHTTPDescription
AUTH_FAILED401Invalid API Key or Merchant ID
INSUFFICIENT_BALANCE402Not enough balance for payout
INVALID_PARAMS400Missing or invalid request parameters
DUPLICATE_ORDER409Transaction ID already exists
INVALID_WITHDRAW_PASS403Incorrect withdrawal password
ACCOUNT_SUSPENDED403Merchant account suspended
SERVER_ERROR500Internal server error