POST https://<your-api-domain>/payment/query

Read-only lookup for a payment order created via /payment/create or /payment/create-transfer. Use this as a fallback when a callback is missed or to reconcile state.

เรียกดู order ที่สร้างจาก /payment/create หรือ /payment/create-transfer — ใช้ fallback เวลา callback หายหรือทำ reconciliation

Webhook is the source of truth
ใช้ Webhook เป็นหลัก

Don't poll this endpoint as your primary signal. Listen for the webhook callback and use /payment/query only when the callback fails to arrive within the expected window.

อย่า poll endpoint นี้เป็นช่องทางหลัก — ให้ฟัง callback webhook ก่อน แล้วเรียก /payment/query เฉพาะเมื่อ callback มาช้ากว่ากำหนด

Request

Request

Body fields

Body fields

FieldTypeRequiredNotes ฟิลด์ประเภทบังคับหมายเหตุ
merchant_id string Yes Your merchant identifier. merchant_id string Yes รหัส merchant
token string Yes Your API token. token string Yes API token
time number | string Yes Unix epoch (seconds). See Authentication. time number | string Yes Unix epoch (วินาที) — ดู Authentication
platform_order_id string Yes The order ID returned by /payment/create. Format: <3-char prefix>P<YYYYMMDD><12 random alphanumeric chars> — 24 characters total. platform_order_id string Yes Order ID ที่ได้จาก /payment/create — รูปแบบ: <prefix 3 ตัวอักษร>P<YYYYMMDD><12 ตัวสุ่ม> รวม 24 ตัว

Code samples

ตัวอย่างโค้ด

TIME=$(date +%s)
BODY="{\"merchant_id\":\"AA12345678\",\"token\":\"YOUR_TOKEN\",\"time\":$TIME,\"platform_order_id\":\"ABCP20260508abc123XYZ456\"}"
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "YOUR_SECRET" | awk '{print $2}')

curl -X POST https://<your-api-domain>/payment/query \
  -H "Content-Type: application/json" \
  -H "X-SIGNATURE: $SIG" \
  -d "$BODY"
import crypto from 'node:crypto';

const SECRET = 'YOUR_SECRET';
const body = JSON.stringify({
  merchant_id:       'AA12345678',
  token:             'YOUR_TOKEN',
  time:             Math.floor(Date.now() / 1000),
  platform_order_id: 'ABCP20260508abc123XYZ456',
});
const sig = crypto.createHmac('sha256', SECRET).update(body).digest('hex');

const r = await fetch('https://<your-api-domain>/payment/query', {
  method:  'POST',
  headers: { 'Content-Type': 'application/json', 'X-SIGNATURE': sig },
  body
});
console.log(await r.json());
<?php
$secret = 'YOUR_SECRET';
$body = json_encode([
    'merchant_id'       => 'AA12345678',
    'token'             => 'YOUR_TOKEN',
    'time'              => time(),
    'platform_order_id' => 'ABCP20260508abc123XYZ456',
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$sig = hash_hmac('sha256', $body, $secret);

$ch = curl_init('https://<your-api-domain>/payment/query');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $body,
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        "X-SIGNATURE: $sig",
    ],
]);
echo curl_exec($ch);

Response

Response

Success — HTTP 200

สำเร็จ — HTTP 200

JSON
{
  "code":    200,
  "message": "Success",
  "data":    {
    "platform_order_id": "ABCP20260508abc123XYZ456",
    "merchant_order_id": "ORDER-2026-001",
    "order_datetime":    "2026-05-08 10:30:00",
    "amount":            500.00,
    "status":            "settled_paid",
    "expire_datetime":   "2026-05-08 10:45:00",
    "payment_datetime":  "2026-05-08 10:32:11"
  },
  "success": true
}

Response fields

Response fields

