สารบัญหน้านี้ (25)
- ภาพรวมโมดูล
- Workflow: ตั้ง webhook ครั้งแรก
- Workflow: ปลายทางล่ม
- The Webhook Endpoint object
- The Event object
- The Webhook Attempt object
- Endpoints (13)
- POSTลงทะเบียน webhook endpoint
- GETรายการ webhook endpoint
- GETดู webhook endpoint
- PATCHแก้ไข / เปิด-ปิด endpoint
- DELETEลบ webhook endpoint
- POSTหมุน secret
- POSTส่ง event ทดสอบ
- GETรายการ event
- GETดู event
- GETประวัติการส่งของ event
- POSTส่ง event ซ้ำ
- GETดูการแจ้งเตือนถึงร้าน (อีเมล / LINE)
- PUTตั้งการแจ้งเตือนถึงร้าน
- Webhooks (5)
- Errors
- Rate limit
- เวอร์ชันและ Changelog
- เครื่องมือ: ตัวดูประวัติการส่ง webhook
- PAYNARA
- Docs
- Payment API
- Notification
PAYNARA Payments API · โมดูล 5/5
Webhooks & Notifications API
ให้ระบบของร้านรู้ทันทีเมื่อเงินเข้า คืนเงิน หรือรอบโอนเสร็จ ผ่าน webhook ที่ลงลายเซ็น HMAC-SHA256 · ดูประวัติการส่งทุกครั้งและส่งซ้ำได้ · ตั้งการแจ้งเตือนถึงเจ้าของร้านทางอีเมลและ LINE
/v1/webhook-endpoints/v1/events/v1/notification-settings

