Overview & Authentication
The Zyx Pay API allows you to initiate automated customer checkouts, verify completed payments, and receive real-time webhook notifications. All requests must use HTTPS and include your Merchant API Key.
Provide your API key either as a standard HTTP header or directly in the JSON POST payload:
1. Copy your live API key from your Merchant Dashboard → API & Webhooks. Do not leave the placeholder text YOUR_API_KEY.
2. Ensure your merchant account has an active subscription package from the Subscription page.
Create Payment Request
Initiate a payment request. The API responds with a secure, hosted checkout link (payment_url). Redirect your customer to this URL to complete payment via bKash, Nagad, Rocket, or Upay.
By default, leaving payment_method omitted generates a payment_url that opens the official payment method selection screen. Customers choose between your active connected payment methods (bKash, Nagad, Rocket, or Upay).
- Dynamic Available Wallets: Only wallets currently connected and active on your merchant account are displayed. Disconnected wallets (e.g. Upay if not added) are automatically hidden and cannot be opened.
- Direct Gateway Bypass (Optional): If you explicitly pass
payment_method(e.g.bkash,nagad,rocket, orupay), customer is taken directly to that channel's interface.
Request Parameters (JSON Body)
| Field | Type | Requirement | Format / Pattern | Description & Example |
|---|---|---|---|---|
| api_key | string | Required | zyx_live_[a-f0-9]+ | Your live Merchant API Key from Dashboard. (Or pass via X-API-KEY header). |
| amount | float | Required | ^\d+(\.\d{1,2})?$ | Payable amount in BDT. Min 1.00. Examples: 500.00, 1250. |
| order_id | string | Required | Max 100 chars | Your store's internal invoice or order number. Examples: INV-84920, ORD_1001. |
| payment_method | string | Optional | bkash | nagad | rocket | upay | Specific payment channel. If omitted, opens the payment options choice page where customer selects from your connected wallets. If specified (and active), opens that gateway directly. |
| customer_phone | string | Optional | ^01[3-9]\d{8}$ | Customer's 11-digit Bangladeshi mobile number (e.g. 01712345678). Auto-fills into the official bKash/Nagad box! |
| customer_name | string | Optional | Max 100 chars | Customer's full name. Example: Abu Sayed Dipon. |
| customer_email | string | Optional | RFC 5322 Email | Customer's email address for digital payment receipts. Example: user@example.com. |
| success_url | string (URL) | Required | https?://... | Redirect destination when payment is verified successfully. Example: https://mystore.com/order/success. |
| cancel_url | string (URL) | Required | https?://... | Redirect destination if customer clicks Cancel. Example: https://mystore.com/order/cancel. |
curl -X POST "https://zyxpay.cyou/api/payment/create" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_LIVE_API_KEY" \
-d '{
"amount": 1500.00,
"order_id": "ORD-1004",
"payment_method": "bkash",
"customer_email": "customer@example.com",
"customer_phone": "01700000000",
"success_url": "https://yourwebsite.com/payment/success",
"cancel_url": "https://yourwebsite.com/payment/cancel"
}'
Success Response (200 OK)
{
"status": 1,
"message": "Payment session initialized successfully",
"transaction_id": "TRX9A8B7C6D5E",
"payment_url": "https://zyxpay.cyou/pay/bkash/TRX9A8B7C6D5E",
"payment_method": "bkash",
"amount": 1500.00,
"currency": "BDT",
"metadata": {
"order_id": "ORD-1004",
"customer_name": "Abu Sayed Dipon",
"customer_email": "customer@example.com",
"customer_phone": "01700000000"
}
}
Response Fields Specification
| Field | Type | Format / Values | Description |
|---|---|---|---|
| status | integer | 1 | 0 | 1 indicates session created successfully; 0 indicates an error. |
| transaction_id | string | TRX[0-9A-Z]+ | Unique internal gateway transaction reference (e.g. TRX9A8B7C6D5E). Use this ID to verify or check status. |
| payment_url | string (URL) | https://zyxpay.cyou/pay/{method}/{TRX} | Redirect destination for your customer. Directly opens the official gateway UI without intermediate forms. |
| payment_method | string | bkash | nagad | rocket | upay | The initialized checkout channel brand. |
| amount | float | 1500.00 | Total payable amount charged to customer in BDT. |
Error Codes & Troubleshooting Guide
| HTTP Code | Error Code | Reason | Solution |
|---|---|---|---|
| 401 Unauthorized | INVALID_API_KEY | API Key was missing, mistyped, or contains the placeholder YOUR_LIVE_API_KEY. |
Copy your key from Dashboard → API & Webhooks. |
| 403 Forbidden | PACKAGE_REQUIRED | Merchant subscription package is expired or not activated. | Renew or subscribe to a plan from Dashboard → Subscription. |
| 403 Forbidden | INACTIVE_ACCOUNT | Merchant account status is pending review or suspended. | Contact platform administrator or support team to activate account. |
| 403 Forbidden | IP_NOT_WHITELISTED | Caller server IP address does not match your IP whitelist. | Add your server's outbound IP in Dashboard Security settings or leave blank. |
| 400 Bad Request | VALIDATION_ERROR | Amount ≤ 0 or missing success_url / cancel_url. |
Pass valid positive amount (e.g. 500.00) and complete HTTPS URLs. |
Verify Payment Request
Verify the current status and settlement confirmation of any transaction before fulfilling digital orders or granting user access. Accepts your gateway transaction_id, bank trx_id, or store order_id.
Verify Request Parameters (JSON Body)
| Field | Type | Requirement | Description & Accepted Values |
|---|---|---|---|
| transaction_id | string | Required | The session identifier returned by Create API (e.g. TRX9A8B7C6D5E) or your internal order_id or SMS trx_id. |
curl -X POST "https://zyxpay.cyou/api/payment/verify" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_LIVE_API_KEY" \
-d '{
"transaction_id": "TRX9A8B7C6D5E"
}'
Verified Response (200 OK)
{
"status": 1,
"transaction_id": "TRX9A8B7C6D5E",
"order_id": "ORD-1004",
"amount": 1500.00,
"trx_id": "9H8B7F6D",
"payment_method": "bkash",
"sender_number": "01712345678",
"payment_status": "completed",
"completed_at": "2026-11-02 20:30:15"
}
Verification Output Schema
| Field | Type | Values / Pattern | Description |
|---|---|---|---|
| status | integer | 1 | 0 | 1 = Completed & Verified via Bank SMS; 0 = Pending or Failed. |
| payment_status | string | completed | pending | failed | Current real-time status of the transaction. |
| trx_id | string | Alphanumeric | Official bank SMS Transaction ID (e.g. bKash TrxID 9H8B7F6D). |
| sender_number | string | 01[3-9]XXXXXXXX | Customer's bKash / Nagad / Rocket paying mobile number captured via SMS. |
| completed_at | string (datetime) | YYYY-MM-DD HH:MM:SS | Timestamp when payment was confirmed. null if pending. |
Submit Transaction ID API (Offline Recovery)
When customers pay via bKash, Nagad, Rocket, or Upay, they receive a bank confirmation SMS with a unique Transaction ID (trx_id, e.g. 9H8B7F6D). If your Android sync phone was offline (no internet, low battery, power outage, or sleeping), your server has not yet received that SMS.
1. Submit TrxID Anytime: When you or your customer submits the bank trx_id, if the phone is offline, the gateway safely records the transaction in pending state awaiting phone sync.
2. Automatic Reconciliation on APK Sync: As soon as your Android phone connects to the internet and the Zyx Pay APK syncs, the gateway automatically verifies all pending details (exact TrxID, exact amount, merchant ID, and anti-fraud replay check). If all details match, it immediately changes the order to completed, credits your merchant wallet balance, and dispatches your real-time webhook!
Submit Request Parameters (JSON Body)
| Field | Type | Requirement | Description & Accepted Values |
|---|---|---|---|
| transaction_id | string | Required | Gateway transaction identifier (e.g. TRX9A8B7C6D5E) or your internal order_id (e.g. ORD-1004). |
| trx_id | string | Required | The bank transaction reference from the customer (e.g. bKash / Nagad TrxID 9H8B7F6D). Min 4 characters. |
| sender_number | string | Optional | Customer's 11-digit mobile number used to send money (e.g. 01712345678). |
| payment_method | string | Optional | Payment provider used: bkash, nagad, rocket, or upay. |
curl -X POST "https://zyxpay.cyou/api/payment/submit-trx" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_LIVE_API_KEY" \
-d '{
"transaction_id": "TRX9A8B7C6D5E",
"trx_id": "9H8B7F6D",
"sender_number": "01712345678",
"payment_method": "bkash"
}'
Case A: SMS Already Synced (Instant Verified)
{
"status": 1,
"code": "PAYMENT_COMPLETED",
"payment_status": "completed",
"message": "Payment verified and completed automatically.",
"transaction_id": "TRX9A8B7C6D5E",
"order_id": "ORD-1004",
"amount": 1500.00,
"trx_id": "9H8B7F6D",
"payment_method": "bkash",
"sender_number": "01712345678",
"completed_at": "2026-11-16 19:20:10"
}
Case B: Device Offline (Queued for APK Sync)
{
"status": 1,
"code": "TRX_SUBMITTED_PENDING_SYNC",
"payment_status": "pending",
"message": "Transaction ID recorded. Mobile device is currently offline or SMS is pending sync. Order will be automatically verified once device syncs.",
"transaction_id": "TRX9A8B7C6D5E",
"order_id": "ORD-1004",
"amount": 1500.00,
"trx_id": "9H8B7F6D",
"payment_method": "bkash",
"sender_number": "01712345678",
"completed_at": null
}
Payment Status Polling
Lightweight real-time check endpoint used by front-end clients to poll transaction status without exposing merchant API keys:
GET https://zyxpay.cyou/api/pay-status?id=TRX_9A8B7C6D5E
No-Code Hosted Payment Links & QR Codes
If you don't want to write API code, you can generate Payment Links directly from your merchant dashboard. Each link provides:
Displays customer details & payment method picker: https://zyxpay.cyou/pay-link/PAY...
Directly opens official bKash gateway page: https://zyxpay.cyou/pay-link/bkash/PAY...
Directly opens official Nagad gateway page: https://zyxpay.cyou/pay-link/nagad/PAY...
Append ?phone=017XXXXXXXX&direct=1 to any payment link to automatically populate the customer account number on the bKash/Nagad screen.
Instant Server Webhooks (IPN)
When an SMS arrives on your connected Android phone and matches a customer transaction, Zyx Pay instantly sends an HTTP POST request to your configured webhook_url.
{
"event": "payment.completed",
"transaction_id": "TRX_9A8B7C6D5E",
"order_id": "ORD-1004",
"amount": 1500.00,
"payment_method": "bkash",
"trx_id": "9H8B7F6D",
"sender_number": "017XXXXXXXX",
"status": "completed",
"timestamp": "2026-10-13 00:25:10"
}
<?php
// webhook.php on your server
$raw = file_get_contents('php://input');
$data = json_decode($raw, true);
if (!empty($data) && $data['status'] === 'completed') {
$orderId = $data['order_id'];
$trxId = $data['trx_id'];
$amount = (float)$data['amount'];
// Update your database: Mark order paid
// e.g., updateOrderStatus($orderId, 'paid', $trxId);
// Respond with 200 OK
http_response_code(200);
echo json_encode(['status' => 'received']);
exit;
}
http_response_code(400);
echo "Invalid payload";
?>
Handling Cancelled Payments (cancel_url)
When a customer clicks Cancel / বন্ধ করুন or closes the hosted bKash or Nagad checkout page, Zyx Pay cancels the session and automatically redirects the customer back to your configured cancel_url (e.g. https://yourstore.com/cancel or fallback https://zyxpay.cyou/cancel).
The redirect URL appends complete context so your application can restore the customer's shopping cart or offer another payment option:
GET https://yourstore.com/cancel?transaction_id=TRX_9A8B7C6D5E&order_id=ORD-1004&amount=1500.00&status=cancelled
| Parameter | Type | Description |
|---|---|---|
| transaction_id | string | Unique Zyx Pay transaction ID (e.g. TRX_9A8B7C6D5E) |
| order_id | string | Your internal order reference passed during payment creation |
| amount | numeric | The order amount in BDT |
| status | string | Always returns cancelled |
<?php
// cancel.php on your e-commerce store
$orderId = $_GET['order_id'] ?? null;
$trxId = $_GET['transaction_id'] ?? null;
$status = $_GET['status'] ?? null;
if ($status === 'cancelled') {
// 1. Release reserved cart stock or mark order abandoned
// 2. Show friendly message to customer with retry checkout button:
echo "<h1>Payment was cancelled</h1>";
echo "<p>Order #" . htmlspecialchars($orderId) . " has not been charged.</p>";
echo "<a href='/checkout?order=" . urlencode($orderId) . "'>Try Again</a>";
}
?>
Mobile Android App Sync
The Zyx Pay Mobile Sync App installs on any Android phone (Android 5.0 through 14+) receiving bKash, Nagad, Rocket, or Upay payment notification SMS.
Open the app, tap Scan QR, and point the camera at your dashboard QR code. Your Device Key and API endpoint configure instantly.
When SMS arrives from 16247 (bKash) or 16167 (Nagad), the app parses the TrxID and posts it to /api/add-data within 300ms.
Drop-in PHP Client Class
Copy and paste this helper class into any PHP project to integrate payments in under two minutes:
<?php
class ZyxPay {
private $apiKey;
private $baseUrl = 'https://zyxpay.cyou/api';
public function __construct($apiKey) {
$this->apiKey = $apiKey;
}
public function createPayment($amount, $orderId, $successUrl, $cancelUrl, $email = '', $phone = '') {
$data = [
'amount' => $amount,
'order_id' => $orderId,
'customer_email' => $email,
'customer_phone' => $phone,
'success_url' => $successUrl,
'cancel_url' => $cancelUrl
];
return $this->request('/payment/create', $data);
}
public function verifyPayment($transactionId) {
return $this->request('/payment/verify', ['transaction_id' => $transactionId]);
}
public function submitTransactionId($transactionId, $trxId, $senderNumber = '', $paymentMethod = '') {
return $this->request('/payment/submit-trx', [
'transaction_id' => $transactionId,
'trx_id' => $trxId,
'sender_number' => $senderNumber,
'payment_method' => $paymentMethod
]);
}
private function request($endpoint, $payload) {
$ch = curl_init($this->baseUrl . $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-API-KEY: ' . $this->apiKey
]);
$res = curl_exec($ch);
curl_close($ch);
return json_decode($res, true);
}
}
?>
Offline Device Recovery & Sync Cron Job
Sometimes an Android device receiving MFS payment SMS goes offline (due to intermittent network, battery saver, or phone reboot). During this period, customers continue paying on your website and those orders remain in PENDING status.
The moment the phone comes back online or whenever your automated cron runs, Zyx Pay reconciles and matches all queued pending transactions against the newly received SMS logs, automatically marks transactions COMPLETED, credits your merchant wallet balance, and dispatches instant webhook notifications!
Whenever the Android app reconnects to the network, it instantly pings /api/device-connect and auto-triggers backlog reconciliation.
Matches by TrxID, paying customer phone number (last 10 digits), and exact transaction amount within a configurable lookback window (default: 48 hours).
Set up a scheduled cron job (every 1 to 5 minutes) on your server or cPanel to ensure zero human intervention is ever needed.
Scheduled Cron Setup Options
*/2 * * * * curl -s "https://zyxpay.cyou/api/cron-sync" > /dev/null 2>&1
curl -s -X GET "https://zyxpay.cyou/api/cron-sync?api_key=YOUR_API_KEY&hours=48"
php /path/to/php-web/api/cron-sync.php --hours=48
Sync Query Parameters
| Parameter | Type | Requirement | Default | Description |
|---|---|---|---|---|
| api_key | string | Optional | null (all active) | Pass your merchant API key to scope the sync strictly to your own account. |
| hours | integer | Optional | 48 | Lookback window in hours (between 1 and 168 hours / 7 days). |
Sync JSON Response (200 OK)
{
"status": 1,
"timestamp": "2026-11-02 21:45:00",
"merchant_filter": "Global (All Active Merchants)",
"lookback_hours": 48,
"scanned_pending": 6,
"matched_completed": 2,
"devices_marked_offline": 0,
"matched_transactions": [
{
"transaction_id": "TRX9A8B7C6D5E",
"order_id": "ORD-1004",
"amount": 600.00,
"payment_method": "bkash",
"trx_id": "BLM39402X",
"sender_number": "017XXXXXXXX",
"sms_log_id": 142,
"confirmed_at": "2026-11-02 21:45:00"
}
],
"message": "Reconciliation completed. Successfully matched and completed 2 pending transactions."
}