FieldTypeDescription ฟิลด์ประเภทคำอธิบาย
data.platform_order_id string Echo of input. data.platform_order_id string Echo ค่าที่ส่งมา
data.merchant_order_id string Your original order ID from the create call. data.merchant_order_id string Order ID ที่ฝั่งคุณส่งตอนสร้าง
data.order_datetime string When the order was created (YYYY-MM-DD HH:mm:ss in GMT+7). data.order_datetime string เวลาที่สร้าง order (YYYY-MM-DD HH:mm:ss GMT+7)
data.amount number Order amount in THB. data.amount number จำนวนเงินใน THB
data.status enum Internal status, one of: open (waiting for payment), unsettled_paid (paid, settling to your balance), settled_paid (paid and credited to your balance), error (expired or rejected), freeze (held by admin). For most merchants, treat settled_paid as the terminal success state and error as failure. data.status enum สถานะ internal ค่าใดค่าหนึ่งใน: open (รอจ่าย), unsettled_paid (จ่ายแล้ว กำลัง settle เข้า balance), settled_paid (จ่ายและเข้าบัญชีแล้ว), error (หมดอายุหรือถูกปฏิเสธ), freeze (ถูก hold โดย admin) — โดยทั่วไปให้ถือ settled_paid เป็น success สุดท้าย และ error เป็น failure
data.expire_datetime string When the order expires if not paid (YYYY-MM-DD HH:mm:ss GMT+7). data.expire_datetime string เวลาหมดอายุของ order ถ้าไม่ได้จ่าย (YYYY-MM-DD HH:mm:ss GMT+7)
data.payment_datetime string | null When the customer's payment was confirmed (YYYY-MM-DD HH:mm:ss GMT+7). null if not paid yet (e.g. status open or error). data.payment_datetime string | null เวลาที่ระบบยืนยันการจ่ายของลูกค้า (YYYY-MM-DD HH:mm:ss GMT+7) — เป็น null ถ้ายังไม่จ่าย (เช่น status open หรือ error)
Status values differ from the webhook callback
ค่า status ต่างจากใน webhook callback

The webhook payment callback uses uppercase PAID / FAIL as the status value (see Payment Callback). This query endpoint exposes the lower-level internal status (open / unsettled_paid / settled_paid / error / freeze). The mapping is roughly: callback PAID ↔ query settled_paid (and sometimes briefly unsettled_paid); callback FAIL ↔ query error.

Webhook payment callback ใช้ค่า PAID / FAIL ตัวพิมพ์ใหญ่ (ดู Payment Callback) — endpoint query นี้ส่งกลับค่า internal status (open / unsettled_paid / settled_paid / error / freeze) — การจับคู่โดยประมาณ: callback PAID ↔ query settled_paid (อาจผ่าน unsettled_paid สั้น ๆ ก่อน); callback FAIL ↔ query error

No account_no / qrcode / payment_type here
ไม่มี account_no / qrcode / payment_type

Those fields are only returned by the create endpoints. The query endpoint focuses on payment status. Store what you need from the create response on your side.

ฟิลด์เหล่านั้นอยู่เฉพาะใน response ของ create endpoint — endpoint query โฟกัสเรื่องสถานะ — ฝั่งคุณควรเก็บค่าที่จำเป็นจาก create response เอง

Errors

Errors

HTTP Error code When it happens Error code เกิดเมื่อ
400 invalid-inputs Missing or malformed platform_order_id. invalid-inputs ไม่มี หรือรูปแบบ platform_order_id ผิด
404 not-found Order not found, or it was created by a different merchant. not-found ไม่พบ order หรือ order เป็นของ merchant อื่น

Notes

หมายเหตุ

  • Results are cached for ~5 minutes. Once status changes to success or failed, it will not change again.
  • Result ถูก cache ไว้ ~5 นาที — เมื่อเปลี่ยนเป็น success หรือ failed แล้วจะไม่เปลี่ยนอีก
  • Reasonable polling cadence: every 30 s while the order is open and you suspect a missed callback. Stop polling once you see a terminal status.
  • ความถี่ polling ที่เหมาะสม: ทุก 30 วินาทีตอน order ยัง open และสงสัยว่า callback หาย — หยุด poll เมื่อเจอสถานะสุดท้าย