ภาพรวมโมดูล Notification
ใช้เมื่อไร
- อัปเดตสถานะคำสั่งซื้ออัตโนมัติเมื่อ payment.succeeded — แทนการ poll
- โปรแกรมบัญชีรับ settlement.* ไปลงบัญชีทุกวัน
- ระบบร้านล่มแล้วต้องตามเก็บ event ที่พลาด — GET /v1/events + resend
- เจ้าของร้านอยากรู้ยอดใหญ่/ข้อพิพาททันทีทาง LINE — /v1/notification-settings
Object หลัก
-
Webhook EndpointURL ปลายทาง 1 ตัวของร้าน พร้อม event ที่รับและสถิติ — ตัวอย่าง: ระบบหลังร้านของบ้านแม่ปลื้ม -
Eventเหตุการณ์ 1 ครั้ง (เก็บ 30 วัน) — data.object คือสำเนา object ณ เวลาเกิดเหตุ -
Webhook Attemptการพยายามส่ง 1 ครั้ง — ตัวอย่าง: ส่ง settlement.paid ไปโปรแกรมบัญชีแล้วหมดเวลา
การยืนยันตัวตน
ทุกคำขอส่ง API key แบบ Bearer + X-Merchant-Id ของร้าน · sandbox ใช้ pn_test_… production ใช้ pn_live_… · แนะนำสร้าง restricted key ที่มีเฉพาะ scope ที่ระบบนั้นใช้ (เช่น ระบบบัญชีได้แค่ *:read)
POST https://sandbox.api.paynara.example/v1/webhook-endpoints 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 | สิทธิ์ | ระดับ |
|---|---|---|
webhooks:read | ดู endpoint | อ่าน |
webhooks:write | สร้าง แก้ ลบ หมุน secret ทดสอบ และส่ง event ซ้ำ | เขียน |
events:read | ดู event และประวัติการส่ง | อ่าน |
notifications:read | ดูการแจ้งเตือนถึงร้าน | อ่าน |
notifications:write | ตั้งการแจ้งเตือนถึงร้าน | เขียน |
ความสัมพันธ์กับโมดูลอื่น
- Paymentevent payment.* และ checkout.session.* (รายชื่อเต็มพร้อม payload ในหน้า Payment)
- Transactionsettlement.* · balance.available · report.ready
- Refundrefund.* และ refund.batch.completed
- Verificationmerchant.verification.* · risk.review_required · dispute.* · slip.duplicate_detected
ข้อควรรู้
-
ตรวจลายเซ็นทุกครั้ง
Paynara-Signature: t=<unix>,v1=<HMAC-SHA256(secret, "t.raw_body")> · ปฏิเสธถ้า t เก่าเกิน 5 นาที (กัน replay)
-
มาซ้ำ/สลับลำดับได้
ใช้ event.id กันประมวลผลซ้ำ · ตัดสินสถานะจาก data.object.status หรือ GET ล่าสุด ไม่ใช่ลำดับที่ได้รับ
-
ตอบภายใน 10 วินาที
ไม่ตอบ 2xx → ส่งซ้ำ 7 ครั้ง (ทันที · 1 นาที · 5 นาที · 30 นาที · 2 ชั่วโมง · 6 ชั่วโมง · 24 ชั่วโมง (ครั้งสุดท้าย)) · ล้มเหลวต่อเนื่อง 3 วัน → ปิด endpoint
-
เวลา ISO 8601 +07:00
event.created เป็นเวลาไทย · t ในลายเซ็นเป็น unix วินาที (UTC)
-
แบ่งหน้าแบบ cursor
GET /v1/events ย้อนหลัง 30 วัน ใช้ limit + starting_after
-
PDPA
payload มีอีเมล/เบอร์ลูกค้าแบบปิดบังเท่านั้น · การแจ้งเตือนทาง LINE/อีเมลถึงร้านไม่มีข้อมูลลูกค้า
Workflow (2 เรื่อง)
แต่ละเรื่องดูได้ 2 แบบ: ภาพรวม สำหรับทุกคนในทีม และ Sequence ทีละขั้น สำหรับนักพัฒนา (กดเล่น หรือคลิกลูกศรเพื่อดูคำขอ/ผลลัพธ์จริงของขั้นนั้น) · ลูกศรประ = ไม่รอผล (webhook/คิว)
ตั้ง webhook ครั้งแรก — ทดสอบไม่ผ่านเพราะใบรับรอง TLS แก้แล้วรับ event จริง
นักพัฒนาของร้านเชื่อมระบบหลังร้านกับ PAYNARA เพื่ออัปเดตสถานะคำสั่งซื้ออัตโนมัติ
- นักพัฒนาของร้าน
- ระบบหลังร้านปลายทาง webhook
- PAYNARA API
- ตัวส่ง webhookคิว + ส่งซ้ำ
- 1
นักพัฒนาของร้าน → PAYNARA API
ลงทะเบียน URL และเลือก event ที่ต้องใช้
POST /v1/webhook-endpoints - 2
นักพัฒนาของร้าน → ระบบหลังร้าน
บันทึก secret เป็นตัวแปรสภาพแวดล้อม (ไม่เก็บในโค้ด)
- 3
นักพัฒนาของร้าน → PAYNARA API
ส่ง event ทดสอบ — ปลายทางเชื่อมต่อไม่ได้เพราะใบรับรอง TLS หมดอายุ
POST /v1/webhook-endpoints/we_9Lp3Ds/test - 4
นักพัฒนาของร้าน → ระบบหลังร้าน
ต่ออายุใบรับรองของโดเมนร้าน
- 5
นักพัฒนาของร้าน → PAYNARA API
ทดสอบใหม่ ปลายทางตอบ 200
POST /v1/webhook-endpoints/we_9Lp3Ds/test - 6
PAYNARA API → ตัวส่ง webhook
คุณอรอุมาจ่าย ORD-2610-0153 สำเร็จ ระบบสร้าง event evt_7Gq2Mn
ไม่รอผล (async) - 7
ตัวส่ง webhook → ระบบหลังร้าน
ส่ง event พร้อมลายเซ็น HMAC-SHA256
POST /api/paynara/webhookไม่รอผล (async) - 8
ระบบหลังร้าน → ระบบหลังร้าน
ตรวจ HMAC กับ raw body · เวลา t ไม่เกิน 5 นาที · ถ้าเคยรับ evt นี้แล้วตอบ 200 เฉย ๆ
- 9
ระบบหลังร้าน → ตัวส่ง webhook
ตอบภายใน 184 ms แล้วค่อยอัปเดตคำสั่งซื้อในคิวของร้าน
- 10
นักพัฒนาของร้าน → PAYNARA API
ตรวจประวัติว่าส่งครั้งเดียวสำเร็จ
GET /v1/events/evt_7Gq2Mn/attempts
ตั้งค่าเสร็จใน 15 นาที · event แรกจริง (payment.succeeded ของ ORD-2610-0153) ส่งถึงใน 184 ms ครั้งเดียว · ตรวจลายเซ็นผ่าน
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 นักพัฒนาของร้าน PAYNARA API
POST /v1/webhook-endpoints
ลงทะเบียน URL และเลือก event ที่ต้องใช้
POST /v1/webhook-endpoints HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"url": "https://baanmaeplub.example/api/paynara/webhook",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
]
}HTTP/1.1 201 Created
{
"id": "we_9Lp3Ds",
"status": "enabled",
"secret": "pn_whs_test_4f8a1c9e2b"
}2 นักพัฒนาของร้าน ระบบหลังร้าน
เก็บ secret ใน env
บันทึก secret เป็นตัวแปรสภาพแวดล้อม (ไม่เก็บในโค้ด)
3 นักพัฒนาของร้าน PAYNARA API
POST …/test
ส่ง event ทดสอบ — ปลายทางเชื่อมต่อไม่ได้เพราะใบรับรอง TLS หมดอายุ
POST /v1/webhook-endpoints/we_9Lp3Ds/test HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"event_type": "payment.succeeded"
}HTTP/1.1 422 Unprocessable Entity
{
"error": {
"code": "url_unreachable",
"message": "เชื่อมต่อ TLS ไม่สำเร็จ: certificate has expired",
"request_id": "req_5Nn2Wq"
}
}4 นักพัฒนาของร้าน ระบบหลังร้าน
ต่ออายุใบรับรอง
ต่ออายุใบรับรองของโดเมนร้าน
5 นักพัฒนาของร้าน PAYNARA API
POST …/test (อีกครั้ง)
ทดสอบใหม่ ปลายทางตอบ 200
POST /v1/webhook-endpoints/we_9Lp3Ds/test HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"event_type": "payment.succeeded"
}HTTP/1.1 200 OK
{
"status_code": 200,
"duration_ms": 143
}6 PAYNARA API ตัวส่ง webhookasync
payment.succeeded เกิดขึ้น
คุณอรอุมาจ่าย ORD-2610-0153 สำเร็จ ระบบสร้าง event evt_7Gq2Mn
7 ตัวส่ง webhook ระบบหลังร้านasync
POST + Paynara-Signature
ส่ง event พร้อมลายเซ็น HMAC-SHA256
POST /api/paynara/webhook HTTP/1.1
Content-Type: application/json
Paynara-Signature: t=1791774873,v1=5b1e…
{
"id": "evt_7Gq2Mn",
"type": "payment.succeeded",
"data": {
"object": {
"id": "pay_3NqL8k",
"status": "succeeded"
}
}
}8 ระบบหลังร้าน ระบบหลังร้าน
ตรวจลายเซ็น + กันซ้ำ
ตรวจ HMAC กับ raw body · เวลา t ไม่เกิน 5 นาที · ถ้าเคยรับ evt นี้แล้วตอบ 200 เฉย ๆ
9 ระบบหลังร้าน ตัวส่ง webhook
200 {"received":true}
ตอบภายใน 184 ms แล้วค่อยอัปเดตคำสั่งซื้อในคิวของร้าน
HTTP/1.1 200 OK
{
"received": true
}10 นักพัฒนาของร้าน PAYNARA API
GET /v1/events/evt_7Gq2Mn/attempts
ตรวจประวัติว่าส่งครั้งเดียวสำเร็จ
GET /v1/events/evt_7Gq2Mn/attempts HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"object": "list",
"url": "/v1/events/evt_7Gq2Mn/attempts",
"has_more": false,
"data": [
{
"id": "wha_7Gq2Mn1",
"object": "webhook_attempt",
"event": "evt_7Gq2Mn",
"endpoint": "we_9Lp3Ds",
"attempt": 1,
"status_code": 200,
"duration_ms": 184,
"error": null,
"request": {
"url": "https://baanmaeplub.example/api/paynara/webhook",
"headers": {
"Content-Type": "application/json",
"User-Agent": "PAYNARA-Webhooks/2026-08-01",
"Paynara-Signature": "t=1791774873,v1=5b1e0f…"
}
},
"response": {
"body_excerpt": "{\"received\":true}"
},
"next_attempt_at": null,
"created": "2026-10-12T10:14:33+07:00"
}
],
"next_cursor": null
}ตั้งค่าเสร็จใน 15 นาที · event แรกจริง (payment.succeeded ของ ORD-2610-0153) ส่งถึงใน 184 ms ครั้งเดียว · ตรวจลายเซ็นผ่าน
ปลายทางล่ม — ส่งซ้ำตามตาราง → ระบบปิด endpoint → แก้แล้วส่งซ้ำ
โปรแกรมบัญชีของร้าน (https://erp.baanmaeplub.example/hooks/paynara) ตอบ 502/หมดเวลาหลังย้ายเซิร์ฟเวอร์ — event settlement.* ส่งไม่ถึง
- ตัวส่ง webhook
- โปรแกรมบัญชีของร้าน
- PAYNARA API
- เจ้าของร้านอีเมล / LINE
- นักพัฒนา
- 1
ตัวส่ง webhook → โปรแกรมบัญชีของร้าน
ส่ง event evt_6Pa3Hz (รอบโอน stl_20261011 ฿9,313.37) — ไม่ตอบใน 10 วินาที
ไม่รอผล (async) - 2
ตัวส่ง webhook → ตัวส่ง webhook
ลองใหม่ตามตาราง ได้ 502 Bad Gateway ทุกครั้ง
- 3
PAYNARA API → PAYNARA API
endpoint ไม่สำเร็จเลยตั้งแต่ 9 ต.ค. ระบบปิดอัตโนมัติเพื่อไม่ส่งข้อมูลไปที่ที่อาจไม่ใช่ของร้านแล้ว
- 4
PAYNARA API → เจ้าของร้าน
แจ้งเจ้าของร้านตามกฎการแจ้งเตือน (ส่งแม้อยู่ในช่วงงดแจ้ง)
ไม่รอผล (async) - 5
นักพัฒนา → PAYNARA API
ดูสาเหตุและสถิติ
GET /v1/webhook-endpoints/we_2Vx8Gr - 6
นักพัฒนา → โปรแกรมบัญชีของร้าน
พบว่า proxy ใหม่ไม่ได้ส่งต่อ path /hooks/ จึงแก้และทดสอบ
- 7
นักพัฒนา → PAYNARA API
เปิด endpoint อีกครั้ง
PATCH /v1/webhook-endpoints/we_2Vx8Gr - 8
นักพัฒนา → PAYNARA API
หา event ที่ตกค้าง
GET /v1/events?endpoint=we_2Vx8Gr&delivery_status=failed - 9
นักพัฒนา → PAYNARA API
ส่งซ้ำทีละ event (id เดิม — โปรแกรมบัญชีกันซ้ำได้)
POST /v1/events/evt_6Pa3Hz/resend - 10
ตัวส่ง webhook → โปรแกรมบัญชีของร้าน
ครั้งนี้ปลายทางตอบ 200 ใน 96 ms
ไม่รอผล (async) - 11
นักพัฒนา → PAYNARA API
event รอบโอนเดือนสิงหาคมเก่ากว่า 30 วันส่งซ้ำไม่ได้ จึงดึง GET /v1/settlements แทน
POST /v1/events/evt_4Kc1Ds/resend
ไม่มี event หาย: เปิด endpoint แล้วส่งซ้ำ 2 event ภายใน 2 นาที · event เก่ากว่า 30 วันดึงข้อมูลผ่าน GET แทน · เจ้าของร้านรู้ทางอีเมลตั้งแต่ endpoint ถูกปิด
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 ตัวส่ง webhook โปรแกรมบัญชีของร้านasync
ส่ง settlement.paid ครั้งที่ 1
ส่ง event evt_6Pa3Hz (รอบโอน stl_20261011 ฿9,313.37) — ไม่ตอบใน 10 วินาที
ไม่ตอบภายใน 10,000 ms นับเป็นล้มเหลว (ไม่มี status code)
2 ตัวส่ง webhook ตัวส่ง webhook
ส่งซ้ำ 1 นาที · 5 นาที · 30 นาที · 2 ชั่วโมง · 6 ชั่วโมง
ลองใหม่ตามตาราง ได้ 502 Bad Gateway ทุกครั้ง
3 PAYNARA API PAYNARA API
ล้มเหลวต่อเนื่อง 3 วัน → ปิด
endpoint ไม่สำเร็จเลยตั้งแต่ 9 ต.ค. ระบบปิดอัตโนมัติเพื่อไม่ส่งข้อมูลไปที่ที่อาจไม่ใช่ของร้านแล้ว
4 PAYNARA API เจ้าของร้านasync
อีเมล webhook_endpoint.disabled
แจ้งเจ้าของร้านตามกฎการแจ้งเตือน (ส่งแม้อยู่ในช่วงงดแจ้ง)
5 นักพัฒนา PAYNARA API
GET /v1/webhook-endpoints/we_2Vx8Gr
ดูสาเหตุและสถิติ
GET /v1/webhook-endpoints/we_2Vx8Gr HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"id": "we_2Vx8Gr",
"status": "disabled",
"disabled_reason": "ส่งไม่สำเร็จต่อเนื่อง 3 วัน (ระบบปิดอัตโนมัติ)",
"stats": {
"failed_24h": 7
}
}6 นักพัฒนา โปรแกรมบัญชีของร้าน
แก้ reverse proxy
พบว่า proxy ใหม่ไม่ได้ส่งต่อ path /hooks/ จึงแก้และทดสอบ
7 นักพัฒนา PAYNARA API
PATCH …/we_2Vx8Gr enabled
เปิด endpoint อีกครั้ง
PATCH /v1/webhook-endpoints/we_2Vx8Gr HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"status": "enabled"
}HTTP/1.1 200 OK
{
"id": "we_2Vx8Gr",
"status": "enabled"
}8 นักพัฒนา PAYNARA API
GET /v1/events?delivery_status=failed
หา event ที่ตกค้าง
GET /v1/events?endpoint=we_2Vx8Gr&delivery_status=failed HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"object": "list",
"data": [
{
"id": "evt_7Kt1Qr",
"type": "settlement.created"
},
{
"id": "evt_6Pa3Hz",
"type": "settlement.paid"
}
]
}9 นักพัฒนา PAYNARA API
POST /v1/events/evt_6Pa3Hz/resend
ส่งซ้ำทีละ event (id เดิม — โปรแกรมบัญชีกันซ้ำได้)
POST /v1/events/evt_6Pa3Hz/resend HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"endpoint": "we_2Vx8Gr"
}HTTP/1.1 202 Accepted
{
"event": "evt_6Pa3Hz",
"status": "queued",
"attempt": 7
}10 ตัวส่ง webhook โปรแกรมบัญชีของร้านasync
ส่งซ้ำ → 200
ครั้งนี้ปลายทางตอบ 200 ใน 96 ms
HTTP/1.1 200 OK
{
"received": true
}11 นักพัฒนา PAYNARA API
resend event เดือนก่อน
event รอบโอนเดือนสิงหาคมเก่ากว่า 30 วันส่งซ้ำไม่ได้ จึงดึง GET /v1/settlements แทน
POST /v1/events/evt_4Kc1Ds/resend HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 410
{
"error": {
"code": "event_expired",
"message": "event เก่ากว่า 30 วัน ส่งซ้ำไม่ได้",
"request_id": "req_9Td3Ha"
}
}ไม่มี event หาย: เปิด endpoint แล้วส่งซ้ำ 2 event ภายใน 2 นาที · event เก่ากว่า 30 วันดึงข้อมูลผ่าน GET แทน · เจ้าของร้านรู้ทางอีเมลตั้งแต่ endpoint ถูกปิด
Objects
The Webhook Endpoint object
URL ปลายทาง 1 ตัวของร้าน พร้อม event ที่รับและสถิติ — ตัวอย่าง: ระบบหลังร้านของบ้านแม่ปลื้ม
idstringไม่บังคับอ่านอย่างเดียวรหัส endpoint (we_)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
urlstring · uriจำเป็นURL ปลายทาง (https เท่านั้น · ไม่รับ localhost/IP ภายใน)
descriptionstringไม่บังคับคำอธิบายสำหรับทีม
enabled_eventsarray<string>จำเป็นevent ที่ต้องการ ("*" = ทั้งหมด · รองรับ "payment.*")
statusstringไม่บังคับenabled / disabled (ปิดเอง หรือระบบปิดเมื่อส่งไม่สำเร็จต่อเนื่อง 3 วัน)
disabled_reasonstringไม่บังคับอ่านอย่างเดียวเหตุผลที่ถูกปิด
api_versionstringไม่บังคับรูปแบบ payload ของ event (ล็อกตอนสร้าง — เปลี่ยนด้วย PATCH)
secretstringไม่บังคับอ่านอย่างเดียวความลับสำหรับตรวจลายเซ็น — คืนเฉพาะตอนสร้างและหลังหมุน เก็บไว้ทันที
secret_last4stringไม่บังคับอ่านอย่างเดียวเลขท้ายของความลับปัจจุบัน
previous_secret_expires_atstring · date-timeไม่บังคับอ่านอย่างเดียวหลังหมุน ความลับเก่ายังใช้ได้ถึงเวลานี้ (ลงลายเซ็นทั้ง 2 ตัวใน v1 คนละค่า)
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
statsobjectไม่บังคับอ่านอย่างเดียวสถิติการส่ง
ฟิลด์ย่อยของ
stats(4)delivered_24hintegerไม่บังคับส่งสำเร็จ 24 ชม.
failed_24hintegerไม่บังคับล้มเหลว 24 ชม.
success_rate_7dnumberไม่บังคับอัตราสำเร็จ 7 วัน (0–1)
avg_ms_7dintegerไม่บังคับเวลาตอบเฉลี่ย (ms)
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
updatedstring · date-timeไม่บังคับอ่านอย่างเดียวแก้ไขล่าสุด
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "we_9Lp3Ds",
"object": "webhook_endpoint",
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"status": "enabled",
"disabled_reason": null,
"api_version": "2026-08-01",
"secret_last4": "9e2b",
"metadata": {},
"stats": {
"delivered_24h": 4,
"failed_24h": 0,
"success_rate_7d": 0.993,
"avg_ms_7d": 212
},
"created": "2026-03-21T10:05:00+07:00",
"updated": "2026-10-01T09:10:00+07:00",
"livemode": false
}
The Event object
เหตุการณ์ 1 ครั้ง (เก็บ 30 วัน) — data.object คือสำเนา object ณ เวลาเกิดเหตุ
idstringไม่บังคับอ่านอย่างเดียวรหัส event (evt_) — ใช้กันประมวลผลซ้ำ
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
typestringไม่บังคับอ่านอย่างเดียวชนิด event (ดูรายชื่อในหัวข้อ Webhooks ของทุกหน้า)
merchantstringไม่บังคับอ่านอย่างเดียวร้านค้าเจ้าของเหตุการณ์ (บัญชี platform ใช้แยกว่าเป็นของร้านไหน)
api_versionstringไม่บังคับอ่านอย่างเดียวรูปแบบ data ตามเวอร์ชันของ endpoint
dataobjectไม่บังคับอ่านอย่างเดียวข้อมูล
ฟิลด์ย่อยของ
data(2)objectobjectไม่บังคับสำเนา object ณ เวลาเกิดเหตุการณ์ (payment / refund / settlement …)
previous_attributesobjectไม่บังคับค่าก่อนเปลี่ยน (เฉพาะ *.updated)
object_typestringไม่บังคับอ่านอย่างเดียวชนิด object ใน data (ใช้แยกเส้นทางประมวลผล)
object_idstringไม่บังคับอ่านอย่างเดียวid ของ object (ใช้ GET ล่าสุดแทนการเชื่อ data ที่อาจเก่า)
sourcestringไม่บังคับอ่านอย่างเดียวที่มาของเหตุการณ์
pending_webhooksintegerไม่บังคับอ่านอย่างเดียวจำนวน endpoint ที่ยังส่งไม่สำเร็จ
requestobjectไม่บังคับอ่านอย่างเดียวคำขอ API ที่ทำให้เกิด event (null ถ้าเกิดจากระบบ)
ฟิลด์ย่อยของ
request(2)idstringไม่บังคับrequest_id
idempotency_keystringไม่บังคับIdempotency-Key ของคำขอ
deliveryobjectไม่บังคับอ่านอย่างเดียวสรุปการส่งไปยัง endpoint
ฟิลด์ย่อยของ
delivery(5)endpointstringไม่บังคับwe_…
statusstringไม่บังคับสถานะ
attemptsintegerไม่บังคับจำนวนครั้งที่ส่ง
last_attempt_atstring · date-timeไม่บังคับส่งล่าสุด
next_attempt_atstring · date-timeไม่บังคับส่งครั้งถัดไป (null ถ้าจบแล้ว)
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
expires_atstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาที่ event ถูกลบ (created + 30 วัน) — หลังจากนี้ GET /v1/events/{id} ได้ 404 และส่งซ้ำไม่ได้
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "evt_7Gq2Mn",
"object": "event",
"type": "payment.succeeded",
"merchant": "mch_baanmaeplub",
"api_version": "2026-08-01",
"created": "2026-10-12T10:14:33+07:00",
"expires_at": "2026-11-11T10:14:33+07:00",
"livemode": false,
"object_type": "payment",
"object_id": "pay_3NqL8k",
"source": "api",
"pending_webhooks": 0,
"data": {
"object": {
"id": "pay_3NqL8k",
"object": "payment",
"status": "succeeded",
"amount": 104000,
"amount_received": 104000,
"order_ref": "ORD-2610-0153"
}
},
"request": {
"id": "req_3Gq8Ls",
"idempotency_key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f"
},
"delivery": {
"endpoint": "we_9Lp3Ds",
"status": "delivered",
"attempts": 1,
"last_attempt_at": "2026-10-12T10:14:33+07:00",
"next_attempt_at": null
}
}
The Webhook Attempt object
การพยายามส่ง 1 ครั้ง — ตัวอย่าง: ส่ง settlement.paid ไปโปรแกรมบัญชีแล้วหมดเวลา
idstringไม่บังคับอ่านอย่างเดียวรหัสความพยายามส่ง (wha_)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
eventstringไม่บังคับอ่านอย่างเดียวevent ที่ส่ง
endpointstringไม่บังคับอ่านอย่างเดียวendpoint ปลายทาง
attemptintegerไม่บังคับอ่านอย่างเดียวครั้งที่ (1–7 · ส่งซ้ำด้วยมือนับต่อ)
status_codeintegerไม่บังคับอ่านอย่างเดียวHTTP status ที่ปลายทางตอบ (null = ไม่ตอบ/เชื่อมต่อไม่ได้)
duration_msintegerไม่บังคับอ่านอย่างเดียวเวลาตอบ (ms) · เกิน 10,000 = หมดเวลา
errorstringไม่บังคับอ่านอย่างเดียวสาเหตุถ้าไม่สำเร็จ
requestobjectไม่บังคับอ่านอย่างเดียวURL และหัวที่ส่ง (ไม่รวม body เพื่อลดขนาด)
ฟิลด์ย่อยของ
request(2)urlstringไม่บังคับURL
headersobjectไม่บังคับหัว HTTP รวม Paynara-Signature
responseobjectไม่บังคับอ่านอย่างเดียวคำตอบจากปลายทาง (ตัด 1 KB แรก)
ฟิลด์ย่อยของ
response(1)body_excerptstringไม่บังคับเนื้อหาบางส่วน
next_attempt_atstring · date-timeไม่บังคับอ่านอย่างเดียวครั้งถัดไปตามตารางส่งซ้ำ
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
{
"id": "wha_6Pa3Hz1",
"object": "webhook_attempt",
"event": "evt_6Pa3Hz",
"endpoint": "we_2Vx8Gr",
"attempt": 1,
"status_code": null,
"duration_ms": 10000,
"error": "หมดเวลา 10 วินาที",
"request": {
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"headers": {
"Content-Type": "application/json",
"User-Agent": "PAYNARA-Webhooks/2026-08-01",
"Paynara-Signature": "t=1791702004,v1=5b1e0f…"
}
},
"response": {
"body_excerpt": null
},
"next_attempt_at": "2026-10-11T14:01:04+07:00",
"created": "2026-10-11T14:00:04+07:00"
}Endpoints (13)
| Method | Path | ทำอะไร | scope |
|---|---|---|---|
| POST | /v1/webhook-endpoints | ลงทะเบียน webhook endpoint | webhooks:write |
| GET | /v1/webhook-endpoints | รายการ webhook endpoint | webhooks:read |
| GET | /v1/webhook-endpoints/{endpoint_id} | ดู webhook endpoint | webhooks:read |
| PATCH | /v1/webhook-endpoints/{endpoint_id} | แก้ไข / เปิด-ปิด endpoint | webhooks:write |
| DELETE | /v1/webhook-endpoints/{endpoint_id} | ลบ webhook endpoint | webhooks:write |
| POST | /v1/webhook-endpoints/{endpoint_id}/rotate-secret | หมุน secret | webhooks:write |
| POST | /v1/webhook-endpoints/{endpoint_id}/test | ส่ง event ทดสอบ | webhooks:write |
| GET | /v1/events | รายการ event | events:read |
| GET | /v1/events/{event_id} | ดู event | events:read |
| GET | /v1/events/{event_id}/attempts | ประวัติการส่งของ event | events:read |
| POST | /v1/events/{event_id}/resend | ส่ง event ซ้ำ | webhooks:write |
| GET | /v1/notification-settings | ดูการแจ้งเตือนถึงร้าน (อีเมล / LINE) | notifications:read |
| PUT | /v1/notification-settings | ตั้งการแจ้งเตือนถึงร้าน | notifications:write |
ลงทะเบียน webhook endpoint
ลงทะเบียน URL ของร้านเพื่อรับ event · ได้ secret สำหรับตรวจลายเซ็นกลับมาครั้งเดียว — ร้านละไม่เกิน 16 endpoint ต่อสภาพแวดล้อม
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
urlstring · uriจำเป็นURL ปลายทาง (https เท่านั้น · ไม่รับ localhost/IP ภายใน)
descriptionstringไม่บังคับคำอธิบายสำหรับทีม
enabled_eventsarray<string>จำเป็นevent ที่ต้องการ ("*" = ทั้งหมด · รองรับ "payment.*")
api_versionstringไม่บังคับรูปแบบ payload ของ event (ล็อกตอนสร้าง — เปลี่ยนด้วย PATCH)
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
ผลลัพธ์
- 201สร้างแล้ว — เก็บ secret ทันที (ดูซ้ำไม่ได้)
- 400
url_invalidURL ปลายทางไม่ถูกต้อง - 400
event_type_unknownชื่อ event ไม่รู้จัก - 409
endpoint_limit_reachedwebhook endpoint ครบจำนวนแล้ว - 409
idempotency_conflictIdempotency-Key ซ้ำแต่ body ต่าง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ปลายทางต้องตอบ 2xx ภายใน 10 วินาที — ตอบ 200 ก่อนแล้วประมวลผลต่อในคิวของร้าน
- แนะนำแยก endpoint ตามระบบ (หลังร้าน / บัญชี) แทนการรวม * ไว้ที่เดียว
curl -X POST "https://sandbox.api.paynara.example/v1/webhook-endpoints" \
-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 '{
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"api_version": "2026-08-01",
"metadata": {
"owner": "dev@baanmaeplub.example"
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/webhook-endpoints', {
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({
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"api_version": "2026-08-01",
"metadata": {
"owner": "dev@baanmaeplub.example"
}
}),
});
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/webhook-endpoints",
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={
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"api_version": "2026-08-01",
"metadata": {
"owner": "dev@baanmaeplub.example"
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_9Lp3Ds",
"object": "webhook_endpoint",
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"status": "enabled",
"disabled_reason": null,
"api_version": "2026-08-01",
"secret_last4": "9e2b",
"metadata": {
"owner": "dev@baanmaeplub.example"
},
"created": "2026-03-21T10:05:00+07:00",
"updated": "2026-03-21T10:05:00+07:00",
"livemode": false,
"secret": "pn_whs_test_4f8a1c9e2b"
}{
"error": {
"code": "url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#url_invalid"
}
}{
"error": {
"code": "event_type_unknown",
"message": "ชื่อ event ไม่รู้จัก",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_type_unknown"
}
}{
"error": {
"code": "endpoint_limit_reached",
"message": "webhook endpoint ครบจำนวนแล้ว",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#endpoint_limit_reached"
}
}{
"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"
}
}รายการ webhook endpoint
endpoint ทั้งหมดของร้านพร้อมสถานะและสถิติการส่ง
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
statusstringไม่บังคับสถานะ
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 2002 endpoint (1 ถูกปิดอัตโนมัติ)
- 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- secret ไม่ถูกคืนในรายการ — มีเฉพาะ secret_last4
- stats แสดงอัตราสำเร็จ 7 วัน ใช้เฝ้าระวัง endpoint ที่กำลังจะถูกปิดอัตโนมัติ
curl -X GET "https://sandbox.api.paynara.example/v1/webhook-endpoints?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/webhook-endpoints?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/webhook-endpoints?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/webhook-endpoints",
"has_more": false,
"data": [
{
"id": "we_9Lp3Ds",
"object": "webhook_endpoint",
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"status": "enabled",
"disabled_reason": null,
"api_version": "2026-08-01",
"secret_last4": "9e2b",
"metadata": {},
"stats": {
"delivered_24h": 4,
"failed_24h": 0,
"success_rate_7d": 0.993,
"avg_ms_7d": 212
},
"created": "2026-03-21T10:05:00+07:00",
"updated": "2026-10-01T09:10:00+07:00",
"livemode": false
},
{
"id": "we_2Vx8Gr",
"object": "webhook_endpoint",
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"description": "โปรแกรมบัญชี (บันทึกรอบโอนเงิน)",
"enabled_events": [
"settlement.created",
"settlement.paid",
"balance.available"
],
"status": "disabled",
"disabled_reason": "ส่งไม่สำเร็จต่อเนื่อง 3 วัน (ระบบปิดอัตโนมัติ)",
"api_version": "2026-08-01",
"secret_last4": "41c7",
"metadata": {},
"stats": {
"delivered_24h": 0,
"failed_24h": 7,
"success_rate_7d": 0,
"avg_ms_7d": null
},
"created": "2026-05-02T14:30:00+07:00",
"updated": "2026-10-11T22:36:05+07:00",
"livemode": false
}
],
"next_cursor": null
}{
"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"
}
}ดู webhook endpoint
GET/v1/webhook-endpoints/{endpoint_id}
รายละเอียดและสถิติ 7 วัน (ไม่มี secret)
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200endpoint โปรแกรมบัญชี (ถูกปิด)
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- endpoint ที่ status = disabled มี disabled_reason (เช่น ล้มเหลวต่อเนื่อง 3 วัน)
- secret ไม่ถูกคืน ถ้าหายให้หมุนใหม่ด้วย rotate-secret
curl -X GET "https://sandbox.api.paynara.example/v1/webhook-endpoints/we_2Vx8Gr" \
-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/webhook-endpoints/we_2Vx8Gr', {
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/webhook-endpoints/we_2Vx8Gr",
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": "we_2Vx8Gr",
"object": "webhook_endpoint",
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"description": "โปรแกรมบัญชี (บันทึกรอบโอนเงิน)",
"enabled_events": [
"settlement.created",
"settlement.paid",
"balance.available"
],
"status": "disabled",
"disabled_reason": "ส่งไม่สำเร็จต่อเนื่อง 3 วัน (ระบบปิดอัตโนมัติ)",
"api_version": "2026-08-01",
"secret_last4": "41c7",
"metadata": {},
"stats": {
"delivered_24h": 0,
"failed_24h": 7,
"success_rate_7d": 0,
"avg_ms_7d": null
},
"created": "2026-05-02T14:30:00+07:00",
"updated": "2026-10-11T22:36:05+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"
}
}แก้ไข / เปิด-ปิด endpoint
PATCH/v1/webhook-endpoints/{endpoint_id}
เปลี่ยน URL event ที่รับ เวอร์ชัน payload หรือเปิดใช้อีกครั้งหลังถูกปิด (event ที่ตกค้างระหว่างปิดไม่ถูกส่งอัตโนมัติ — ใช้ resend)
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
urlstring · uriไม่บังคับURL ใหม่
enabled_eventsarray<string>ไม่บังคับแทนทั้งชุด
statusstringไม่บังคับเปิด/ปิด
api_versionstringไม่บังคับเวอร์ชัน payload
descriptionstringไม่บังคับคำอธิบาย
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
ผลลัพธ์
- 200เปิดใช้อีกครั้ง
- 400
url_invalidURL ปลายทางไม่ถูกต้อง - 400
event_type_unknownชื่อ event ไม่รู้จัก - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- เปิดใช้ endpoint ที่ถูกปิดอัตโนมัติด้วย status = enabled — event ที่ค้างไม่ถูกส่งเอง ให้ส่งซ้ำผ่าน /v1/events/{id}/resend
- เปลี่ยน url แล้วควรกด test ทันที
curl -X PATCH "https://sandbox.api.paynara.example/v1/webhook-endpoints/we_2Vx8Gr" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Content-Type: application/json" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub" \
-d '{
"status": "enabled"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/webhook-endpoints/we_2Vx8Gr', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
body: JSON.stringify({
"status": "enabled"
}),
});
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.patch(
"https://sandbox.api.paynara.example/v1/webhook-endpoints/we_2Vx8Gr",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
json={
"status": "enabled"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_2Vx8Gr",
"object": "webhook_endpoint",
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"description": "โปรแกรมบัญชี (บันทึกรอบโอนเงิน)",
"enabled_events": [
"settlement.created",
"settlement.paid",
"balance.available"
],
"status": "enabled",
"disabled_reason": null,
"api_version": "2026-08-01",
"secret_last4": "41c7",
"metadata": {},
"stats": {
"delivered_24h": 0,
"failed_24h": 7,
"success_rate_7d": 0,
"avg_ms_7d": null
},
"created": "2026-05-02T14:30:00+07:00",
"updated": "2026-10-12T15:20:00+07:00",
"livemode": false
}{
"error": {
"code": "url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#url_invalid"
}
}{
"error": {
"code": "event_type_unknown",
"message": "ชื่อ event ไม่รู้จัก",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_type_unknown"
}
}{
"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"
}
}ลบ webhook endpoint
DELETE/v1/webhook-endpoints/{endpoint_id}
ลบถาวร — event ที่กำลังส่งซ้ำไปยัง endpoint นี้หยุดทันที (ประวัติการส่งยังดูได้ 30 วัน)
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint
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เรียกเกินโควตา
- ลบแล้วกู้คืนไม่ได้ — ถ้าต้องการหยุดชั่วคราวใช้ PATCH status = disabled แทน
- คืน 200 พร้อม deleted = true
curl -X DELETE "https://sandbox.api.paynara.example/v1/webhook-endpoints/we_1Tz0Ab" \
-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/webhook-endpoints/we_1Tz0Ab', {
method: 'DELETE',
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.delete(
"https://sandbox.api.paynara.example/v1/webhook-endpoints/we_1Tz0Ab",
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": "we_1Tz0Ab",
"object": "webhook_endpoint",
"deleted": true
}{
"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"
}
}หมุน secret
POST/v1/webhook-endpoints/{endpoint_id}/rotate-secret
ออก secret ใหม่ (เช่น สงสัยว่ารั่ว) — ระหว่างช่วงเปลี่ยน ทุก event ลงลายเซ็นทั้ง secret ใหม่และเก่า (v1 2 ค่า) จนถึง previous_secret_expires_at
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
expire_previous_inintegerไม่บังคับให้ secret เก่าใช้ต่อได้อีก (วินาที · 0 = ยกเลิกทันที)
ผลลัพธ์
- 200secret ใหม่ (แสดงครั้งเดียว)
- 404
resource_not_foundไม่พบรายการ - 409
endpoint_disabledendpoint ถูกปิดอยู่ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ระหว่างช่วงเปลี่ยน หัว Paynara-Signature มี v1 สองค่า: t=…,v1=<ใหม่>,v1=<เก่า> — โค้ดตรวจควรยอมรับถ้าตรงค่าใดค่าหนึ่ง
curl -X POST "https://sandbox.api.paynara.example/v1/webhook-endpoints/we_9Lp3Ds/rotate-secret" \
-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 '{
"expire_previous_in": 86400
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/webhook-endpoints/we_9Lp3Ds/rotate-secret', {
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({
"expire_previous_in": 86400
}),
});
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/webhook-endpoints/we_9Lp3Ds/rotate-secret",
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={
"expire_previous_in": 86400
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "we_9Lp3Ds",
"object": "webhook_endpoint",
"url": "https://baanmaeplub.example/api/paynara/webhook",
"description": "ระบบหลังร้าน (อัปเดตสถานะคำสั่งซื้อ)",
"enabled_events": [
"payment.succeeded",
"payment.failed",
"payment.canceled",
"payment.requires_action",
"refund.created",
"refund.succeeded",
"refund.failed",
"dispute.created"
],
"status": "enabled",
"disabled_reason": null,
"api_version": "2026-08-01",
"secret_last4": "5f5f",
"metadata": {},
"created": "2026-03-21T10:05:00+07:00",
"updated": "2026-10-12T11:00:00+07:00",
"livemode": false,
"secret": "pn_whs_test_7c3e9d1a5f",
"previous_secret_expires_at": "2026-10-13T11:00:00+07:00"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "endpoint_disabled",
"message": "endpoint ถูกปิดอยู่",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#endpoint_disabled"
}
}{
"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"
}
}ส่ง event ทดสอบ
POST/v1/webhook-endpoints/{endpoint_id}/test
ส่ง event ชนิด webhook_endpoint.test (หรือชนิดที่เลือก พร้อมข้อมูลตัวอย่าง) ไปที่ endpoint แล้วรอผลทันที — ใช้ตรวจ firewall, TLS และโค้ดตรวจลายเซ็น
Path parameterspath
endpoint_idstringจำเป็นรหัส endpoint
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
event_typestringไม่บังคับชนิด event ที่จำลอง (ข้อมูลตัวอย่าง livemode = false)
ผลลัพธ์
- 200ส่งสำเร็จ — ผลของการส่งครั้งนี้
- 422
url_unreachableส่ง event ทดสอบไม่สำเร็จ - 409
endpoint_disabledendpoint ถูกปิดอยู่ - 400
event_type_unknownชื่อ event ไม่รู้จัก - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ผลทดสอบไม่นับในสถิติและไม่ทำให้ endpoint ถูกปิด
curl -X POST "https://sandbox.api.paynara.example/v1/webhook-endpoints/we_9Lp3Ds/test" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Content-Type: application/json" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub" \
-d '{
"event_type": "payment.succeeded"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/webhook-endpoints/we_9Lp3Ds/test', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
body: JSON.stringify({
"event_type": "payment.succeeded"
}),
});
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/webhook-endpoints/we_9Lp3Ds/test",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
json={
"event_type": "payment.succeeded"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "webhook_test",
"endpoint": "we_9Lp3Ds",
"event": "evt_test_4Rb7",
"event_type": "payment.succeeded",
"status_code": 200,
"duration_ms": 143,
"error": null,
"signature_header": "t=1791777600,v1=8c2f…",
"created": "2026-10-12T11:00:00+07:00"
}{
"error": {
"code": "url_unreachable",
"message": "ส่ง event ทดสอบไม่สำเร็จ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#url_unreachable"
}
}{
"error": {
"code": "endpoint_disabled",
"message": "endpoint ถูกปิดอยู่",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#endpoint_disabled"
}
}{
"error": {
"code": "event_type_unknown",
"message": "ชื่อ event ไม่รู้จัก",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_type_unknown"
}
}{
"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"
}
}รายการ event
event ย้อนหลัง 30 วัน — กรองตามชนิด endpoint สถานะการส่ง และ object ต้นทาง · ใช้ตามเก็บ event ที่พลาดหลังระบบร้านล่ม
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
typestringไม่บังคับชนิด (รองรับ payment.*)
endpointstringไม่บังคับเฉพาะ endpoint
delivery_statusstringไม่บังคับสถานะการส่ง
object_idstringไม่บังคับid ของ object ต้นทาง (pay_ / rf_ / stl_)
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)
ผลลัพธ์
- 200event ที่ส่งไม่ถึงโปรแกรมบัญชี
- 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 400
date_range_invalidช่วงวันที่ไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- เก็บ event 30 วัน (ดู expires_at) — เก่ากว่านั้นใช้ข้อมูลจาก GET ของ object โดยตรง
- กรอง delivery_status = failed เพื่อหา event ที่ระบบของร้านยังไม่ได้รับ
curl -X GET "https://sandbox.api.paynara.example/v1/events?limit=20&type=settlement.*&endpoint=we_2Vx8Gr&delivery_status=failed" \
-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/events?limit=20&type=settlement.*&endpoint=we_2Vx8Gr&delivery_status=failed', {
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/events?limit=20&type=settlement.*&endpoint=we_2Vx8Gr&delivery_status=failed",
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/events",
"has_more": false,
"data": [
{
"id": "evt_7Kt1Qr",
"object": "event",
"type": "settlement.created",
"data_object_id": "stl_20261012",
"created": "2026-10-12T01:05:01+07:00",
"delivery": {
"endpoint": "we_2Vx8Gr",
"status": "failed",
"attempts": 1,
"last_attempt_at": "2026-10-12T01:05:01+07:00",
"next_attempt_at": null
}
},
{
"id": "evt_6Pa3Hz",
"object": "event",
"type": "settlement.paid",
"data_object_id": "stl_20261011",
"created": "2026-10-11T14:00:04+07:00",
"delivery": {
"endpoint": "we_2Vx8Gr",
"status": "retrying",
"attempts": 6,
"last_attempt_at": "2026-10-11T22:36:04+07:00",
"next_attempt_at": "2026-10-12T14:00:04+07:00"
}
}
],
"next_cursor": null
}{
"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"
}
}ดู event
event เต็มพร้อม data.object ตามที่ส่ง — ใช้ดีบักว่าระบบร้านได้รับอะไร
Path parameterspath
event_idstringจำเป็นรหัส event
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200payment.succeeded ของคุณอรอุมา
- 404
resource_not_foundไม่พบรายการ - 410
event_expiredevent เก่าเกิน 30 วัน - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- data.object เป็นสำเนา ณ เวลาเกิดเหตุ อาจเก่ากว่าสถานะปัจจุบัน — ตัดสินใจสำคัญให้ GET object_id อีกครั้ง
- event ที่เกิน expires_at ได้ 404 event_expired
curl -X GET "https://sandbox.api.paynara.example/v1/events/evt_7Gq2Mn" \
-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/events/evt_7Gq2Mn', {
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/events/evt_7Gq2Mn",
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": "evt_7Gq2Mn",
"object": "event",
"type": "payment.succeeded",
"merchant": "mch_baanmaeplub",
"api_version": "2026-08-01",
"created": "2026-10-12T10:14:33+07:00",
"expires_at": "2026-11-11T10:14:33+07:00",
"livemode": false,
"object_type": "payment",
"object_id": "pay_3NqL8k",
"source": "api",
"pending_webhooks": 0,
"data": {
"object": {
"id": "pay_3NqL8k",
"object": "payment",
"status": "succeeded",
"amount": 104000,
"amount_received": 104000,
"order_ref": "ORD-2610-0153"
}
},
"request": {
"id": "req_3Gq8Ls",
"idempotency_key": "7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f"
},
"delivery": {
"endpoint": "we_9Lp3Ds",
"status": "delivered",
"attempts": 1,
"last_attempt_at": "2026-10-12T10:14:33+07:00",
"next_attempt_at": null
}
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "event_expired",
"message": "event เก่าเกิน 30 วัน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_expired"
}
}{
"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"
}
}ประวัติการส่งของ event
GET/v1/events/{event_id}/attempts
ทุกครั้งที่พยายามส่ง: เวลา status code ระยะเวลา error และเวลาครั้งถัดไป
Path parameterspath
event_idstringจำเป็นรหัส event
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 2006 ครั้ง (ตัวอย่าง 2 ครั้งแรก)
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- แสดงทุกความพยายาม (สูงสุด 7 ครั้ง: ทันที → 1 นาที → 5 นาที → 30 นาที → 2 ชั่วโมง → 6 ชั่วโมง → 24 ชั่วโมง (ครั้งสุดท้าย)) พร้อม status_code และ duration_ms
- response.body_excerpt เก็บ 500 ตัวอักษรแรก ใช้ดูข้อผิดพลาดฝั่งเซิร์ฟเวอร์ร้าน
curl -X GET "https://sandbox.api.paynara.example/v1/events/evt_6Pa3Hz/attempts?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/events/evt_6Pa3Hz/attempts?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/events/evt_6Pa3Hz/attempts?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/events/evt_6Pa3Hz/attempts",
"has_more": true,
"data": [
{
"id": "wha_6Pa3Hz1",
"object": "webhook_attempt",
"event": "evt_6Pa3Hz",
"endpoint": "we_2Vx8Gr",
"attempt": 1,
"status_code": null,
"duration_ms": 10000,
"error": "หมดเวลา 10 วินาที",
"request": {
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"headers": {
"Content-Type": "application/json",
"User-Agent": "PAYNARA-Webhooks/2026-08-01",
"Paynara-Signature": "t=1791702004,v1=5b1e0f…"
}
},
"response": {
"body_excerpt": null
},
"next_attempt_at": "2026-10-11T14:01:04+07:00",
"created": "2026-10-11T14:00:04+07:00"
},
{
"id": "wha_6Pa3Hz3",
"object": "webhook_attempt",
"event": "evt_6Pa3Hz",
"endpoint": "we_2Vx8Gr",
"attempt": 3,
"status_code": 502,
"duration_ms": 61,
"error": "Bad Gateway",
"request": {
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"headers": {
"Content-Type": "application/json",
"User-Agent": "PAYNARA-Webhooks/2026-08-01",
"Paynara-Signature": "t=1791702364,v1=5b1e0f…"
}
},
"response": {
"body_excerpt": "<html><title>502</title>…"
},
"next_attempt_at": "2026-10-11T14:36:04+07:00",
"created": "2026-10-11T14:06:04+07:00"
}
],
"next_cursor": "wha_6Pa3Hz3"
}{
"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"
}
}ส่ง event ซ้ำ
POST/v1/events/{event_id}/resend
ส่ง event เดิม (id เดิม ข้อมูลเดิม ลายเซ็นใหม่) ไปที่ endpoint ทันที — สำหรับ event ภายใน 30 วัน · ระบบร้านต้องกันประมวลผลซ้ำด้วย event id
Path parameterspath
event_idstringจำเป็นรหัส event
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
endpointstringไม่บังคับส่งไป endpoint ไหน (ไม่ส่ง = ทุก endpoint ที่สมัคร event นี้)
ผลลัพธ์
- 202เข้าคิวส่งแล้ว — ผลดูได้ที่ attempts
- 409
endpoint_disabledendpoint ถูกปิดอยู่ - 410
event_expiredevent เก่าเกิน 30 วัน - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- endpoint ที่ disabled ต้องเปิดก่อน (PATCH status = enabled) ไม่งั้นได้ 409 endpoint_disabled
- ส่งซ้ำด้วยมือไม่นับในตารางส่งซ้ำอัตโนมัติ
curl -X POST "https://sandbox.api.paynara.example/v1/events/evt_6Pa3Hz/resend" \
-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 '{
"endpoint": "we_2Vx8Gr"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/events/evt_6Pa3Hz/resend', {
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({
"endpoint": "we_2Vx8Gr"
}),
});
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/events/evt_6Pa3Hz/resend",
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={
"endpoint": "we_2Vx8Gr"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "webhook_resend",
"event": "evt_6Pa3Hz",
"endpoint": "we_2Vx8Gr",
"attempt": 7,
"status": "queued",
"created": "2026-10-12T15:21:30+07:00"
}{
"error": {
"code": "endpoint_disabled",
"message": "endpoint ถูกปิดอยู่",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#endpoint_disabled"
}
}{
"error": {
"code": "event_expired",
"message": "event เก่าเกิน 30 วัน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_expired"
}
}{
"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"
}
}ดูการแจ้งเตือนถึงร้าน (อีเมล / LINE)
ช่องทางและกฎการแจ้งเตือนถึงเจ้าของร้าน (คนละส่วนกับ webhook ที่ส่งถึงระบบ) — เช่น แจ้ง LINE เมื่อมียอดขายตั้งแต่ ฿3,000 หรือมีข้อพิพาท
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200การตั้งค่าปัจจุบัน
- 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- อีเมลแสดงแบบปิดบัง (PDPA) · LINE แสดงเฉพาะชื่อ OA ที่ผูก
- ใช้คู่กับ webhook — แจ้งคนดูแลร้านเมื่อ webhook ล้มเหลวหรือรอบโอนไม่สำเร็จ
curl -X GET "https://sandbox.api.paynara.example/v1/notification-settings" \
-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/notification-settings', {
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/notification-settings",
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": "notification_settings",
"merchant": "mch_baanmaeplub",
"channels": [
{
"type": "email",
"target": "sho***@baanmaeplub.example",
"verified": true
},
{
"type": "line",
"target": "LINE OA \"PAYNARA แจ้งเตือนร้านค้า\" (ผูกแล้ว 1 บัญชี)",
"verified": true
}
],
"rules": [
{
"event": "payment.succeeded",
"channels": [
"line"
],
"condition": {
"amount_gte": 300000
},
"note": "แจ้งทุกยอดตั้งแต่ ฿3,000"
},
{
"event": "refund.succeeded",
"channels": [
"line"
],
"condition": null
},
{
"event": "settlement.paid",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "dispute.created",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "risk.review_required",
"channels": [
"line"
],
"condition": null
},
{
"event": "webhook_endpoint.disabled",
"channels": [
"email"
],
"condition": null
}
],
"quiet_hours": {
"start": "22:00",
"end": "07:00",
"except": [
"dispute.created",
"webhook_endpoint.disabled"
]
},
"daily_summary": {
"enabled": true,
"time": "08:00",
"channels": [
"email"
]
},
"updated": "2026-09-02T10:15:00+07:00"
}{
"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"
}
}ตั้งการแจ้งเตือนถึงร้าน
แทนการตั้งค่าทั้งชุด: ช่องทาง กฎต่อ event (เงื่อนไขยอด) ช่วงเวลางดแจ้ง และสรุปรายวัน · ช่องทางใหม่ต้องยืนยัน (อีเมลยืนยัน / สแกนผูก LINE OA)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
channelsarray<object>จำเป็นช่องทาง
ฟิลด์ย่อยของ
channels(2)typestringไม่บังคับชนิด
targetstringไม่บังคับอีเมล หรือ link token ของ LINE OA
rulesarray<object>จำเป็นกฎต่อ event
ฟิลด์ย่อยของ
rules(3)eventstringไม่บังคับชนิด event
channelsarray<string>ไม่บังคับส่งช่องทางไหน
conditionobjectไม่บังคับเงื่อนไข เช่น amount_gte (สตางค์)
quiet_hoursobjectไม่บังคับช่วงงดแจ้ง (ยกเว้น event สำคัญ)
ฟิลด์ย่อยของ
quiet_hours(3)startstringไม่บังคับHH:mm
endstringไม่บังคับHH:mm
exceptarray<string>ไม่บังคับevent ที่แจ้งเสมอ
daily_summaryobjectไม่บังคับสรุปยอดรายวัน
ฟิลด์ย่อยของ
daily_summary(3)enabledbooleanไม่บังคับเปิด
timestringไม่บังคับเวลา
channelsarray<string>ไม่บังคับช่องทาง
ผลลัพธ์
- 200บันทึกแล้ว
- 400
parameter_invalidค่าฟิลด์ไม่ถูกต้อง - 400
event_type_unknownชื่อ event ไม่รู้จัก - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ข้อความ LINE/อีเมลไม่มีข้อมูลบัตรหรือข้อมูลลูกค้า — มีแค่ยอด เลขคำสั่งซื้อ และลิงก์เข้าแดชบอร์ด (PDPA)
curl -X PUT "https://sandbox.api.paynara.example/v1/notification-settings" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Content-Type: application/json" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub" \
-d '{
"channels": [
{
"type": "email",
"target": "shop@baanmaeplub.example"
},
{
"type": "line",
"target": "lnk_3Hd8Vq"
}
],
"rules": [
{
"event": "payment.succeeded",
"channels": [
"line"
],
"condition": {
"amount_gte": 300000
}
},
{
"event": "refund.succeeded",
"channels": [
"line"
],
"condition": null
},
{
"event": "settlement.paid",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "dispute.created",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "risk.review_required",
"channels": [
"line"
],
"condition": null
},
{
"event": "webhook_endpoint.disabled",
"channels": [
"email"
],
"condition": null
}
],
"quiet_hours": {
"start": "22:00",
"end": "07:00",
"except": [
"dispute.created",
"webhook_endpoint.disabled"
]
},
"daily_summary": {
"enabled": true,
"time": "08:00",
"channels": [
"email"
]
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/notification-settings', {
method: 'PUT',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
body: JSON.stringify({
"channels": [
{
"type": "email",
"target": "shop@baanmaeplub.example"
},
{
"type": "line",
"target": "lnk_3Hd8Vq"
}
],
"rules": [
{
"event": "payment.succeeded",
"channels": [
"line"
],
"condition": {
"amount_gte": 300000
}
},
{
"event": "refund.succeeded",
"channels": [
"line"
],
"condition": null
},
{
"event": "settlement.paid",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "dispute.created",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "risk.review_required",
"channels": [
"line"
],
"condition": null
},
{
"event": "webhook_endpoint.disabled",
"channels": [
"email"
],
"condition": null
}
],
"quiet_hours": {
"start": "22:00",
"end": "07:00",
"except": [
"dispute.created",
"webhook_endpoint.disabled"
]
},
"daily_summary": {
"enabled": true,
"time": "08:00",
"channels": [
"email"
]
}
}),
});
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.put(
"https://sandbox.api.paynara.example/v1/notification-settings",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
json={
"channels": [
{
"type": "email",
"target": "shop@baanmaeplub.example"
},
{
"type": "line",
"target": "lnk_3Hd8Vq"
}
],
"rules": [
{
"event": "payment.succeeded",
"channels": [
"line"
],
"condition": {
"amount_gte": 300000
}
},
{
"event": "refund.succeeded",
"channels": [
"line"
],
"condition": None
},
{
"event": "settlement.paid",
"channels": [
"email",
"line"
],
"condition": None
},
{
"event": "dispute.created",
"channels": [
"email",
"line"
],
"condition": None
},
{
"event": "risk.review_required",
"channels": [
"line"
],
"condition": None
},
{
"event": "webhook_endpoint.disabled",
"channels": [
"email"
],
"condition": None
}
],
"quiet_hours": {
"start": "22:00",
"end": "07:00",
"except": [
"dispute.created",
"webhook_endpoint.disabled"
]
},
"daily_summary": {
"enabled": True,
"time": "08:00",
"channels": [
"email"
]
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "notification_settings",
"merchant": "mch_baanmaeplub",
"channels": [
{
"type": "email",
"target": "sho***@baanmaeplub.example",
"verified": true
},
{
"type": "line",
"target": "LINE OA \"PAYNARA แจ้งเตือนร้านค้า\" (ผูกแล้ว 1 บัญชี)",
"verified": true
}
],
"rules": [
{
"event": "payment.succeeded",
"channels": [
"line"
],
"condition": {
"amount_gte": 300000
},
"note": "แจ้งทุกยอดตั้งแต่ ฿3,000"
},
{
"event": "refund.succeeded",
"channels": [
"line"
],
"condition": null
},
{
"event": "settlement.paid",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "dispute.created",
"channels": [
"email",
"line"
],
"condition": null
},
{
"event": "risk.review_required",
"channels": [
"line"
],
"condition": null
},
{
"event": "webhook_endpoint.disabled",
"channels": [
"email"
],
"condition": null
}
],
"quiet_hours": {
"start": "22:00",
"end": "07:00",
"except": [
"dispute.created",
"webhook_endpoint.disabled"
]
},
"daily_summary": {
"enabled": true,
"time": "08:00",
"channels": [
"email"
]
},
"updated": "2026-10-12T11:00:00+07:00"
}{
"error": {
"code": "parameter_invalid",
"message": "ค่าฟิลด์ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_invalid"
}
}{
"error": {
"code": "event_type_unknown",
"message": "ชื่อ event ไม่รู้จัก",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#event_type_unknown"
}
}{
"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 กันประมวลผลซ้ำ
webhook_endpoint.testevent ทดสอบ
ส่งเมื่อ: POST /v1/webhook-endpoints/{id}/test โดยไม่ระบุ event_type
{
"id": "evt_01JB7Q00",
"type": "webhook_endpoint.test",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"endpoint": "we_9Lp3Ds",
"message": "ทดสอบจาก PAYNARA — ตอบ 2xx เพื่อยืนยันว่ารับได้"
}
}webhook_endpoint.disabledendpoint ถูกปิดอัตโนมัติ
ส่งเมื่อ: ส่งไม่สำเร็จต่อเนื่อง 3 วัน (ส่งไปยัง endpoint อื่นที่สมัคร + อีเมลเจ้าของร้าน)
{
"id": "evt_01JB7Q01",
"type": "webhook_endpoint.disabled",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "we_2Vx8Gr",
"object": "webhook_endpoint",
"url": "https://erp.baanmaeplub.example/hooks/paynara",
"description": "โปรแกรมบัญชี (บันทึกรอบโอนเงิน)",
"enabled_events": [
"settlement.created",
"settlement.paid",
"balance.available"
],
"status": "disabled",
"disabled_reason": "ส่งไม่สำเร็จต่อเนื่อง 3 วัน (ระบบปิดอัตโนมัติ)",
"api_version": "2026-08-01",
"secret_last4": "41c7",
"metadata": {},
"stats": {
"delivered_24h": 0,
"failed_24h": 7,
"success_rate_7d": 0,
"avg_ms_7d": null
},
"created": "2026-05-02T14:30:00+07:00",
"updated": "2026-10-11T22:36:05+07:00",
"livemode": false
}
}webhook_endpoint.secret_rotatedหมุน secret แล้ว
ส่งเมื่อ: POST …/rotate-secret — แจ้ง endpoint อื่นเพื่อบันทึกการเปลี่ยน (ไม่มีค่า secret ใน payload)
{
"id": "evt_01JB7Q02",
"type": "webhook_endpoint.secret_rotated",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "we_9Lp3Ds",
"object": "webhook_endpoint",
"secret_last4": "5f5f",
"previous_secret_expires_at": "2026-10-13T11:00:00+07:00"
}
}webhook_endpoint.updatedแก้ไข endpoint
ส่งเมื่อ: PATCH เปลี่ยน URL / event / สถานะ
{
"id": "evt_01JB7Q03",
"type": "webhook_endpoint.updated",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "we_2Vx8Gr",
"object": "webhook_endpoint",
"status": "enabled",
"previous_attributes": {
"status": "disabled"
}
}
}notification_settings.updatedเปลี่ยนการแจ้งเตือนถึงร้าน
ส่งเมื่อ: PUT /v1/notification-settings (บันทึกผู้แก้ไว้ใน audit log)
{
"id": "evt_01JB7Q04",
"type": "notification_settings.updated",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"object": "notification_settings",
"merchant": "mch_baanmaeplub",
"changed": [
"rules[0].condition.amount_gte"
]
}
}ส่งซ้ำเมื่อปลายทางไม่ตอบ
- 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": "url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"param": "items[0].quantity",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#url_invalid"
}
}| HTTP | code | ความหมาย | วิธีแก้ |
|---|---|---|---|
| 400 | url_invalid | URL ปลายทางไม่ถูกต้อง ต้องเป็น https:// ที่เข้าถึงได้จากอินเทอร์เน็ต ไม่ใช่ localhost/IP ภายใน | ใช้โดเมนที่มี TLS ใช้ได้ (ทดสอบบนเครื่องใช้ CLI ส่งต่อ event) |
| 422 | url_unreachable | ส่ง event ทดสอบไม่สำเร็จ ปลายทางตอบไม่ใช่ 2xx หรือเกิน 10 วินาที ระหว่างทดสอบ | ตรวจ firewall / ใบรับรอง TLS / ให้ตอบ 200 ก่อนประมวลผลหนัก |
| 400 | event_type_unknown | ชื่อ event ไม่รู้จัก enabled_events มีชื่อที่ไม่อยู่ในรายการ event | ใช้ชื่อตามหัวข้อ Webhooks ของแต่ละหน้า หรือ "*" สำหรับทั้งหมด |
| 409 | endpoint_limit_reached | webhook endpoint ครบจำนวนแล้ว ร้านละไม่เกิน 16 endpoint ต่อสภาพแวดล้อม | ลบ endpoint ที่ไม่ใช้ หรือรวม event ไว้ที่ endpoint เดียว |
| 409 | endpoint_disabled | endpoint ถูกปิดอยู่ ปิดเองหรือระบบปิดอัตโนมัติหลังส่งไม่สำเร็จต่อเนื่อง 3 วัน | แก้ปลายทาง แล้ว PATCH status = enabled ก่อนส่งซ้ำ |
| 410 | event_expired | event เก่าเกิน 30 วัน ส่งซ้ำได้เฉพาะ event ภายใน 30 วัน | ดึงสถานะล่าสุดผ่าน GET ของ object นั้นแทน |
| 409 | idempotency_conflict | Idempotency-Key ซ้ำแต่ body ต่าง ใช้ Idempotency-Key เดิมภายใน 24 ชม. กับคำขอที่เนื้อหาไม่เหมือนเดิม | สร้าง Idempotency-Key ใหม่ (UUID v4) ต่อ 1 การกระทำ |
| 400 | parameter_invalid | ค่าฟิลด์ไม่ถูกต้อง ชนิดข้อมูล รูปแบบ หรือค่าที่ไม่อยู่ใน enum เช่น amount เป็นทศนิยม หรือวันที่ไม่ใช่ ISO 8601 | เงินส่งเป็นสตางค์ (จำนวนเต็ม) · เวลาใช้ ISO 8601 พร้อม +07:00 |
| 400 | cursor_invalid | cursor ของการแบ่งหน้าไม่ถูกต้อง starting_after / ending_before ไม่ใช่ id ของรายการชนิดเดียวกัน หรือส่งทั้งสองค่าพร้อมกัน | ใช้ id ของรายการสุดท้ายในหน้าก่อนหน้า และส่งเพียงค่าเดียว |
| 400 | date_range_invalid | ช่วงวันที่ไม่ถูกต้อง created[gte] มากกว่า created[lte] หรือช่วงยาวเกิน 92 วัน | แบ่งช่วงไม่เกิน 92 วัน หรือใช้ POST /v1/reports สำหรับช่วงยาว |
| 404 | resource_not_found | ไม่พบรายการ id ไม่มีอยู่ หรือเป็นของร้านค้าอื่น | ตรวจ id และ X-Merchant-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 ถ้ายังเกิดซ้ำ |
ไม่พบรหัสที่ค้นหา
Rate limit — โควตาการเรียก
| ขอบเขต | โควตา | Burst | หมายเหตุ |
|---|---|---|---|
| จัดการ endpoint (POST / PATCH / DELETE) | 10 ครั้ง/นาที | — | สูงสุด 16 endpoint/สภาพแวดล้อม |
| POST …/test | 10 ครั้ง/นาที/endpoint | — | |
| POST /v1/events/{id}/resend | 30 ครั้ง/นาที | 60 | ส่งซ้ำจำนวนมากให้เว้น 2 วินาที/ครั้ง |
| GET /v1/events · attempts | 20–50 ครั้ง/วินาที | — | ย้อนหลัง 30 วัน |
| การส่ง webhook ขาออก (ต่อ endpoint) | 50 คำขอพร้อมกัน | — | ปลายทางช้าจะทำให้ event ถัดไปรอคิว |
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-01duration_ms ของ attempt ที่หมดเวลาแสดง 0 — ตอนนี้แสดง 10000
- เพิ่ม
2026-08-01GET/PUT /v1/notification-settings — แจ้งเตือนถึงร้านทางอีเมลและ LINE พร้อมเงื่อนไขยอดและช่วงงดแจ้ง
- เปลี่ยน
2026-08-01ปิด endpoint อัตโนมัติหลังล้มเหลวต่อเนื่อง 3 วัน (เดิม 5 วัน) และแจ้ง webhook_endpoint.disabled
- ความปลอดภัย
2025-11-15หัว Paynara-Signature บังคับมี t และปฏิเสธลายเซ็นแบบเดิม (ไม่มีเวลา) — กัน replay
- เพิ่ม
2025-11-15POST …/test รองรับ event_type จำลองข้อมูลจริงของแต่ละชนิด
- เพิ่ม
2025-11-15POST …/rotate-secret (ช่วงเปลี่ยนลงลายเซ็น 2 ค่า) · GET /v1/events/{id}/attempts · POST /v1/events/{id}/resend
- เลิกใช้
2025-11-15หัว X-Paynara-Signature (ไม่มี t) เลิกใช้ ใช้ Paynara-Signature — รองรับถึง 31 ธ.ค. 2569
- แก้ไข
2024-06-01event ที่ส่งซ้ำด้วยมือได้ id ใหม่ ทำให้ระบบร้านประมวลผลซ้ำ — ตอนนี้ใช้ id เดิม
- เพิ่ม
2024-06-01enabled_events รองรับรูปแบบ "payment.*"
เครื่องมือ: ตัวดูประวัติการส่ง webhook
7 event ล่าสุดของร้าน (ข้อมูลเดียวกับหน้าอื่น — เช่น payment.succeeded ของ ORD-2610-0153 และ settlement.* ที่ส่งไม่ถึงโปรแกรมบัญชี) · คลิก event เพื่อดูทุกครั้งที่ส่ง คลิกแถวเพื่อดู attempt object · ลองส่งซ้ำไปที่ endpoint ที่ถูกปิด แล้วเปิด endpoint แล้วส่งซ้ำอีกครั้ง
ไม่มี event ตามตัวกรองนี้
{}