Payment Gateway REST API — สร้าง QR PromptPay, ตรวจสอบยอดอัตโนมัติผ่าน LINE
ส่ง API Key ผ่าน header ทุก request
X-API-Key: your-api-key-here
API Key ได้จากหน้า Dashboard > API Keys หรือจาก Admin
สร้าง payment ใหม่ + QR PromptPay
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | จำนวนเงิน (THB) เช่น 100, 299.00 |
con_id | number | Yes | Bank Connection ID — ระบุว่าจะใช้บัญชีธนาคารไหน |
ref | string | No | Reference ของคุณ เช่น order ID, player UID |
callback_url | string | No | URL สำหรับ webhook เมื่อชำระสำเร็จ (override merchant default) |
metadata | object | No | ข้อมูลเพิ่มเติมที่จะส่งกลับใน callback |
curl -X POST https://your-domain.com/pay/create \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"amount": 100,
"con_id": 1,
"ref": "order-001",
"metadata": {"uid": "player-123"}
}'
{
"code": 0,
"data": {
"id": "payment-uuid",
"amount": 100.01,
"base_amount": 100,
"connection_id": 1,
"status": "pending",
"expires_at": "2024-01-01T00:15:00.000Z",
"qr_url": "/pay/qr/payment-uuid"
}
}
amount จะมีสตางค์เพิ่มเพื่อแยกรายการ (เช่น 100.01, 100.02) — ให้แสดง QR ด้วยยอดนี้
ดึง QR Code เป็นรูป PNG
| Param | Description |
|---|---|
:id | Payment ID ที่ได้จาก /pay/create |
?format=base64 | ส่งกลับเป็น JSON + base64 data URI แทน |
ใช้เป็น <img src="/pay/qr/uuid"> ได้เลย
ตรวจสอบสถานะ payment
{
"code": 0,
"data": {
"id": "payment-uuid",
"status": "confirmed",
"amount": 100.01,
"base_amount": 100,
"ref": "order-001",
"created_at": "...",
"expires_at": "...",
"confirmed_at": "..."
}
}
Status: pending → confirmed / expired / cancelled
ยกเลิก payment ที่ยัง pending
ต้องใช้ X-API-Key ของ merchant เจ้าของ payment
เมื่อชำระสำเร็จ ระบบจะ POST ไปที่ callback_url
POST your-callback-url
Content-Type: application/json
{
"event": "payment.confirmed",
"payment_id": "uuid",
"ref": "order-001",
"amount": 100.01,
"base_amount": 100,
"confirmed_at": "2024-01-01T00:05:00.000Z",
"metadata": {"uid": "player-123"}
}
Sync LINE token จาก Chrome Extension
{
"sync_key": "your-sync-key",
"cookies": [{"name": "lct", "value": "token..."}]
}
Sync Key ได้จากหน้า Dashboard > API Keys
Extension นี้ใช้ดึง LINE token จาก LINE Chrome Extension เพื่อให้ระบบ monitor ข้อความแจ้งเตือนธนาคารได้
manifest.json)chrome://extensionshttps://salmongateway.comcon_idPOST /pay/create ด้วย con_id → ได้ QR Code| Code | Meaning |
|---|---|
0 | Success |
400 | Bad request — ข้อมูลไม่ครบหรือไม่ถูกต้อง |
401 | Unauthorized — API Key ไม่ถูกต้อง |
402 | Insufficient credit — เครดิตไม่พอ |
403 | Forbidden — ไม่มีสิทธิ์ |
404 | Not found |
409 | Conflict — สตางค์เต็มหมดสำหรับยอดนี้ |
500 | Internal error |