สารบัญหน้านี้ (22)
- ภาพรวมโมดูล
- Workflow: กระทบยอดรอบโอนประจำวัน (T+1)
- Workflow: สั่งรายงานทั้งเดือนให้สำนักงานบัญชี (async + ผิดช่วงวันที่)
- The Transaction object
- The Settlement object
- The Balance object
- Endpoints (10)
- GETรายการเคลื่อนไหวทั้งหมด
- GETดูรายการเคลื่อนไหว
- GETยอดคงเหลือของร้าน
- GETรายการรอบโอนเงิน
- GETดูรอบโอนเงิน
- GETรายการในรอบโอน
- GETไฟล์กระทบยอด (CSV)
- GETอัตราค่าธรรมเนียมของร้าน
- POSTสั่งสร้างรายงาน (async)
- GETดูสถานะรายงาน / ลิงก์ดาวน์โหลด
- Webhooks (7)
- Errors
- Rate limit
- เวอร์ชันและ Changelog
- เครื่องมือ: ตัวกระทบยอด
- PAYNARA
- Docs
- Payment API
- Transaction
PAYNARA Payments API · โมดูล 2/5
Transaction & Settlement API
ดูทุกการเคลื่อนไหวของเงินร้าน (ขาย คืนเงิน ค่าธรรมเนียม ปรับปรุง โอนออก) · ยอดคงเหลือ · รอบโอนเงินเข้าบัญชี T+1 พร้อมไฟล์กระทบยอด CSV · สั่งรายงานช่วงยาวแบบเบื้องหลัง
/v1/transactions/v1/balance/v1/settlements/v1/fees/v1/reports

ภาพรวมโมดูล Transaction
ใช้เมื่อไร
- ทำหน้า "ยอดเงินของฉัน" บนแดชบอร์ดร้าน — GET /v1/balance
- ลงบัญชีอัตโนมัติทุกวัน — settlement.created → report.csv → จับคู่ order_ref
- ตอบลูกค้า/ฝ่ายบัญชีว่ารายการนี้โอนเข้าวันไหน — transaction.settlement_id
- ปิดงบรายเดือน/ส่งสำนักงานบัญชี — POST /v1/reports
Object หลัก
-
Transactionการเคลื่อนไหวของเงิน 1 รายการ — ทุก payment ที่สำเร็จ ทุกการคืนเงิน และทุกการโอนออก สร้าง transaction เสมอ (ตัวอย่าง: คำสั่งซื้อของคุณอรอุมาที่ยังไม่ตัดรอบ) -
Settlementรอบโอนเงิน 1 รอบ (ยอดขาย 1 วัน) — ตัวอย่างรอบ stl_20261012 ของยอดขายวันที่ 11 ต.ค. -
Balanceยอดคงเหลือของร้าน ณ เวลาที่เรียก (คำนวณสด)
การยืนยันตัวตน
ทุกคำขอส่ง API key แบบ Bearer + X-Merchant-Id ของร้าน · sandbox ใช้ pn_test_… production ใช้ pn_live_… · แนะนำสร้าง restricted key ที่มีเฉพาะ scope ที่ระบบนั้นใช้ (เช่น ระบบบัญชีได้แค่ *:read)
POST https://sandbox.api.paynara.example/v1/reports HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
X-Merchant-Id: mch_baanmaeplub
Paynara-Version: 2026-08-01
Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f
Content-Type: application/json| scope | สิทธิ์ | ระดับ |
|---|---|---|
transactions:read | ดูรายการเคลื่อนไหวและอัตราค่าธรรมเนียม | อ่าน |
balance:read | ดูยอดคงเหลือ | อ่าน |
settlements:read | ดูรอบโอนและดาวน์โหลดไฟล์กระทบยอด | อ่าน |
reports:read | ดูสถานะรายงานและลิงก์ดาวน์โหลด | อ่าน |
reports:write | สั่งสร้างรายงาน | เขียน |
ความสัมพันธ์กับโมดูลอื่น
- Paymentpayment ที่ succeeded สร้าง transaction ชนิด charge (fee และ net อยู่ใน payment ด้วย)
- Refundการคืนเงินสร้าง transaction ชนิด refund หักในรอบโอนถัดไป
- Verificationข้อพิพาท (dispute) สร้าง transaction ชนิด dispute / adjustment
- Notificationรับ settlement.* และ report.ready ทาง webhook — ถ้าส่งไม่ถึงดูประวัติและส่งซ้ำได้
ข้อควรรู้
-
รอบโอน T+1 เวลา 14:00
ตัดรอบ 23:59:59 ทุกวัน · โอนวันทำการถัดไป 14:00 · วันหยุดรวมเป็นรอบเดียวในวันทำการถัดไป
-
สตางค์ + ปัดต่อรายการ
ค่าธรรมเนียมและ VAT ปัดเศษต่อรายการ — ผลรวมในรอบจึงอาจต่างจาก "ยอดรวม × อัตรา" 1–2 สตางค์ (ถูกต้องแล้ว)
-
แบ่งหน้าแบบ cursor
limit ≤ 100 · starting_after / ending_before · ช่วงวันที่ไม่เกิน 92 วันต่อคำขอ
-
เวลา ISO 8601 +07:00
created ทุกตัวเป็นเวลาไทย · payout_date เป็นวันที่ YYYY-MM-DD
-
ไฟล์ CSV เป็นสตางค์
คอลัมน์เงินลงท้าย _satang · UTF-8 มี BOM · แถว TOTAL ท้ายไฟล์ไว้ตรวจผลรวม
-
เก็บข้อมูล 10 ปี
รายการเคลื่อนไหวเก็บ 10 ปีตามกฎหมายบัญชี · ไม่มีข้อมูลส่วนบุคคลของลูกค้าในไฟล์กระทบยอด (มีแค่ order_ref)
Workflow (2 เรื่อง)
แต่ละเรื่องดูได้ 2 แบบ: ภาพรวม สำหรับทุกคนในทีม และ Sequence ทีละขั้น สำหรับนักพัฒนา (กดเล่น หรือคลิกลูกศรเพื่อดูคำขอ/ผลลัพธ์จริงของขั้นนั้น) · ลูกศรประ = ไม่รอผล (webhook/คิว)
กระทบยอดรอบโอนประจำวัน (T+1) — webhook ไม่ถึง ใช้การดึงสำรอง
ขายวันที่ 11 ต.ค. 13 รายการ + คืนเงิน 1 รายการ → โอนเข้าบัญชีร้าน 12 ต.ค. 14:00 · โปรแกรมบัญชีของร้านรับ webhook ไม่ได้ จึงดึงข้อมูลเองตามเวลา
- เจ้าของร้าน
- โปรแกรมบัญชีของร้านerp.baanmaeplub.example
- PAYNARA API
- ระบบตัดรอบsettlement engine
- ธนาคารสยามรุ่ง (สมมติ)
- 1
ระบบตัดรอบ → ระบบตัดรอบ
รวมรายการขาย 13 รายการและคืนเงิน 1 รายการ สร้างรอบ stl_20261012 สถานะ scheduled
- 2
ระบบตัดรอบ → โปรแกรมบัญชีของร้าน
ส่ง event ไปโปรแกรมบัญชี แต่ปลายทางไม่ตอบภายใน 10 วินาที (เซิร์ฟเวอร์ปิดซ่อม)
ไม่รอผล (async) - 3
โปรแกรมบัญชีของร้าน → PAYNARA API
งานตั้งเวลา 07:00 ของโปรแกรมบัญชีดึงรอบโอนของวันนี้เองเป็นแผนสำรอง
GET /v1/settlements?payout_date[gte]=2026-10-12&status=scheduled - 4
โปรแกรมบัญชีของร้าน → PAYNARA API
ดาวน์โหลดไฟล์กระทบยอด 1 แถวต่อรายการ
GET /v1/settlements/stl_20261012/report.csv - 5
โปรแกรมบัญชีของร้าน → โปรแกรมบัญชีของร้าน
จับคู่ order_ref ได้ครบ 13 คำสั่งซื้อ และพบการคืนเงิน rf_4Xc8Hn ของคำสั่งซื้อวันที่ 10 ที่ต้องลงบัญชีลดยอดขาย
- 6
ระบบตัดรอบ → ธนาคารสยามรุ่ง (สมมติ)
ระบบโอนยอดสุทธิเข้าบัญชีร้าน (เลขท้าย 4821)
- 7
ธนาคารสยามรุ่ง (สมมติ) → เจ้าของร้าน
แอปธนาคารแจ้งเจ้าของร้านว่ามีเงินเข้า
- 8
ระบบตัดรอบ → โปรแกรมบัญชีของร้าน
แจ้งผลการโอนพร้อมเลขอ้างอิงธนาคาร (ส่งไม่ถึงเช่นกัน — งาน 15:00 ดึงซ้ำ)
ไม่รอผล (async) - 9
โปรแกรมบัญชีของร้าน → PAYNARA API
ดึงสถานะรอบอีกครั้งเพื่อบันทึกเลขอ้างอิงการโอน
GET /v1/settlements/stl_20261012 - 10
เจ้าของร้าน → โปรแกรมบัญชีของร้าน
เจ้าของร้านเทียบยอดในบัญชีธนาคารกับรายงาน แล้วกดยืนยัน (ตรงทุกบาท)
ยอดโอน ฿10,107.83 ตรงกับไฟล์ CSV 14 แถว ภายในวันเดียว · ไม่มีรายการตกหล่นแม้ webhook ส่งไม่ถึง
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 ระบบตัดรอบ ระบบตัดรอบ
01:05 ตัดรอบวันที่ 11
รวมรายการขาย 13 รายการและคืนเงิน 1 รายการ สร้างรอบ stl_20261012 สถานะ scheduled
2 ระบบตัดรอบ โปรแกรมบัญชีของร้านasync
webhook settlement.created
ส่ง event ไปโปรแกรมบัญชี แต่ปลายทางไม่ตอบภายใน 10 วินาที (เซิร์ฟเวอร์ปิดซ่อม)
endpoint นี้ถูกปิดอัตโนมัติหลังล้มเหลวต่อเนื่อง 3 วัน — ดูประวัติในหน้า Notification
3 โปรแกรมบัญชีของร้าน PAYNARA API
GET /v1/settlements?payout_date[gte]=…
งานตั้งเวลา 07:00 ของโปรแกรมบัญชีดึงรอบโอนของวันนี้เองเป็นแผนสำรอง
GET /v1/settlements?payout_date[gte]=2026-10-12&status=scheduled HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"object": "list",
"url": "/v1/settlements",
"has_more": false,
"data": [
{
"id": "stl_20261012",
"status": "scheduled",
"net": 1010783,
"payout_at": "2026-10-12T14:00:00+07:00"
}
],
"next_cursor": null
}4 โปรแกรมบัญชีของร้าน PAYNARA API
GET …/stl_20261012/report.csv
ดาวน์โหลดไฟล์กระทบยอด 1 แถวต่อรายการ
GET /v1/settlements/stl_20261012/report.csv HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
Accept: text/csvHTTP/1.1 200 OK
{
"content_type": "text/csv; charset=utf-8",
"rows": 15
}5 โปรแกรมบัญชีของร้าน โปรแกรมบัญชีของร้าน
จับคู่กับคำสั่งซื้อ
จับคู่ order_ref ได้ครบ 13 คำสั่งซื้อ และพบการคืนเงิน rf_4Xc8Hn ของคำสั่งซื้อวันที่ 10 ที่ต้องลงบัญชีลดยอดขาย
6 ระบบตัดรอบ ธนาคารสยามรุ่ง (สมมติ)
14:00 โอน ฿10,107.83
ระบบโอนยอดสุทธิเข้าบัญชีร้าน (เลขท้าย 4821)
7 ธนาคารสยามรุ่ง (สมมติ) เจ้าของร้าน
แจ้งเงินเข้า
แอปธนาคารแจ้งเจ้าของร้านว่ามีเงินเข้า
8 ระบบตัดรอบ โปรแกรมบัญชีของร้านasync
webhook settlement.paid
แจ้งผลการโอนพร้อมเลขอ้างอิงธนาคาร (ส่งไม่ถึงเช่นกัน — งาน 15:00 ดึงซ้ำ)
9 โปรแกรมบัญชีของร้าน PAYNARA API
GET /v1/settlements/stl_20261012
ดึงสถานะรอบอีกครั้งเพื่อบันทึกเลขอ้างอิงการโอน
GET /v1/settlements/stl_20261012 HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"id": "stl_20261012",
"status": "paid",
"net": 1010783,
"payout_reference": "SRR-PO-20261012-0388",
"paid_at": "2026-10-12T14:00:02+07:00"
}10 เจ้าของร้าน โปรแกรมบัญชีของร้าน
ยืนยันกระทบยอด
เจ้าของร้านเทียบยอดในบัญชีธนาคารกับรายงาน แล้วกดยืนยัน (ตรงทุกบาท)
ยอดโอน ฿10,107.83 ตรงกับไฟล์ CSV 14 แถว ภายในวันเดียว · ไม่มีรายการตกหล่นแม้ webhook ส่งไม่ถึง
สั่งรายงานทั้งเดือนให้สำนักงานบัญชี (async + ผิดช่วงวันที่)
ฝ่ายบัญชีต้องการรายการเดือนกันยายนทั้งหมด — ลองดึงช่วง 4 เดือนด้วย list ก่อนแล้วโดนปฏิเสธ จึงเปลี่ยนเป็นรายงานแบบ async
- นักบัญชีสำนักงานบัญชีภายนอก
- โปรแกรมบัญชีของร้าน
- PAYNARA API
- คิวสร้างรายงาน
- ที่เก็บไฟล์ลิงก์ลงลายเซ็น 1 ชม.
- 1
นักบัญชี → โปรแกรมบัญชีของร้าน
นักบัญชีขอไฟล์รายการเคลื่อนไหวทั้งเดือนเพื่อปิดงบ
- 2
โปรแกรมบัญชีของร้าน → PAYNARA API
สคริปต์เดิมส่งช่วง มิ.ย.–ก.ย. ในคำขอเดียว
GET /v1/transactions?created[gte]=2026-06-01T00:00:00%2B07:00&created[lte]=2026-09-30T23:59:59%2B07:00 - 3
โปรแกรมบัญชีของร้าน → PAYNARA API
เปลี่ยนเป็นสั่งรายงานเฉพาะเดือนกันยายน
POST /v1/reports - 4
PAYNARA API → คิวสร้างรายงาน
ระบบรับงานแล้วตอบกลับทันที ไม่ต้องรอ
ไม่รอผล (async) - 5
โปรแกรมบัญชีของร้าน → PAYNARA API
หน้าจอโปรแกรมบัญชีแสดง "กำลังสร้าง…"
GET /v1/reports/rpt_9Kd2Ws - 6
คิวสร้างรายงาน → คิวสร้างรายงาน
ดึงข้อมูลจากฐานข้อมูลสำเนาสำหรับรายงาน (ไม่กระทบการรับชำระ)
- 7
คิวสร้างรายงาน → ที่เก็บไฟล์
บันทึกไฟล์ 182 KB พร้อมลิงก์ลงลายเซ็น
- 8
PAYNARA API → โปรแกรมบัญชีของร้าน
แจ้งว่าไฟล์พร้อม
POST /hooks/paynaraไม่รอผล (async) - 9
โปรแกรมบัญชีของร้าน → ที่เก็บไฟล์
ดาวน์โหลดไฟล์ภายใน 1 ชั่วโมงก่อนลิงก์หมดอายุ
- 10
โปรแกรมบัญชีของร้าน → นักบัญชี
แนบไฟล์ส่งอีเมลถึงสำนักงานบัญชี
ได้ไฟล์ CSV 1,284 แถวภายใน 48 วินาที โดยไม่ต้องวนเรียก list ทีละ 100 รายการ (ลดการเรียก API จาก 13 ครั้งเหลือ 3 ครั้ง)
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 นักบัญชี โปรแกรมบัญชีของร้าน
ขอรายการ ก.ย. 2569
นักบัญชีขอไฟล์รายการเคลื่อนไหวทั้งเดือนเพื่อปิดงบ
2 โปรแกรมบัญชีของร้าน PAYNARA API
GET /v1/transactions (4 เดือน)
สคริปต์เดิมส่งช่วง มิ.ย.–ก.ย. ในคำขอเดียว
GET /v1/transactions?created[gte]=2026-06-01T00:00:00%2B07:00&created[lte]=2026-09-30T23:59:59%2B07:00 HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 400 Bad Request
{
"error": {
"code": "date_range_invalid",
"message": "ช่วงวันที่ยาวเกิน 92 วัน ใช้ POST /v1/reports แทน",
"param": "created",
"request_id": "req_7Pw3Ue"
}
}3 โปรแกรมบัญชีของร้าน PAYNARA API
POST /v1/reports
เปลี่ยนเป็นสั่งรายงานเฉพาะเดือนกันยายน
POST /v1/reports HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"type": "transactions",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"format": "csv"
}HTTP/1.1 202 Accepted
{
"id": "rpt_9Kd2Ws",
"status": "processing"
}4 PAYNARA API คิวสร้างรายงานasync
เข้าคิว
ระบบรับงานแล้วตอบกลับทันที ไม่ต้องรอ
5 โปรแกรมบัญชีของร้าน PAYNARA API
GET /v1/reports/rpt_9Kd2Ws
หน้าจอโปรแกรมบัญชีแสดง "กำลังสร้าง…"
GET /v1/reports/rpt_9Kd2Ws HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"id": "rpt_9Kd2Ws",
"status": "processing",
"file": null
}6 คิวสร้างรายงาน คิวสร้างรายงาน
รวม 1,284 แถว
ดึงข้อมูลจากฐานข้อมูลสำเนาสำหรับรายงาน (ไม่กระทบการรับชำระ)
7 คิวสร้างรายงาน ที่เก็บไฟล์
อัปโหลด CSV
บันทึกไฟล์ 182 KB พร้อมลิงก์ลงลายเซ็น
8 PAYNARA API โปรแกรมบัญชีของร้านasync
webhook report.ready
แจ้งว่าไฟล์พร้อม
POST /hooks/paynara HTTP/1.1
{
"type": "report.ready",
"data": {
"id": "rpt_9Kd2Ws",
"status": "ready",
"row_count": 1284
}
}HTTP/1.1 200 OK9 โปรแกรมบัญชีของร้าน ที่เก็บไฟล์
ดาวน์โหลด file.url
ดาวน์โหลดไฟล์ภายใน 1 ชั่วโมงก่อนลิงก์หมดอายุ
10 โปรแกรมบัญชีของร้าน นักบัญชี
ส่งไฟล์ให้นักบัญชี
แนบไฟล์ส่งอีเมลถึงสำนักงานบัญชี
ได้ไฟล์ CSV 1,284 แถวภายใน 48 วินาที โดยไม่ต้องวนเรียก list ทีละ 100 รายการ (ลดการเรียก API จาก 13 ครั้งเหลือ 3 ครั้ง)
Objects
The Transaction object
การเคลื่อนไหวของเงิน 1 รายการ — ทุก payment ที่สำเร็จ ทุกการคืนเงิน และทุกการโอนออก สร้าง transaction เสมอ (ตัวอย่าง: คำสั่งซื้อของคุณอรอุมาที่ยังไม่ตัดรอบ)
idstringไม่บังคับอ่านอย่างเดียวรหัสรายการเคลื่อนไหว (ขึ้นต้น txn_)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
typestringไม่บังคับอ่านอย่างเดียวชนิดรายการ — ยอดบวกเพิ่มเงินร้าน ยอดลบลดเงินร้าน
sourcestringไม่บังคับอ่านอย่างเดียวid ต้นทาง (pay_… / rf_… / dsp_… / stl_…)
order_refstringไม่บังคับอ่านอย่างเดียวเลขคำสั่งซื้อของร้าน (คัดลอกจาก payment)
methodstringไม่บังคับอ่านอย่างเดียวช่องทางของรายการต้นทาง
descriptionstringไม่บังคับอ่านอย่างเดียวคำอธิบายที่แสดงในรายงาน
amountintegerไม่บังคับอ่านอย่างเดียวยอดก่อนหักค่าธรรมเนียม (สตางค์ · ลบ = เงินออก)
feeintegerไม่บังคับอ่านอย่างเดียวค่าธรรมเนียม PAYNARA
fee_vatintegerไม่บังคับอ่านอย่างเดียวVAT 7% ของค่าธรรมเนียม (ร้านขอใบกำกับภาษีรายเดือนได้)
netintegerไม่บังคับอ่านอย่างเดียวยอดสุทธิ = amount − fee − fee_vat
currencystringไม่บังคับอ่านอย่างเดียวสกุลเงิน
fee_detailsarray<object>ไม่บังคับอ่านอย่างเดียวแยกส่วนประกอบค่าธรรมเนียม
ฟิลด์ย่อยของ
fee_details(4)typestringไม่บังคับชนิด
fee_keystringไม่บังคับกลุ่มอัตรา (GET /v1/fees)
ratestringไม่บังคับอัตรา
amountintegerไม่บังคับจำนวน (สตางค์)
statusstringไม่บังคับอ่านอย่างเดียวpending = ยังไม่ตัดรอบ · available = อยู่ในรอบที่รอโอน · paid_out = โอนเข้าบัญชีแล้ว
available_onstring · dateไม่บังคับอ่านอย่างเดียววันที่เงินเข้ารอบโอน (T+1 วันทำการ)
settlement_idstringไม่บังคับอ่านอย่างเดียวรอบโอนที่รายการนี้อยู่ (null ถ้ายังไม่ตัดรอบ)
reporting_categorystringไม่บังคับอ่านอย่างเดียวหมวดสำหรับลงบัญชี
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "txn_3NqL8kC",
"object": "transaction",
"type": "charge",
"source": "pay_3NqL8k",
"order_ref": "ORD-2610-0153",
"method": "card",
"description": "ชำระด้วยบัตร VISA •••• 0101",
"amount": 104000,
"fee": 2756,
"fee_vat": 193,
"net": 101051,
"currency": "THB",
"fee_details": [
{
"type": "payment_fee",
"fee_key": "card",
"rate": "2.65%",
"amount": 2756
},
{
"type": "vat",
"rate": "7%",
"amount": 193
}
],
"status": "pending",
"available_on": "2026-10-13",
"settlement_id": null,
"reporting_category": "sales",
"created": "2026-10-12T10:14:32+07:00",
"livemode": false
}
The Settlement object
รอบโอนเงิน 1 รอบ (ยอดขาย 1 วัน) — ตัวอย่างรอบ stl_20261012 ของยอดขายวันที่ 11 ต.ค.
idstringไม่บังคับอ่านอย่างเดียวรหัสรอบโอน stl_<วันที่โอน>
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
statusstringไม่บังคับอ่านอย่างเดียวpending = กำลังรวมยอด · scheduled = ตัดรอบแล้วรอโอน · paid = โอนสำเร็จ · failed = โอนไม่สำเร็จ (บัญชีปลายทางมีปัญหา)
period_startstring · date-timeไม่บังคับอ่านอย่างเดียวเริ่มช่วงขายที่รวม
period_endstring · date-timeไม่บังคับอ่านอย่างเดียวสิ้นสุดช่วงขาย (ตัดรอบ 23:59:59)
payout_datestring · dateไม่บังคับอ่านอย่างเดียววันที่โอน (T+1 · ตรงวันหยุดเลื่อนไปวันทำการถัดไป)
payout_atstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาโอน (รอบ 14:00)
gross_salesintegerไม่บังคับอ่านอย่างเดียวยอดขายรวม (charge)
refundsintegerไม่บังคับอ่านอย่างเดียวยอดคืนเงินที่หักในรอบนี้
feesintegerไม่บังคับอ่านอย่างเดียวค่าธรรมเนียมรวม
fee_vatintegerไม่บังคับอ่านอย่างเดียวVAT ของค่าธรรมเนียมรวม
adjustmentsintegerไม่บังคับอ่านอย่างเดียวปรับปรุงอื่น (ข้อพิพาท คืนค่าธรรมเนียม)
netintegerไม่บังคับอ่านอย่างเดียวยอดโอน = gross_sales − refunds − fees − fee_vat + adjustments
currencystringไม่บังคับอ่านอย่างเดียวสกุลเงิน
count_chargesintegerไม่บังคับอ่านอย่างเดียวจำนวนรายการขาย
count_refundsintegerไม่บังคับอ่านอย่างเดียวจำนวนรายการคืนเงิน
by_methodarray<object>ไม่บังคับอ่านอย่างเดียวสรุปแยกช่องทาง
ฟิลด์ย่อยของ
by_method(6)methodstringไม่บังคับช่องทาง
countintegerไม่บังคับจำนวนรายการ
grossintegerไม่บังคับยอดรวม
feeintegerไม่บังคับค่าธรรมเนียม
fee_vatintegerไม่บังคับVAT
netintegerไม่บังคับสุทธิ
bank_accountobjectไม่บังคับอ่านอย่างเดียวบัญชีรับเงินของร้าน (ปิดบัง)
ฟิลด์ย่อยของ
bank_account(3)bankstringไม่บังคับรหัสธนาคาร (สมมติ)
bank_namestringไม่บังคับชื่อธนาคาร
account_last4stringไม่บังคับเลขบัญชี 4 หลักท้าย
payout_referencestringไม่บังคับอ่านอย่างเดียวเลขอ้างอิงการโอนจากธนาคาร (มีเมื่อ paid)
failure_reasonstringไม่บังคับอ่านอย่างเดียวเหตุผลเมื่อ failed
report_urlstringไม่บังคับอ่านอย่างเดียวpath ไฟล์กระทบยอด CSV
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "stl_20261012",
"object": "settlement",
"status": "scheduled",
"period_start": "2026-10-11T00:00:00+07:00",
"period_end": "2026-10-11T23:59:59+07:00",
"payout_date": "2026-10-12",
"payout_at": "2026-10-12T14:00:00+07:00",
"gross_sales": 1053000,
"refunds": 15000,
"fees": 25437,
"fee_vat": 1780,
"adjustments": 0,
"net": 1010783,
"currency": "THB",
"count_charges": 13,
"count_refunds": 1,
"by_method": [
{
"method": "promptpay",
"count": 7,
"gross": 255000,
"fee": 2160,
"fee_vat": 151,
"net": 252689
},
{
"method": "card",
"count": 4,
"gross": 321000,
"fee": 9107,
"fee_vat": 636,
"net": 311257
},
{
"method": "installment",
"count": 1,
"gross": 362000,
"fee": 12670,
"fee_vat": 887,
"net": 348443
},
{
"method": "mobile_banking",
"count": 2,
"gross": 100000,
"fee": 1500,
"fee_vat": 106,
"net": 98394
}
],
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
},
"payout_reference": null,
"report_url": "/v1/settlements/stl_20261012/report.csv",
"created": "2026-10-12T01:05:00+07:00",
"livemode": false
}
The Balance object
ยอดคงเหลือของร้าน ณ เวลาที่เรียก (คำนวณสด)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
merchantstringไม่บังคับอ่านอย่างเดียวรหัสร้านค้าเจ้าของยอด (ตรงกับ X-Merchant-Id)
currencystringไม่บังคับอ่านอย่างเดียวสกุลเงิน
totalintegerไม่บังคับอ่านอย่างเดียวยอดเงินของร้านทั้งหมด = available + pending (สตางค์ · ไม่รวม capturable และ reserved)
availablearray<object>ไม่บังคับอ่านอย่างเดียวยอดที่ตัดรอบแล้วรอโอนเข้าบัญชี (ใช้หักคืนเงินได้ก่อน)
ฟิลด์ย่อยของ
available(3)amountintegerไม่บังคับยอดพร้อมโอน (สตางค์)
sourcestringไม่บังคับที่มาของยอด
notestringไม่บังคับคำอธิบายสำหรับแสดงบนแดชบอร์ด
pendingarray<object>ไม่บังคับอ่านอย่างเดียวยอดสุทธิที่ยังไม่ตัดรอบ (วันนี้ · หักคืนเงินแล้ว)
ฟิลด์ย่อยของ
pending(3)amountintegerไม่บังคับยอดรอตัดรอบ (สตางค์)
sourcestringไม่บังคับที่มาของยอด
notestringไม่บังคับคำอธิบายสำหรับแสดงบนแดชบอร์ด
capturablearray<object>ไม่บังคับอ่านอย่างเดียววงเงิน authorize ที่รอ capture (ไม่นับเป็นเงินของร้าน)
ฟิลด์ย่อยของ
capturable(3)amountintegerไม่บังคับวงเงินรอ capture (สตางค์)
sourcestringไม่บังคับที่มาของยอด
notestringไม่บังคับคำอธิบายสำหรับแสดงบนแดชบอร์ด
reservedarray<object>ไม่บังคับอ่านอย่างเดียวยอดที่ถูกระงับ (ข้อพิพาท/ตรวจความเสี่ยง) — ไม่โอนจนกว่าจะปิดเรื่อง
ฟิลด์ย่อยของ
reserved(3)amountintegerไม่บังคับยอดที่ระงับ (สตางค์)
sourcestringไม่บังคับที่มาของยอด
notestringไม่บังคับคำอธิบายสำหรับแสดงบนแดชบอร์ด
refund_pendingarray<object>ไม่บังคับอ่านอย่างเดียวการคืนเงินที่ยังไม่ส่งเข้าเครือข่าย (หักไว้แล้ว)
ฟิลด์ย่อยของ
refund_pending(3)amountintegerไม่บังคับยอดคืน (สตางค์)
refundstringไม่บังคับรหัสการคืนเงิน (rf_…)
notestringไม่บังคับคำอธิบาย
next_payoutobjectไม่บังคับอ่านอย่างเดียวการโอนครั้งถัดไป
ฟิลด์ย่อยของ
next_payout(4)settlementstringไม่บังคับรอบโอน
amountintegerไม่บังคับยอดโอน (สตางค์)
atstring · date-timeไม่บังคับเวลาโอน
bank_accountobjectไม่บังคับบัญชีรับเงิน (ปิดบังเลขบัญชี)
ฟิลด์ย่อยของ
bank_account(3)bankstringไม่บังคับรหัสธนาคาร (สมมติ)
bank_namestringไม่บังคับชื่อธนาคาร
account_last4stringไม่บังคับเลขบัญชี 4 หลักท้าย
last_payoutobjectไม่บังคับอ่านอย่างเดียวการโอนครั้งล่าสุด
ฟิลด์ย่อยของ
last_payout(4)settlementstringไม่บังคับรอบโอน
amountintegerไม่บังคับยอด (สตางค์)
paid_atstring · date-timeไม่บังคับเวลาโอนสำเร็จ
payout_referencestringไม่บังคับเลขอ้างอิงธนาคาร
payout_scheduleobjectไม่บังคับอ่านอย่างเดียวรอบโอนของร้าน (ตั้งในสัญญา)
ฟิลด์ย่อยของ
payout_schedule(4)intervalstringไม่บังคับความถี่
delay_daysintegerไม่บังคับT+n
timestringไม่บังคับเวลาโอน
timezonestringไม่บังคับเขตเวลา
updatedstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาคำนวณ (ปรับทุกครั้งที่มีรายการ)
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"object": "balance",
"merchant": "mch_baanmaeplub",
"currency": "THB",
"total": 1120629,
"available": [
{
"amount": 1010783,
"source": "settled",
"note": "รอโอนรอบ stl_20261012 เวลา 14:00"
}
],
"pending": [
{
"amount": 109846,
"source": "today",
"note": "ยอดสุทธิของวันนี้ (หักคืนเงินแล้ว) — เข้ารอบ 13 ต.ค."
}
],
"capturable": [
{
"amount": 540000,
"source": "authorized",
"note": "วงเงิน authorize รอ capture (ยังไม่นับเป็นรายได้)"
}
],
"reserved": [
{
"amount": 53000,
"source": "dispute",
"note": "ระงับไว้สำหรับข้อพิพาท dsp_6Bn2Lw (ยอด + ค่าดำเนินการ)"
}
],
"refund_pending": [
{
"amount": 15000,
"refund": "rf_5Tg9Qa",
"note": "หักจาก pending แล้ว — แสดงเพื่อตรวจสอบ"
}
],
"next_payout": {
"settlement": "stl_20261012",
"amount": 1010783,
"at": "2026-10-12T14:00:00+07:00",
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
}
},
"last_payout": {
"settlement": "stl_20261011",
"amount": 931337,
"paid_at": "2026-10-11T14:00:03+07:00",
"payout_reference": "SRR-PO-20261011-0412"
},
"payout_schedule": {
"interval": "daily",
"delay_days": 1,
"time": "14:00",
"timezone": "Asia/Bangkok"
},
"updated": "2026-10-12T11:00:00+07:00",
"livemode": false
}Endpoints (10)
| Method | Path | ทำอะไร | scope |
|---|---|---|---|
| GET | /v1/transactions | รายการเคลื่อนไหวทั้งหมด | transactions:read |
| GET | /v1/transactions/{transaction_id} | ดูรายการเคลื่อนไหว | transactions:read |
| GET | /v1/balance | ยอดคงเหลือของร้าน | balance:read |
| GET | /v1/settlements | รายการรอบโอนเงิน | settlements:read |
| GET | /v1/settlements/{settlement_id} | ดูรอบโอนเงิน | settlements:read |
| GET | /v1/settlements/{settlement_id}/transactions | รายการในรอบโอน | settlements:readtransactions:read |
| GET | /v1/settlements/{settlement_id}/report.csv | ไฟล์กระทบยอด (CSV) | settlements:read |
| GET | /v1/fees | อัตราค่าธรรมเนียมของร้าน | transactions:read |
| POST | /v1/reports | สั่งสร้างรายงาน (async) | reports:write |
| GET | /v1/reports/{report_id} | ดูสถานะรายงาน / ลิงก์ดาวน์โหลด | reports:read |
รายการเคลื่อนไหวทั้งหมด
ทุกการเปลี่ยนแปลงของเงินร้านเรียงตามเวลา (ขาย คืนเงิน ค่าธรรมเนียม ปรับปรุง โอนออก) — กรองช่วงวันที่ ชนิด ช่องทาง และรอบโอนได้ · ช่วงยาวเกิน 92 วันใช้ POST /v1/reports
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
typestringไม่บังคับกรองชนิด (คั่นด้วย , ได้)
methodstringไม่บังคับกรองช่องทาง
settlementstringไม่บังคับเฉพาะรายการในรอบโอนนี้
sourcestringไม่บังคับid ต้นทาง (pay_ / rf_)
statusstringไม่บังคับสถานะ
created[gte]string · date-timeไม่บังคับสร้างตั้งแต่เวลา (ISO 8601 +07:00) · ช่วงรวมไม่เกิน 92 วัน
created[lte]string · date-timeไม่บังคับสร้างถึงเวลา
sortstringไม่บังคับเรียงลำดับ (ใส่ - ข้างหน้า = มากไปน้อย)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200รายการของวันที่ 11 ต.ค. (ตัวอย่าง 3 แถวแรก)
- 400
date_range_invalidช่วงวันที่ไม่ถูกต้อง - 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 400
parameter_invalidค่าฟิลด์ไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ผลรวม net ของทุกรายการในรอบ = settlement.net เสมอ (ใช้ตรวจความครบถ้วน)
- type = payout เป็นยอดลบ (เงินออกไปบัญชีร้าน) — อย่านับเป็นค่าใช้จ่าย
curl -X GET "https://sandbox.api.paynara.example/v1/transactions?limit=20&settlement=stl_20261012&created[gte]=2026-10-11T00%3A00%3A00%2B07%3A00&created[lte]=2026-10-11T23%3A59%3A59%2B07%3A00" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/transactions?limit=20&settlement=stl_20261012&created[gte]=2026-10-11T00%3A00%3A00%2B07%3A00&created[lte]=2026-10-11T23%3A59%3A59%2B07%3A00', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/transactions?limit=20&settlement=stl_20261012&created[gte]=2026-10-11T00%3A00%3A00%2B07%3A00&created[lte]=2026-10-11T23%3A59%3A59%2B07%3A00",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"url": "/v1/transactions",
"has_more": true,
"data": [
{
"id": "txn_2Hd7MqC",
"object": "transaction",
"type": "charge",
"source": "pay_2Hd7Mq",
"order_ref": "ORD-2610-0138",
"method": "promptpay",
"amount": 95000,
"fee": 760,
"fee_vat": 53,
"net": 94187,
"currency": "THB",
"status": "available",
"available_on": "2026-10-12",
"settlement_id": "stl_20261012",
"created": "2026-10-11T08:12:40+07:00",
"livemode": false
},
{
"id": "txn_2Jk4WbC",
"object": "transaction",
"type": "charge",
"source": "pay_2Jk4Wb",
"order_ref": "ORD-2610-0139",
"method": "card",
"amount": 39000,
"fee": 1034,
"fee_vat": 72,
"net": 37894,
"currency": "THB",
"status": "available",
"available_on": "2026-10-12",
"settlement_id": "stl_20261012",
"created": "2026-10-11T08:47:05+07:00",
"livemode": false
},
{
"id": "txn_4Xc8HnR",
"object": "transaction",
"type": "refund",
"source": "rf_4Xc8Hn",
"order_ref": "ORD-2610-0126",
"method": "promptpay",
"amount": -15000,
"fee": 0,
"fee_vat": 0,
"net": -15000,
"currency": "THB",
"status": "available",
"available_on": "2026-10-12",
"settlement_id": "stl_20261012",
"created": "2026-10-11T10:41:22+07:00",
"livemode": false
}
],
"next_cursor": "txn_4Xc8HnR"
}{
"error": {
"code": "date_range_invalid",
"message": "ช่วงวันที่ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#date_range_invalid"
}
}{
"error": {
"code": "cursor_invalid",
"message": "cursor ของการแบ่งหน้าไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#cursor_invalid"
}
}{
"error": {
"code": "parameter_invalid",
"message": "ค่าฟิลด์ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_invalid"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}ดูรายการเคลื่อนไหว
GET/v1/transactions/{transaction_id}
รายละเอียดรายการเดียว พร้อมแยกค่าธรรมเนียมและ VAT — ขยาย source เพื่อดู payment/refund ต้นทางในคำขอเดียว
Path parameterspath
transaction_idstringจำเป็นรหัสรายการ
Query parametersquery
expand[]array<string>ไม่บังคับขยาย object ที่อ้างถึงให้เป็นข้อมูลเต็ม (source, settlement)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200รายการ charge ของคำสั่งซื้อ ORD-2610-0153 (ยังไม่ตัดรอบ)
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- amount เป็นยอดก่อนหักค่าธรรมเนียม · net = amount − fee − fee_vat (ยอดลบ = เงินออกจากร้าน)
- settlement_id เป็น null จนกว่าจะตัดรอบ (23:59:59)
curl -X GET "https://sandbox.api.paynara.example/v1/transactions/txn_3NqL8kC" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/transactions/txn_3NqL8kC', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/transactions/txn_3NqL8kC",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "txn_3NqL8kC",
"object": "transaction",
"type": "charge",
"source": "pay_3NqL8k",
"order_ref": "ORD-2610-0153",
"method": "card",
"description": "ชำระด้วยบัตร VISA •••• 0101",
"amount": 104000,
"fee": 2756,
"fee_vat": 193,
"net": 101051,
"currency": "THB",
"fee_details": [
{
"type": "payment_fee",
"fee_key": "card",
"rate": "2.65%",
"amount": 2756
},
{
"type": "vat",
"rate": "7%",
"amount": 193
}
],
"status": "pending",
"available_on": "2026-10-13",
"settlement_id": null,
"reporting_category": "sales",
"created": "2026-10-12T10:14:32+07:00",
"livemode": false
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}ยอดคงเหลือของร้าน
ยอดที่รอโอน (available) ยอดของวันนี้ที่ยังไม่ตัดรอบ (pending) และวงเงินรอ capture — ใช้แสดงบนแดชบอร์ดของร้านและตรวจก่อนคืนเงินจำนวนมาก
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200ยอด ณ 12 ต.ค. 11:00
- 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- การคืนเงินหักจาก available ก่อน ถ้าไม่พอหักจาก pending · ไม่พอทั้งคู่ได้ insufficient_balance (หน้า Refund)
curl -X GET "https://sandbox.api.paynara.example/v1/balance" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/balance', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/balance",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "balance",
"merchant": "mch_baanmaeplub",
"currency": "THB",
"total": 1120629,
"available": [
{
"amount": 1010783,
"source": "settled",
"note": "รอโอนรอบ stl_20261012 เวลา 14:00"
}
],
"pending": [
{
"amount": 109846,
"source": "today",
"note": "ยอดสุทธิของวันนี้ (หักคืนเงินแล้ว) — เข้ารอบ 13 ต.ค."
}
],
"capturable": [
{
"amount": 540000,
"source": "authorized",
"note": "วงเงิน authorize รอ capture (ยังไม่นับเป็นรายได้)"
}
],
"reserved": [
{
"amount": 53000,
"source": "dispute",
"note": "ระงับไว้สำหรับข้อพิพาท dsp_6Bn2Lw (ยอด + ค่าดำเนินการ)"
}
],
"refund_pending": [
{
"amount": 15000,
"refund": "rf_5Tg9Qa",
"note": "หักจาก pending แล้ว — แสดงเพื่อตรวจสอบ"
}
],
"next_payout": {
"settlement": "stl_20261012",
"amount": 1010783,
"at": "2026-10-12T14:00:00+07:00",
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
}
},
"last_payout": {
"settlement": "stl_20261011",
"amount": 931337,
"paid_at": "2026-10-11T14:00:03+07:00",
"payout_reference": "SRR-PO-20261011-0412"
},
"payout_schedule": {
"interval": "daily",
"delay_days": 1,
"time": "14:00",
"timezone": "Asia/Bangkok"
},
"updated": "2026-10-12T11:00:00+07:00",
"livemode": false
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}รายการรอบโอนเงิน
รอบโอนเงินเข้าบัญชีร้าน 1 รอบต่อวันทำการ (T+1 เวลา 14:00) เรียงจากใหม่ไปเก่า
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
statusstringไม่บังคับกรองสถานะ
payout_date[gte]string · dateไม่บังคับวันที่โอนตั้งแต่
payout_date[lte]string · dateไม่บังคับวันที่โอนถึง
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200รอบล่าสุด 2 รอบ
- 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 400
date_range_invalidช่วงวันที่ไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- รอบที่ status = pending ยังเปลี่ยนยอดได้ (การคืนเงินช่วงเช้า) — ลงบัญชีเมื่อ scheduled หรือ paid
- วันหยุดต่อเนื่องรวมเป็นรอบเดียว period_start–period_end จึงยาวกว่า 1 วันได้
curl -X GET "https://sandbox.api.paynara.example/v1/settlements?limit=20&payout_date[gte]=2026-10-11" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/settlements?limit=20&payout_date[gte]=2026-10-11', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/settlements?limit=20&payout_date[gte]=2026-10-11",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"url": "/v1/settlements",
"has_more": true,
"data": [
{
"id": "stl_20261012",
"object": "settlement",
"status": "scheduled",
"period_start": "2026-10-11T00:00:00+07:00",
"period_end": "2026-10-11T23:59:59+07:00",
"payout_date": "2026-10-12",
"payout_at": "2026-10-12T14:00:00+07:00",
"gross_sales": 1053000,
"refunds": 15000,
"fees": 25437,
"fee_vat": 1780,
"adjustments": 0,
"net": 1010783,
"currency": "THB",
"count_charges": 13,
"count_refunds": 1,
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
},
"payout_reference": null,
"report_url": "/v1/settlements/stl_20261012/report.csv",
"created": "2026-10-12T01:05:00+07:00",
"livemode": false
},
{
"id": "stl_20261011",
"object": "settlement",
"status": "paid",
"payout_date": "2026-10-11",
"gross_sales": 960000,
"refunds": 0,
"fees": 26787,
"fee_vat": 1876,
"net": 931337,
"count_charges": 11,
"count_refunds": 0,
"payout_reference": "SRR-PO-20261011-0412",
"paid_at": "2026-10-11T14:00:03+07:00",
"livemode": false
}
],
"next_cursor": "stl_20261011"
}{
"error": {
"code": "cursor_invalid",
"message": "cursor ของการแบ่งหน้าไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#cursor_invalid"
}
}{
"error": {
"code": "date_range_invalid",
"message": "ช่วงวันที่ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#date_range_invalid"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}ดูรอบโอนเงิน
GET/v1/settlements/{settlement_id}
ยอดสรุปของรอบ: ยอดขาย − คืนเงิน − ค่าธรรมเนียม − VAT = ยอดโอน พร้อมแยกตามช่องทาง
Path parameterspath
settlement_idstringจำเป็นรหัสรอบโอน
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200รอบ stl_20261012 (ขายวันที่ 11 ต.ค.)
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- gross_sales − refunds − fees − fee_vat + adjustments = net (ตรวจด้วยตัวกระทบยอดด้านล่าง)
- by_method แยกยอดตามช่องทางให้ลงบัญชีค่าธรรมเนียมแยกประเภทได้
curl -X GET "https://sandbox.api.paynara.example/v1/settlements/stl_20261012" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/settlements/stl_20261012', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/settlements/stl_20261012",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "stl_20261012",
"object": "settlement",
"status": "scheduled",
"period_start": "2026-10-11T00:00:00+07:00",
"period_end": "2026-10-11T23:59:59+07:00",
"payout_date": "2026-10-12",
"payout_at": "2026-10-12T14:00:00+07:00",
"gross_sales": 1053000,
"refunds": 15000,
"fees": 25437,
"fee_vat": 1780,
"adjustments": 0,
"net": 1010783,
"currency": "THB",
"count_charges": 13,
"count_refunds": 1,
"by_method": [
{
"method": "promptpay",
"count": 7,
"gross": 255000,
"fee": 2160,
"fee_vat": 151,
"net": 252689
},
{
"method": "card",
"count": 4,
"gross": 321000,
"fee": 9107,
"fee_vat": 636,
"net": 311257
},
{
"method": "installment",
"count": 1,
"gross": 362000,
"fee": 12670,
"fee_vat": 887,
"net": 348443
},
{
"method": "mobile_banking",
"count": 2,
"gross": 100000,
"fee": 1500,
"fee_vat": 106,
"net": 98394
}
],
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
},
"payout_reference": null,
"report_url": "/v1/settlements/stl_20261012/report.csv",
"created": "2026-10-12T01:05:00+07:00",
"livemode": false
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}รายการในรอบโอน
GET/v1/settlements/{settlement_id}/transactions
ทุก transaction ที่รวมเป็นรอบนี้ (เทียบได้ทีละบรรทัดกับไฟล์ CSV) — แบ่งหน้าแบบ cursor
Path parameterspath
settlement_idstringจำเป็นรหัสรอบโอน
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
typestringไม่บังคับกรองชนิด (คั่นด้วย , ได้)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 20014 รายการ (ตัวอย่าง 2 แถว)
- 404
resource_not_foundไม่พบรายการ - 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ได้รายการเดียวกับแถวในไฟล์ report.csv (ยกเว้นแถว TOTAL) — ใช้แทนไฟล์เมื่อต้องการ JSON
- แบ่งหน้าแบบ cursor ได้สูงสุด 100 รายการต่อหน้า
curl -X GET "https://sandbox.api.paynara.example/v1/settlements/stl_20261012/transactions?limit=20" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/settlements/stl_20261012/transactions?limit=20', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/settlements/stl_20261012/transactions?limit=20",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"url": "/v1/settlements/stl_20261012/transactions",
"has_more": true,
"data": [
{
"id": "txn_2Hd7MqC",
"object": "transaction",
"type": "charge",
"source": "pay_2Hd7Mq",
"order_ref": "ORD-2610-0138",
"method": "promptpay",
"amount": 95000,
"fee": 760,
"fee_vat": 53,
"net": 94187,
"currency": "THB",
"status": "available",
"available_on": "2026-10-12",
"settlement_id": "stl_20261012",
"created": "2026-10-11T08:12:40+07:00",
"livemode": false
},
{
"id": "txn_2Qr6VdC",
"object": "transaction",
"type": "charge",
"source": "pay_2Qr6Vd",
"order_ref": "ORD-2610-0142",
"method": "card",
"amount": 184000,
"fee": 4876,
"fee_vat": 341,
"net": 178783,
"currency": "THB",
"status": "available",
"available_on": "2026-10-12",
"settlement_id": "stl_20261012",
"created": "2026-10-11T11:20:33+07:00",
"livemode": false
}
],
"next_cursor": "txn_2Qr6VdC"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "cursor_invalid",
"message": "cursor ของการแบ่งหน้าไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#cursor_invalid"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}ไฟล์กระทบยอด (CSV)
GET/v1/settlements/{settlement_id}/report.csv
ไฟล์กระทบยอดของรอบ 1 แถวต่อ transaction + แถว TOTAL ท้ายไฟล์ (UTF-8 มี BOM เปิดใน Excel ภาษาไทยได้) · ส่ง Accept: application/json เพื่อรับเป็น JSON (ตัวอย่างผลลัพธ์ด้านขวา) · ตัวอย่างไฟล์ CSV จริงดูที่เครื่องมือ "ตัวกระทบยอด" ท้ายหน้า
Path parameterspath
settlement_idstringจำเป็นรหัสรอบโอน
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Acceptstringไม่บังคับรูปแบบผลลัพธ์
ผลลัพธ์
- 200Accept: application/json — คอลัมน์ + แถว (ย่อ 2 แถว) + ยอดรวม
- 302?redirect=true — redirect ไป URL ไฟล์ที่ลงลายเซ็น (อายุ 15 นาที)
- 409
report_not_readyรายงานยังสร้างไม่เสร็จ - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ไฟล์พร้อมหลัง status = scheduled (ประมาณ 01:05) — ก่อนหน้านั้นได้ 409 report_not_ready
- เงินในไฟล์เป็นสตางค์ (หาร 100 เป็นบาท) เพื่อไม่ให้ทศนิยมเพี้ยนใน Excel
curl -X GET "https://sandbox.api.paynara.example/v1/settlements/stl_20261012/report.csv" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/settlements/stl_20261012/report.csv', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/settlements/stl_20261012/report.csv",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "settlement_report",
"settlement": "stl_20261012",
"columns": [
"settlement_id",
"transaction_id",
"type",
"source_id",
"order_ref",
"method",
"created_at",
"gross_satang",
"fee_satang",
"fee_vat_satang",
"net_satang"
],
"rows": [
[
"stl_20261012",
"txn_2Hd7MqC",
"charge",
"pay_2Hd7Mq",
"ORD-2610-0138",
"promptpay",
"2026-10-11T08:12:40+07:00",
95000,
760,
53,
94187
],
[
"stl_20261012",
"txn_2Jk4WbC",
"charge",
"pay_2Jk4Wb",
"ORD-2610-0139",
"card",
"2026-10-11T08:47:05+07:00",
39000,
1034,
72,
37894
]
],
"total": {
"gross": 1038000,
"fee": 25437,
"fee_vat": 1780,
"net": 1010783
},
"row_count": 14
}(ไม่มีเนื้อหา){
"error": {
"code": "report_not_ready",
"message": "รายงานยังสร้างไม่เสร็จ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#report_not_ready"
}
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}อัตราค่าธรรมเนียมของร้าน
อัตราที่ใช้กับร้านนี้ตามสัญญา แยกตามกลุ่มอัตรา (fee_key) พร้อมวันที่มีผล — ใช้คำนวณยอดสุทธิล่วงหน้าในระบบร้าน
Query parametersquery
as_ofstring · dateไม่บังคับอัตรา ณ วันที่ (ค่าเริ่ม = วันนี้)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200อัตราปัจจุบัน
- 400
parameter_invalidค่าฟิลด์ไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ค่าธรรมเนียม = round(amount × rate) · VAT = round(fee × 0.07) · ปัดครึ่งขึ้นต่อรายการ (ไม่ปัดที่ยอดรวม)
curl -X GET "https://sandbox.api.paynara.example/v1/fees?as_of=2026-10-12" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/fees?as_of=2026-10-12', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/fees?as_of=2026-10-12",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "list",
"as_of": "2026-10-12",
"vat_rate": "7%",
"data": [
{
"fee_key": "promptpay",
"method": "promptpay",
"label": "PromptPay QR",
"rate": "0.8%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 90
},
{
"fee_key": "card",
"method": "card",
"label": "บัตร VISA / Mastercard ที่ออกในไทย",
"rate": "2.65%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 180
},
{
"fee_key": "card_international",
"method": "card",
"label": "บัตร VISA / Mastercard ต่างประเทศ",
"rate": "3.65%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 180
},
{
"fee_key": "installment_3",
"method": "installment",
"label": "ผ่อน 0% 3 เดือน (ร้านรับภาระดอกเบี้ย)",
"rate": "3.5%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 180
},
{
"fee_key": "installment_6",
"method": "installment",
"label": "ผ่อน 0% 6 เดือน",
"rate": "4.5%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 180
},
{
"fee_key": "installment_10",
"method": "installment",
"label": "ผ่อน 0% 10 เดือน",
"rate": "6.5%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 180
},
{
"fee_key": "mobile_banking",
"method": "mobile_banking",
"label": "โมบายแบงก์กิ้ง (เด้งเข้าแอปธนาคาร)",
"rate": "1.5%",
"fixed": 0,
"effective_from": "2026-03-18",
"refund_window_days": 90
}
]
}{
"error": {
"code": "parameter_invalid",
"message": "ค่าฟิลด์ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_invalid"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}สั่งสร้างรายงาน (async)
สร้างรายงานช่วงยาว/จำนวนมากแบบเบื้องหลัง — ตอบ 202 ทันที แล้วแจ้ง report.ready เมื่อไฟล์พร้อม (ปกติไม่เกิน 2 นาทีต่อ 100,000 แถว)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
typestringจำเป็นชนิดรายงาน
interval_startstring · date-timeจำเป็นเริ่ม (ย้อนหลังได้ 25 เดือน)
interval_endstring · date-timeจำเป็นสิ้นสุด (ช่วงยาวสุด 13 เดือน)
formatstringไม่บังคับรูปแบบไฟล์
columnsarray<string>ไม่บังคับคอลัมน์ที่ต้องการ (ไม่ส่ง = ทั้งหมดตามชนิด)
timezonestringไม่บังคับเขตเวลาในไฟล์
ผลลัพธ์
- 202รับคำสั่งแล้ว กำลังสร้าง
- 400
date_range_invalidช่วงวันที่ไม่ถูกต้อง - 400
parameter_missingขาดฟิลด์ที่จำเป็น - 409
idempotency_conflictIdempotency-Key ซ้ำแต่ body ต่าง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ทำงานแบบ async — คืน status = processing ทันที แล้วยิง webhook report.ready เมื่อเสร็จ (ไม่ต้องวนเรียก GET ถี่)
- ช่วงยาวสุด 13 เดือนต่อฉบับ ย้อนหลังได้ 25 เดือน · ลิงก์ดาวน์โหลดหมดอายุใน 1 ชั่วโมง (ขอลิงก์ใหม่ด้วย GET)
curl -X POST "https://sandbox.api.paynara.example/v1/reports" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub" \
-d '{
"type": "transactions",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"format": "csv",
"columns": [],
"timezone": "Asia/Bangkok"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/reports', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': '7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f',
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
body: JSON.stringify({
"type": "transactions",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"format": "csv",
"columns": [],
"timezone": "Asia/Bangkok"
}),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.post(
"https://sandbox.api.paynara.example/v1/reports",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
json={
"type": "transactions",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"format": "csv",
"columns": [],
"timezone": "Asia/Bangkok"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "rpt_9Kd2Ws",
"object": "report",
"type": "transactions",
"status": "processing",
"format": "csv",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"columns": [
"transaction_id",
"type",
"source_id",
"order_ref",
"method",
"created_at",
"gross_satang",
"fee_satang",
"fee_vat_satang",
"net_satang"
],
"row_count": null,
"file": null,
"created": "2026-10-12T11:03:52+07:00",
"livemode": false
}{
"error": {
"code": "date_range_invalid",
"message": "ช่วงวันที่ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#date_range_invalid"
}
}{
"error": {
"code": "parameter_missing",
"message": "ขาดฟิลด์ที่จำเป็น",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_missing"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่ body ต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#idempotency_conflict"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}ดูสถานะรายงาน / ลิงก์ดาวน์โหลด
เมื่อ status = ready จะมี file.url ที่ลงลายเซ็น (อายุ 1 ชั่วโมง) — เรียกใหม่เพื่อขอลิงก์ใหม่ได้ภายใน 30 วัน
Path parameterspath
report_idstringจำเป็นรหัสรายงาน
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200พร้อมดาวน์โหลด
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ระหว่าง processing ได้ 200 พร้อม file = null — แนะนำรอ webhook report.ready แทนการ poll
curl -X GET "https://sandbox.api.paynara.example/v1/reports/rpt_9Kd2Ws" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub"const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/reports/rpt_9Kd2Ws', {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data);import os
import requests
API_KEY = os.environ["API_KEY"] # pn_test_8Qm4ZsT2vXa9Lr
res = requests.get(
"https://sandbox.api.paynara.example/v1/reports/rpt_9Kd2Ws",
headers={
"Authorization": f"Bearer {API_KEY}",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "rpt_9Kd2Ws",
"object": "report",
"type": "transactions",
"status": "ready",
"format": "csv",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"columns": [
"transaction_id",
"type",
"source_id",
"order_ref",
"method",
"created_at",
"gross_satang",
"fee_satang",
"fee_vat_satang",
"net_satang"
],
"row_count": 1284,
"file": {
"url": "https://files.sandbox.paynara.example/reports/rpt_9Kd2Ws.csv?sig=4f0c…",
"size": 186342,
"expires_at": "2026-10-12T12:04:40+07:00"
},
"completed_at": "2026-10-12T11:04:40+07:00",
"created": "2026-10-12T11:03:52+07:00",
"livemode": false
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "authentication_failed",
"message": "API key ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authentication_failed"
}
}{
"error": {
"code": "insufficient_scope",
"message": "key ไม่มีสิทธิ์ (scope) ที่ต้องใช้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_scope"
}
}{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#rate_limited"
}
}Webhooks — แจ้งเหตุการณ์ไปที่ระบบของคุณ
ลงทะเบียน URL ปลายทาง แล้วระบบจะส่ง POST พร้อม JSON ทุกครั้งที่เกิดเหตุการณ์ด้านล่าง · ตอบกลับ 2xx ภายใน 10 วินาที ไม่งั้นจะส่งซ้ำตามตาราง · ทุกคำขอมีหัว Paynara-Signature ให้ตรวจว่ามาจากเราจริง · event อาจมาซ้ำหรือสลับลำดับ ให้ใช้ id กันประมวลผลซ้ำ
settlement.createdตัดรอบแล้ว รอโอน
ส่งเมื่อ: ประมาณ 01:05 ของวันทำการ (ไฟล์ report.csv พร้อมแล้ว)
{
"id": "evt_01JB7Q00",
"type": "settlement.created",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "stl_20261012",
"object": "settlement",
"status": "scheduled",
"period_start": "2026-10-11T00:00:00+07:00",
"period_end": "2026-10-11T23:59:59+07:00",
"payout_date": "2026-10-12",
"payout_at": "2026-10-12T14:00:00+07:00",
"gross_sales": 1053000,
"refunds": 15000,
"fees": 25437,
"fee_vat": 1780,
"adjustments": 0,
"net": 1010783,
"currency": "THB",
"count_charges": 13,
"count_refunds": 1,
"by_method": [
{
"method": "promptpay",
"count": 7,
"gross": 255000,
"fee": 2160,
"fee_vat": 151,
"net": 252689
},
{
"method": "card",
"count": 4,
"gross": 321000,
"fee": 9107,
"fee_vat": 636,
"net": 311257
},
{
"method": "installment",
"count": 1,
"gross": 362000,
"fee": 12670,
"fee_vat": 887,
"net": 348443
},
{
"method": "mobile_banking",
"count": 2,
"gross": 100000,
"fee": 1500,
"fee_vat": 106,
"net": 98394
}
],
"bank_account": {
"bank": "srr",
"bank_name": "ธนาคารสยามรุ่ง (สมมติ)",
"account_last4": "4821"
},
"payout_reference": null,
"report_url": "/v1/settlements/stl_20261012/report.csv",
"created": "2026-10-12T01:05:00+07:00",
"livemode": false
}
}settlement.paidโอนเข้าบัญชีร้านสำเร็จ
ส่งเมื่อ: ธนาคารยืนยันการโอน (รอบ 14:00)
{
"id": "evt_01JB7Q01",
"type": "settlement.paid",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "stl_20261011",
"object": "settlement",
"status": "paid",
"payout_date": "2026-10-11",
"gross_sales": 960000,
"refunds": 0,
"fees": 26787,
"fee_vat": 1876,
"net": 931337,
"count_charges": 11,
"count_refunds": 0,
"payout_reference": "SRR-PO-20261011-0412",
"paid_at": "2026-10-11T14:00:03+07:00",
"livemode": false
}
}settlement.failedโอนไม่สำเร็จ
ส่งเมื่อ: บัญชีปลายทางปิด/อายัด/ชื่อไม่ตรง — ยอดกลับไปที่ available และลองใหม่รอบถัดไปหลังแก้บัญชี
{
"id": "evt_01JB7Q02",
"type": "settlement.failed",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "stl_20260815",
"object": "settlement",
"status": "failed",
"failure_reason": "account_frozen",
"net": 0,
"livemode": false
}
}balance.availableมียอดพร้อมโอน
ส่งเมื่อ: ยอด pending ย้ายเข้า available หลังตัดรอบ
{
"id": "evt_01JB7Q03",
"type": "balance.available",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"object": "balance",
"merchant": "mch_baanmaeplub",
"currency": "THB",
"total": 1010783,
"available": [
{
"amount": 1010783,
"source": "settled",
"note": "รอโอนรอบ stl_20261012 เวลา 14:00"
}
],
"pending": [
{
"amount": 0,
"source": "today",
"note": "เพิ่งตัดรอบ — ยังไม่มียอดของวันใหม่"
}
],
"updated": "2026-10-12T01:05:00+07:00",
"livemode": false
}
}transaction.adjustment.createdมีรายการปรับปรุง
ส่งเมื่อ: หักข้อพิพาท คืนค่าธรรมเนียม หรือแก้ยอดโดยทีมงาน
{
"id": "evt_01JB7Q04",
"type": "transaction.adjustment.created",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "txn_ADJ8Ws2",
"object": "transaction",
"type": "adjustment",
"source": "dsp_6Bn2Lw",
"amount": -15000,
"description": "ค่าดำเนินการข้อพิพาท (คืนให้ถ้าร้านชนะ)",
"status": "pending",
"created": "2026-10-08T16:20:01+07:00"
}
}report.readyรายงานพร้อมดาวน์โหลด
ส่งเมื่อ: POST /v1/reports สร้างเสร็จ
{
"id": "evt_01JB7Q05",
"type": "report.ready",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "rpt_9Kd2Ws",
"object": "report",
"type": "transactions",
"status": "ready",
"format": "csv",
"interval_start": "2026-09-01T00:00:00+07:00",
"interval_end": "2026-09-30T23:59:59+07:00",
"columns": [
"transaction_id",
"type",
"source_id",
"order_ref",
"method",
"created_at",
"gross_satang",
"fee_satang",
"fee_vat_satang",
"net_satang"
],
"row_count": 1284,
"file": {
"url": "https://files.sandbox.paynara.example/reports/rpt_9Kd2Ws.csv?sig=4f0c…",
"size": 186342,
"expires_at": "2026-10-12T12:04:40+07:00"
},
"completed_at": "2026-10-12T11:04:40+07:00",
"created": "2026-10-12T11:03:52+07:00",
"livemode": false
}
}report.failedสร้างรายงานไม่สำเร็จ
ส่งเมื่อ: ข้อมูลเกิน 5 ล้านแถว หรือระบบขัดข้อง — สั่งใหม่โดยแบ่งช่วง
{
"id": "evt_01JB7Q06",
"type": "report.failed",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "rpt_9Kc1Vq",
"object": "report",
"status": "failed",
"failure_reason": "too_many_rows"
}
}ส่งซ้ำเมื่อปลายทางไม่ตอบ
- 1ทันที
- 21 นาที
- 35 นาที
- 430 นาที
- 52 ชั่วโมง
- 66 ชั่วโมง
- 724 ชั่วโมง (ครั้งสุดท้าย)
ครบทุกครั้งแล้วยังล้มเหลว → ปิด endpoint อัตโนมัติและส่งอีเมลแจ้งผู้ดูแล · ดูประวัติการส่งและกดส่งซ้ำได้ในแดชบอร์ด
ตรวจลายเซ็น
# ลายเซ็นอยู่ในหัว Paynara-Signature: t=<unix>,v1=<hex>
# คำนวณ HMAC-SHA256(secret, "<t>.<raw body>") แล้วเทียบกับ v1
printf '%s' "$T.$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET"import crypto from 'node:crypto';
// ใช้ raw body (ยังไม่ parse JSON) เท่านั้น
export function verify(rawBody, sigHeader, secret) {
const parts = Object.fromEntries(sigHeader.split(',').map((p) => p.split('=')));
const age = Math.abs(Date.now() / 1000 - Number(parts.t));
if (age > 300) return false; // เก่ากว่า 5 นาที = ปฏิเสธ (กัน replay)
const expected = crypto.createHmac('sha256', secret).update(parts.t + '.' + rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}import hmac, hashlib, time
def verify(raw_body: bytes, sig_header: str, secret: str) -> bool:
parts = dict(p.split("=", 1) for p in sig_header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False # เก่ากว่า 5 นาที = ปฏิเสธ (กัน replay)
msg = parts["t"].encode() + b"." + raw_body
expected = hmac.new(secret.encode(), msg, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts["v1"])Errors — รหัสข้อผิดพลาด
ทุก error ตอบกลับเป็น JSON รูปแบบเดียวกัน พร้อม request_id สำหรับแจ้งทีมสนับสนุน · รหัส HTTP บอกกลุ่มของปัญหา ส่วน error.code บอกสาเหตุที่แน่นอน (ใช้เขียนเงื่อนไขในโค้ดได้ เพราะไม่เปลี่ยนตามภาษา)
- 4xx คำขอไม่ถูกต้อง — แก้ที่ฝั่งผู้เรียก ส่งซ้ำแบบเดิมจะได้ผลเดิม
- 5xx ปัญหาฝั่งระบบ — ลองใหม่แบบเว้นระยะ (exponential backoff) พร้อม Idempotency-Key
{
"error": {
"code": "date_range_invalid",
"message": "ช่วงวันที่ไม่ถูกต้อง",
"param": "items[0].quantity",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#date_range_invalid"
}
}| HTTP | code | ความหมาย | วิธีแก้ |
|---|---|---|---|
| 400 | date_range_invalid | ช่วงวันที่ไม่ถูกต้อง created[gte] มากกว่า created[lte] หรือช่วงยาวเกิน 92 วัน | แบ่งช่วงไม่เกิน 92 วัน หรือใช้ POST /v1/reports สำหรับช่วงยาว |
| 409 | report_not_ready | รายงานยังสร้างไม่เสร็จ ไฟล์กระทบยอด/รายงานกำลังประมวลผล (status = processing) | รอ webhook report.ready หรือ settlement.created แล้วค่อยดาวน์โหลด |
| 400 | cursor_invalid | cursor ของการแบ่งหน้าไม่ถูกต้อง starting_after / ending_before ไม่ใช่ id ของรายการชนิดเดียวกัน หรือส่งทั้งสองค่าพร้อมกัน | ใช้ id ของรายการสุดท้ายในหน้าก่อนหน้า และส่งเพียงค่าเดียว |
| 400 | parameter_invalid | ค่าฟิลด์ไม่ถูกต้อง ชนิดข้อมูล รูปแบบ หรือค่าที่ไม่อยู่ใน enum เช่น amount เป็นทศนิยม หรือวันที่ไม่ใช่ ISO 8601 | เงินส่งเป็นสตางค์ (จำนวนเต็ม) · เวลาใช้ ISO 8601 พร้อม +07:00 |
| 400 | parameter_missing | ขาดฟิลด์ที่จำเป็น ไม่ได้ส่งฟิลด์ที่ทำเครื่องหมาย "จำเป็น" (ชื่อฟิลด์อยู่ใน error.param) | เพิ่มฟิลด์ตาม error.param แล้วส่งใหม่ |
| 409 | idempotency_conflict | Idempotency-Key ซ้ำแต่ body ต่าง ใช้ Idempotency-Key เดิมภายใน 24 ชม. กับคำขอที่เนื้อหาไม่เหมือนเดิม | สร้าง Idempotency-Key ใหม่ (UUID v4) ต่อ 1 การกระทำ |
| 404 | resource_not_found | ไม่พบรายการ id ไม่มีอยู่ หรือเป็นของร้านค้าอื่น | ตรวจ id และ X-Merchant-Id |
| 403 | livemode_mismatch | ข้อมูล sandbox ปนกับ production อ้าง id ที่สร้างใน sandbox ด้วย live key (หรือกลับกัน) | ใช้ key และ id จากสภาพแวดล้อมเดียวกัน |
| 401 | authentication_failed | API key ไม่ถูกต้อง ไม่ได้ส่ง Authorization หรือ key ถูกเพิกถอน/หมุนแล้ว | ส่ง Authorization: Bearer pn_test_… (sandbox) หรือ pn_live_… (production) ที่ยังใช้งานได้ |
| 403 | merchant_mismatch | X-Merchant-Id ไม่ตรงกับ key key นี้ไม่มีสิทธิ์ทำรายการแทนร้านค้าที่ระบุ (ใช้กับบัญชี platform ที่ดูแลหลายร้าน) | ตรวจ X-Merchant-Id หรือขอสิทธิ์จากร้านค้าในแดชบอร์ด |
| 403 | insufficient_scope | key ไม่มีสิทธิ์ (scope) ที่ต้องใช้ restricted key ไม่ได้รับ scope ของ endpoint นี้ | สร้าง restricted key ใหม่ที่มี scope ตามที่ระบุใน endpoint |
| 429 | rate_limited | เรียกเกินโควตา เกินโควตาต่อ key หรือต่อ endpoint ในช่วงเวลา | รอตาม Retry-After แล้วลองใหม่แบบเว้นระยะเพิ่มขึ้น (exponential backoff + jitter) |
| 500 | api_error | ระบบขัดข้องชั่วคราว ข้อผิดพลาดภายในของ PAYNARA (บันทึกแล้วพร้อม request_id) | ลองใหม่ด้วย Idempotency-Key เดิม · แจ้ง request_id ถ้ายังเกิดซ้ำ |
| 503 | service_unavailable | ปิดปรับปรุงหรือเครือข่ายปลายทางไม่ตอบ ระบบหรือเครือข่ายบัตร/ธนาคารปลายทางไม่พร้อมชั่วคราว | ลองใหม่ภายหลัง · ดูสถานะที่ status.paynara.example |
ไม่พบรหัสที่ค้นหา
Rate limit — โควตาการเรียก
| ขอบเขต | โควตา | Burst | หมายเหตุ |
|---|---|---|---|
| GET รายการ (transactions / settlements) | 20 ครั้ง/วินาที | 40 | ต่อ key |
| GET /v1/balance | 30 ครั้ง/วินาที | — | ยอดคำนวณสด ไม่ต้องแคชเกิน 10 วินาที |
| GET …/report.csv | 5 ครั้ง/วินาที | — | ไฟล์ใหญ่สุด 50 MB |
| POST /v1/reports | 10 ครั้ง/ชม. | — | รายงานค้าง processing พร้อมกันได้ 3 ฉบับ |
RateLimit-Limitโควตาของช่วงเวลาRateLimit-Remainingครั้งที่เหลือRateLimit-Resetวินาทีจนโควตาเริ่มใหม่- เกินโควตา → 429 พร้อม
Retry-After· แนะนำลองใหม่แบบเว้นระยะเพิ่มขึ้น + สุ่มเล็กน้อย (jitter)
HTTP/1.1 429 Too Many Requests
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 23
Retry-After: 23
{
"error": {
"code": "rate_limited",
"message": "เรียกเกินโควตา ลองใหม่ใน 23 วินาที",
"request_id": "req_2Kd9QwZ1"
}
}เวอร์ชันและ Changelog
เลือกเวอร์ชันด้วยหัว Paynara-Version (ไม่ส่ง = เวอร์ชันที่ผูกกับ API key) · การเปลี่ยนที่ไม่ทำให้โค้ดเดิมพัง (เพิ่มฟิลด์/endpoint) ออกในเวอร์ชันเดิมได้ · การเปลี่ยนที่ทำให้พังออกเป็นเวอร์ชันใหม่เสมอ และแจ้งล่วงหน้าอย่างน้อย 6 เดือนก่อนปิดเวอร์ชันเก่า
| เวอร์ชัน | สถานะ | รองรับถึง |
|---|---|---|
2026-08-01 ล่าสุด | ปัจจุบัน | — |
2025-11-15 | ยังรองรับ | 30 ก.ย. 2570 |
2024-06-01 | เลิกใช้แล้ว | 31 ธ.ค. 2569 |
- แก้ไข
2026-08-01report.csv รอบที่มีวันหยุดต่อเนื่องแสดงแถว TOTAL ซ้ำ 2 แถว — แก้แล้ว
- เพิ่ม
2026-08-01settlement.by_method สรุปแยกช่องทาง · balance.capturable
- เปลี่ยน
2026-08-01ฟิลด์ settlement.amount เปลี่ยนชื่อเป็น net (เวอร์ชันเก่ายังได้ amount)
- เพิ่ม
2025-11-15GET /v1/settlements/{id}/report.csv รองรับ Accept: application/json
- ความปลอดภัย
2025-11-15ลิงก์ดาวน์โหลดรายงานลงลายเซ็นและหมดอายุใน 1 ชั่วโมง (เดิม 24 ชั่วโมง)
- เพิ่ม
2025-11-15POST /v1/reports + webhook report.ready / report.failed · GET /v1/fees · GET /v1/settlements/{id}/transactions
- เลิกใช้
2025-11-15GET /v1/balance/history เลิกใช้ ใช้ GET /v1/transactions แทน (รองรับถึง 31 ธ.ค. 2569)
- แก้ไข
2024-06-01VAT ของค่าธรรมเนียมปัดที่ยอดรวมของรอบ ทำให้ต่างจากไฟล์ 1 สตางค์ — เปลี่ยนเป็นปัดต่อรายการ
- เปลี่ยน
2024-06-01รอบโอนเปลี่ยนจาก 10:00 เป็น 14:00 เพื่อรวมการคืนเงินช่วงเช้า
เครื่องมือ: ตัวกระทบยอด
รอบ stl_20261012 (ยอดขายวันที่ 11 ต.ค. โอนเข้าธนาคารสยามรุ่ง (สมมติ) 12 ต.ค. 14:00) — ทุกตัวเลขคำนวณจากรายการจริงในตาราง: ค่าธรรมเนียม = round(ยอด × อัตรา) · VAT = round(ค่าธรรมเนียม × 7%) ต่อรายการ · ติ๊กแถวที่จับคู่กับระบบร้านได้ แล้วกรอกยอดที่เข้าบัญชีจริงเพื่อตรวจ
| ตรง | เวลา | transaction | คำสั่งซื้อ | ช่องทาง | ยอด | ค่าธรรมเนียม | VAT | สุทธิ |
|---|
ตัวอย่างไฟล์ report.csv (ตามตัวกรองที่เลือก)
settlement_id,transaction_id,type,source_id,order_ref,method,created_at,gross_satang,fee_satang,fee_vat_satang,net_satang
stl_20261012,txn_2Hd7MqC,charge,pay_2Hd7Mq,ORD-2610-0138,promptpay,2026-10-11T08:12:40+07:00,95000,760,53,94187
stl_20261012,txn_2Jk4WbC,charge,pay_2Jk4Wb,ORD-2610-0139,card,2026-10-11T08:47:05+07:00,39000,1034,72,37894
stl_20261012,txn_2Lm9RtC,charge,pay_2Lm9Rt,ORD-2610-0140,promptpay,2026-10-11T09:30:18+07:00,22000,176,12,21812
stl_20261012,txn_2Np3XcC,charge,pay_2Np3Xc,ORD-2610-0141,mobile_banking,2026-10-11T10:05:51+07:00,70000,1050,74,68876
stl_20261012,txn_2Qr6VdC,charge,pay_2Qr6Vd,ORD-2610-0142,card,2026-10-11T11:20:33+07:00,184000,4876,341,178783
stl_20261012,txn_2St8KeC,charge,pay_2St8Ke,ORD-2610-0143,installment,2026-10-11T12:02:14+07:00,362000,12670,887,348443
stl_20261012,txn_2Uv1LfC,charge,pay_2Uv1Lf,ORD-2610-0144,promptpay,2026-10-11T13:15:09+07:00,24000,192,13,23795
stl_20261012,txn_2Wx5NgC,charge,pay_2Wx5Ng,ORD-2610-0145,card,2026-10-11T14:40:27+07:00,60000,2190,153,57657
stl_20261012,txn_2Yz2PhC,charge,pay_2Yz2Ph,ORD-2610-0146,promptpay,2026-10-11T15:22:46+07:00,42000,336,24,41640
stl_20261012,txn_3Cd4SkC,charge,pay_3Cd4Sk,ORD-2610-0147,promptpay,2026-10-11T16:09:58+07:00,36000,288,20,35692
stl_20261012,txn_3Ef8TmC,charge,pay_3Ef8Tm,ORD-2610-0148,promptpay,2026-10-11T17:31:40+07:00,51000,408,29,50563
stl_20261012,txn_3Gh1UnC,charge,pay_3Gh1Un,ORD-2610-0149,mobile_banking,2026-10-11T18:44:03+07:00,30000,450,32,29518
stl_20261012,txn_3Jk6VpC,charge,pay_3Jk6Vp,ORD-2610-0150,card,2026-10-11T19:58:21+07:00,38000,1007,70,36923
stl_20261012,txn_4Xc8HnR,refund,rf_4Xc8Hn,ORD-2610-0126,promptpay,2026-10-11T10:41:22+07:00,-15000,0,0,-15000
TOTAL,,,,,,,1038000,25437,1780,1010783