สารบัญหน้านี้ (25)
- ภาพรวมโมดูล
- Workflow: ลูกค้าจ่ายด้วยบัตร VISA + 3-D Secure
- Workflow: PromptPay QR หมดอายุ → ออกใหม่ → ลูกค้าสแกนจ่าย
- Workflow: Authorize ก่อน แล้ว capture เมื่อยืนยันวันส่ง (สั่งทำชุดของขวัญ)
- The Payment object
- The Checkout Session object
- Endpoints (12)
- POSTสร้าง payment
- GETดู payment
- PATCHแก้ไข payment
- POSTยืนยัน payment
- POSTCapture ยอดที่ authorize ไว้
- POSTยกเลิก payment (void)
- GETรายการ payment
- POSTออก QR PromptPay ใหม่
- GETช่องทางที่ใช้ได้สำหรับยอดนี้
- POSTสร้างหน้าชำระเงินสำเร็จรูป
- GETดู checkout session
- POSTปิด checkout session
- Webhooks (10)
- Errors
- Rate limit
- เวอร์ชันและ Changelog
- เครื่องมือ: State machine การชำระเงิน
- เครื่องมือ: QR PromptPay จำลอง
- PAYNARA
- Docs
- Payment API
- Payment
PAYNARA Payments API · โมดูล 1/5
Payment API
รับชำระเงินจากลูกค้าของร้านผ่านช่องทางเดียว: PromptPay QR · บัตร VISA / Mastercard (3-D Secure) · ผ่อน 0% · โมบายแบงก์กิ้ง — สร้าง payment จากเซิร์ฟเวอร์ ให้หน้าเว็บ/แอปยืนยัน แล้วรอผลทาง webhook
/v1/payments/v1/checkout-sessions/v1/payment-methods

ภาพรวมโมดูล Payment
ใช้เมื่อไร
- ร้านทำหน้าชำระเงินเอง (custom checkout) — ใช้ /v1/payments + PAYNARA.js
- ไม่อยากทำหน้าชำระเอง — ใช้ /v1/checkout-sessions แล้ว redirect ไปหน้าสำเร็จรูป
- สินค้าสั่งทำ/ต้องยืนยันสต็อกก่อนเก็บเงิน — capture_method = manual แล้ว capture ภายใน 7 วัน
- ขายหน้าร้าน/แผงตลาด — ออก QR PromptPay ต่อรายการ (ยอดล็อก ลูกค้าแก้ไม่ได้)
Object หลัก
-
Paymentการรับชำระ 1 ครั้งของคำสั่งซื้อ 1 รายการ — เก็บสถานะตั้งแต่สร้างจนเงินเข้า ค่าธรรมเนียม ยอดสุทธิ และยอดที่คืนได้ (ตัวอย่าง: คำสั่งซื้อของคุณอรอุมาหลังชำระสำเร็จ) -
Checkout Sessionหน้าชำระเงินสำเร็จรูปของ PAYNARA 1 ครั้ง — สร้าง payment ให้อัตโนมัติเมื่อลูกค้าเลือกช่องทาง
การยืนยันตัวตน
ทุกคำขอส่ง API key แบบ Bearer + X-Merchant-Id ของร้าน · sandbox ใช้ pn_test_… production ใช้ pn_live_… · แนะนำสร้าง restricted key ที่มีเฉพาะ scope ที่ระบบนั้นใช้ (เช่น ระบบบัญชีได้แค่ *:read)
POST https://sandbox.api.paynara.example/v1/payments 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 | สิทธิ์ | ระดับ |
|---|---|---|
payments:read | ดู payment ทีละรายการ/รายการทั้งหมด · ดูช่องทางที่ใช้ได้ | อ่าน |
payments:write | สร้าง แก้ไข ยืนยัน capture ยกเลิก และออก QR ใหม่ | เขียน |
checkout:read | ดู checkout session | อ่าน |
checkout:write | สร้างและปิด checkout session | เขียน |
ความสัมพันธ์กับโมดูลอื่น
- Transactionpayment ที่ succeeded กลายเป็นรายการ charge + fee และรวมเข้ารอบโอน T+1
- Refundคืนเงินเต็ม/บางส่วนจาก payment ที่ succeeded (ยังไม่ capture ให้ cancel)
- Verificationrisk.score ในทุก payment มาจากตัวตรวจความเสี่ยง · ตรวจ BIN บัตรก่อนเสนอผ่อน
- Notificationลงทะเบียน URL รับ payment.* และดูประวัติการส่ง
ข้อควรรู้
-
เงินเป็นสตางค์
ทุกฟิลด์เงินเป็นจำนวนเต็มหน่วยสตางค์ (฿1,040.00 = 104000) · ไม่มีทศนิยม · สกุลเงิน THB
-
Idempotency-Key
POST ที่สร้าง/เปลี่ยนเงินต้องส่ง Idempotency-Key (UUID v4) — ส่งซ้ำได้ภายใน 24 ชม. โดยไม่เกิดรายการซ้ำ
-
เวลา ISO 8601 +07:00
ทุกเวลาตอบเป็นเวลาไทย เช่น 2026-10-12T10:14:32+07:00 · ตัวกรองรับได้ทั้ง +07:00 และ Z
-
แบ่งหน้าแบบ cursor
limit (≤ 100) + starting_after / ending_before · ใช้ next_cursor จนกว่า has_more = false
-
เชื่อ webhook + GET เท่านั้น
อย่ายืนยันคำสั่งซื้อจาก return_url หรือค่าจากหน้าเว็บ — ตรวจด้วย webhook ที่ลายเซ็นถูก หรือ GET /v1/payments/{id}
-
PDPA + PCI DSS
ร้านไม่เก็บเลขบัตร (ใช้ token) · อีเมล/เบอร์ลูกค้าตอบแบบปิดบัง · ข้อมูลรายการเก็บ 10 ปีตามกฎหมายบัญชี
Workflow (3 เรื่อง)
แต่ละเรื่องดูได้ 2 แบบ: ภาพรวม สำหรับทุกคนในทีม และ Sequence ทีละขั้น สำหรับนักพัฒนา (กดเล่น หรือคลิกลูกศรเพื่อดูคำขอ/ผลลัพธ์จริงของขั้นนั้น) · ลูกศรประ = ไม่รอผล (webhook/คิว)
ลูกค้าจ่ายด้วยบัตร VISA + 3-D Secure
คุณอรอุมา ศ. สั่งขนมไทย ORD-2610-0153 ยอด ฿1,040 ผ่านเว็บร้าน — เลขบัตรไม่ผ่านเซิร์ฟเวอร์ร้าน
- ลูกค้าอรอุมา ศ.
- เว็บร้าน + PAYNARA.jsbaanmaeplub.example
- เซิร์ฟเวอร์ร้าน
- PAYNARA API
- ธนาคารผู้ออกบัตรACS 3-D Secure
- 1
ลูกค้า → เว็บร้าน + PAYNARA.js
ลูกค้าตรวจตะกร้า 3 รายการ + ค่าส่งแช่เย็น แล้วเลือกจ่ายด้วยบัตร
- 2
เว็บร้าน + PAYNARA.js → เซิร์ฟเวอร์ร้าน
หน้าเว็บส่งเลขคำสั่งซื้อให้เซิร์ฟเวอร์ร้าน (ยังไม่มีข้อมูลบัตร)
- 3
เซิร์ฟเวอร์ร้าน → PAYNARA API
เซิร์ฟเวอร์ร้านสร้าง payment ด้วยยอดที่คำนวณเอง (ไม่เชื่อยอดจากหน้าเว็บ) พร้อม Idempotency-Key
POST /v1/payments - 4
เซิร์ฟเวอร์ร้าน → เว็บร้าน + PAYNARA.js
ส่งเฉพาะ client_secret กลับให้หน้าเว็บ (ไม่ส่ง API key)
- 5
เว็บร้าน + PAYNARA.js → PAYNARA API
PAYNARA.js แลกเลขบัตรเป็น token แล้วยืนยันรายการโดยตรงกับ PAYNARA
POST /v1/payments/pay_3NqL8k/confirm - 6
เว็บร้าน + PAYNARA.js → ธนาคารผู้ออกบัตร
หน้าเว็บพาลูกค้าไปหน้ายืนยันตัวตนของธนาคารผู้ออกบัตร
- 7
ลูกค้า → ธนาคารผู้ออกบัตร
ลูกค้ากรอกรหัส OTP ที่ได้ทาง SMS ของธนาคาร
- 8
ธนาคารผู้ออกบัตร → PAYNARA API
ธนาคารแจ้งผลยืนยันตัวตนสำเร็จ แล้ว PAYNARA ขออนุมัติวงเงิน
- 9
PAYNARA API → PAYNARA API
ได้รหัสอนุมัติ T48213 คะแนนความเสี่ยงต่ำ จึงเก็บเงินทันที (capture อัตโนมัติ)
- 10
PAYNARA API → เว็บร้าน + PAYNARA.js
ลูกค้าถูกพากลับหน้าร้านพร้อม payment id
- 11
PAYNARA API → เซิร์ฟเวอร์ร้าน
PAYNARA แจ้งเซิร์ฟเวอร์ร้านแบบไม่รอผล — ร้านตรวจลายเซ็นแล้วเปลี่ยนคำสั่งซื้อเป็น "ชำระแล้ว"
POST /api/paynara/webhookไม่รอผล (async) - 12
เซิร์ฟเวอร์ร้าน → PAYNARA API
หน้า return_url ถามสถานะจริงจากเซิร์ฟเวอร์อีกครั้งก่อนแสดง "สั่งซื้อสำเร็จ"
GET /v1/payments/pay_3NqL8k
เงิน ฿1,040 เข้าสถานะ succeeded ภายใน 1 นาที 27 วินาที · ร้านได้สุทธิ ฿1,010.51 (หักค่าธรรมเนียม 2.65% + VAT) ในรอบโอน 13 ต.ค.
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 ลูกค้า เว็บร้าน + PAYNARA.js
กด "ชำระเงิน ฿1,040"
ลูกค้าตรวจตะกร้า 3 รายการ + ค่าส่งแช่เย็น แล้วเลือกจ่ายด้วยบัตร
2 เว็บร้าน + PAYNARA.js เซิร์ฟเวอร์ร้าน
POST /checkout (ของร้าน)
หน้าเว็บส่งเลขคำสั่งซื้อให้เซิร์ฟเวอร์ร้าน (ยังไม่มีข้อมูลบัตร)
3 เซิร์ฟเวอร์ร้าน PAYNARA API
POST /v1/payments
เซิร์ฟเวอร์ร้านสร้าง payment ด้วยยอดที่คำนวณเอง (ไม่เชื่อยอดจากหน้าเว็บ) พร้อม Idempotency-Key
POST /v1/payments HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
X-Merchant-Id: mch_baanmaeplub
Idempotency-Key: 7f3c9a2e-1b4d-4c8e-9f60-2a5d8e1c4b7f
{
"amount": 104000,
"currency": "THB",
"method": "card",
"order_ref": "ORD-2610-0153",
"customer": "cus_Or7k2",
"return_url": "https://baanmaeplub.example/checkout/return"
}HTTP/1.1 201 Created
{
"id": "pay_3NqL8k",
"status": "requires_payment_method",
"client_secret": "pay_3NqL8k_secret_Xk29vQ"
}4 เซิร์ฟเวอร์ร้าน เว็บร้าน + PAYNARA.js
client_secret
ส่งเฉพาะ client_secret กลับให้หน้าเว็บ (ไม่ส่ง API key)
5 เว็บร้าน + PAYNARA.js PAYNARA API
POST …/confirm
PAYNARA.js แลกเลขบัตรเป็น token แล้วยืนยันรายการโดยตรงกับ PAYNARA
POST /v1/payments/pay_3NqL8k/confirm HTTP/1.1
Authorization: Bearer pay_3NqL8k_secret_Xk29vQ
{
"payment_method": "tok_sbx_visa_0101",
"return_url": "https://baanmaeplub.example/checkout/return"
}HTTP/1.1 200 OK
{
"id": "pay_3NqL8k",
"status": "requires_action",
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": {
"url": "https://3ds.sandbox.paynara.example/auth/ac_6Hs2Pd",
"return_url": "https://baanmaeplub.example/checkout/return"
},
"expires_at": "2026-10-12T10:23:40+07:00"
}
}6 เว็บร้าน + PAYNARA.js ธนาคารผู้ออกบัตร
redirect 3-D Secure
หน้าเว็บพาลูกค้าไปหน้ายืนยันตัวตนของธนาคารผู้ออกบัตร
7 ลูกค้า ธนาคารผู้ออกบัตร
กรอก OTP
ลูกค้ากรอกรหัส OTP ที่ได้ทาง SMS ของธนาคาร
หมดเวลา 10 นาที → three_d_secure_failed แล้ว status กลับเป็น requires_payment_method
8 ธนาคารผู้ออกบัตร PAYNARA API
ผลยืนยัน: authenticated
ธนาคารแจ้งผลยืนยันตัวตนสำเร็จ แล้ว PAYNARA ขออนุมัติวงเงิน
9 PAYNARA API PAYNARA API
อนุมัติ + ตรวจความเสี่ยง (12 = allow)
ได้รหัสอนุมัติ T48213 คะแนนความเสี่ยงต่ำ จึงเก็บเงินทันที (capture อัตโนมัติ)
10 PAYNARA API เว็บร้าน + PAYNARA.js
302 → return_url
ลูกค้าถูกพากลับหน้าร้านพร้อม payment id
11 PAYNARA API เซิร์ฟเวอร์ร้านasync
webhook payment.succeeded
PAYNARA แจ้งเซิร์ฟเวอร์ร้านแบบไม่รอผล — ร้านตรวจลายเซ็นแล้วเปลี่ยนคำสั่งซื้อเป็น "ชำระแล้ว"
POST /api/paynara/webhook HTTP/1.1
Paynara-Signature: t=1791774873,v1=5b1e…
{
"id": "evt_7Gq2Mn",
"type": "payment.succeeded",
"data": {
"id": "pay_3NqL8k",
"status": "succeeded",
"amount_received": 104000
}
}HTTP/1.1 200 OK12 เซิร์ฟเวอร์ร้าน PAYNARA API
GET /v1/payments/pay_3NqL8k
หน้า return_url ถามสถานะจริงจากเซิร์ฟเวอร์อีกครั้งก่อนแสดง "สั่งซื้อสำเร็จ"
GET /v1/payments/pay_3NqL8k HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"id": "pay_3NqL8k",
"status": "succeeded",
"amount_received": 104000,
"net": 101051
}เงิน ฿1,040 เข้าสถานะ succeeded ภายใน 1 นาที 27 วินาที · ร้านได้สุทธิ ฿1,010.51 (หักค่าธรรมเนียม 2.65% + VAT) ในรอบโอน 13 ต.ค.
PromptPay QR หมดอายุ → ออกใหม่ → ลูกค้าสแกนจ่าย
คำสั่งซื้อ ORD-2610-0155 ยอด ฿430 · ลูกค้าไปทำธุระจน QR ใบแรกหมดอายุ แล้วกลับมาขอ QR ใหม่
- ลูกค้า
- หน้าชำระของร้าน
- PAYNARA API
- แอปธนาคารของลูกค้าธนาคารฟ้าใส (สมมติ)
- เครือข่าย PromptPay
- 1
หน้าชำระของร้าน → PAYNARA API
สร้าง payment แบบ PromptPay ได้ QR ทันทีใน next_action
POST /v1/payments - 2
หน้าชำระของร้าน → ลูกค้า
หน้าเว็บแสดง QR พร้อมยอดและเวลาที่เหลือ
- 3
PAYNARA API → PAYNARA API
ครบ 15 นาทีไม่มีการโอน ระบบยกเลิก QR ใบนี้ (payment ยังเปิดอยู่)
- 4
ลูกค้า → แอปธนาคารของลูกค้า
ลูกค้ากลับมาสแกนภาพเก่าที่แคปไว้ — แอปธนาคารแจ้งว่ารายการนี้ใช้ไม่ได้
- 5
หน้าชำระของร้าน → PAYNARA API
หน้าเว็บ poll สถานะแล้วพบ last_error = qr_expired จึงแสดงปุ่ม "ขอ QR ใหม่"
GET /v1/payments/pay_3Tu7Zv - 6
หน้าชำระของร้าน → PAYNARA API
ขอ QR ใบใหม่ให้ payment เดิม (เลขคำสั่งซื้อเดิม)
POST /v1/payments/pay_3Tu7Zv/qr - 7
ลูกค้า → แอปธนาคารของลูกค้า
ลูกค้าสแกน เห็นชื่อร้านและยอด ฿430 แล้วกดยืนยัน
- 8
แอปธนาคารของลูกค้า → เครือข่าย PromptPay
ธนาคารของลูกค้าส่งรายการผ่านเครือข่าย PromptPay
- 9
เครือข่าย PromptPay → PAYNARA API
เครือข่ายแจ้ง PAYNARA พร้อมเลขอ้างอิง — ระบบจับคู่กับ payment ได้ทันที
ไม่รอผล (async) - 10
PAYNARA API → หน้าชำระของร้าน
การ poll ครั้งถัดไปได้ succeeded หน้าเว็บแสดง "ชำระแล้ว" (และ webhook payment.succeeded ไปที่เซิร์ฟเวอร์ร้าน)
ได้เงินภายใน 9 วินาทีหลังลูกค้ากดยืนยันในแอปธนาคาร · ค่าธรรมเนียม 0.8% = ฿3.68 รวม VAT · ไม่มีคำสั่งซื้อซ้ำเพราะใช้ payment เดิม
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 หน้าชำระของร้าน PAYNARA API
POST /v1/payments (promptpay)
สร้าง payment แบบ PromptPay ได้ QR ทันทีใน next_action
POST /v1/payments HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"amount": 43000,
"currency": "THB",
"method": "promptpay",
"order_ref": "ORD-2610-0155",
"promptpay": {
"expires_in": 900
}
}HTTP/1.1 201 Created
{
"id": "pay_3Tu7Zv",
"object": "payment",
"amount": 43000,
"currency": "THB",
"status": "requires_action",
"method": "promptpay",
"capture_method": "automatic",
"order_ref": "ORD-2610-0155",
"line_items": [
{
"sku": "LK-CB",
"name": "ลูกชุบ (กล่อง 20 ชิ้น)",
"quantity": 1,
"unit_amount": 22000,
"amount": 22000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 1,
"unit_amount": 15000,
"amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"next_action": {
"type": "display_promptpay_qr",
"display_promptpay_qr": {
"object": "promptpay_qr",
"id": "qr_5Fa8Lm",
"payment": "pay_3Tu7Zv",
"amount": 43000,
"currency": "THB",
"payload": "00020101021230550016A00000067701011201150107536000315080214BMP2610015553037645406430.005802TH6304A1C9",
"image_url": "https://files.sandbox.paynara.example/qr/qr_5Fa8Lm.png",
"ref1": "ORD-2610-0155",
"ref2": "pay_3Tu7Zv",
"created": "2026-10-12T10:52:44+07:00",
"expires_at": "2026-10-12T11:07:44+07:00"
},
"expires_at": "2026-10-12T11:07:44+07:00"
},
"created": "2026-10-12T10:52:44+07:00",
"livemode": false
}2 หน้าชำระของร้าน ลูกค้า
แสดง QR + นับถอยหลัง 15:00
หน้าเว็บแสดง QR พร้อมยอดและเวลาที่เหลือ
3 PAYNARA API PAYNARA API
11:07:44 QR หมดอายุ
ครบ 15 นาทีไม่มีการโอน ระบบยกเลิก QR ใบนี้ (payment ยังเปิดอยู่)
4 ลูกค้า แอปธนาคารของลูกค้า
สแกน QR เก่า
ลูกค้ากลับมาสแกนภาพเก่าที่แคปไว้ — แอปธนาคารแจ้งว่ารายการนี้ใช้ไม่ได้
ไม่มีเงินออกจากบัญชีลูกค้า เพราะเครือข่ายตรวจ QR กับ PAYNARA ก่อนตัดเงิน
5 หน้าชำระของร้าน PAYNARA API
GET /v1/payments/pay_3Tu7Zv
หน้าเว็บ poll สถานะแล้วพบ last_error = qr_expired จึงแสดงปุ่ม "ขอ QR ใหม่"
GET /v1/payments/pay_3Tu7Zv HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9LrHTTP/1.1 200 OK
{
"id": "pay_3Tu7Zv",
"status": "requires_action",
"next_action": null,
"last_error": {
"code": "qr_expired",
"message": "QR หมดอายุแล้ว กรุณาขอ QR ใหม่"
}
}6 หน้าชำระของร้าน PAYNARA API
POST …/qr
ขอ QR ใบใหม่ให้ payment เดิม (เลขคำสั่งซื้อเดิม)
POST /v1/payments/pay_3Tu7Zv/qr HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"expires_in": 900,
"format": "png"
}HTTP/1.1 201 Created
{
"id": "qr_5Gb2Nn",
"expires_at": "2026-10-12T11:23:10+07:00",
"image_url": "https://files.sandbox.paynara.example/qr/qr_5Gb2Nn.png"
}7 ลูกค้า แอปธนาคารของลูกค้า
สแกน QR ใหม่ + ยืนยัน
ลูกค้าสแกน เห็นชื่อร้านและยอด ฿430 แล้วกดยืนยัน
8 แอปธนาคารของลูกค้า เครือข่าย PromptPay
โอน ฿430.00
ธนาคารของลูกค้าส่งรายการผ่านเครือข่าย PromptPay
9 เครือข่าย PromptPay PAYNARA APIasync
แจ้งผลโอน (ref1, ref2)
เครือข่ายแจ้ง PAYNARA พร้อมเลขอ้างอิง — ระบบจับคู่กับ payment ได้ทันที
10 PAYNARA API หน้าชำระของร้าน
status = succeeded
การ poll ครั้งถัดไปได้ succeeded หน้าเว็บแสดง "ชำระแล้ว" (และ webhook payment.succeeded ไปที่เซิร์ฟเวอร์ร้าน)
HTTP/1.1 200 OK
{
"id": "pay_3Tu7Zv",
"status": "succeeded",
"amount_received": 43000,
"method_details": {
"promptpay": {
"qr_id": "qr_5Gb2Nn",
"payer_bank": "fsi",
"transaction_ref": "2026101211091877FSI03218"
}
}
}ได้เงินภายใน 9 วินาทีหลังลูกค้ากดยืนยันในแอปธนาคาร · ค่าธรรมเนียม 0.8% = ฿3.68 รวม VAT · ไม่มีคำสั่งซื้อซ้ำเพราะใช้ payment เดิม
Authorize ก่อน แล้ว capture เมื่อยืนยันวันส่ง (สั่งทำชุดของขวัญ)
ORD-2610-0154: ชุดของขวัญ 6 ชุดสำหรับงานแต่ง · ร้านกันวงเงินไว้ก่อน ลูกค้าลดเหลือ 5 ชุด จึง capture บางส่วน
- ลูกค้า (คู่บ่าวสาว)
- หลังร้าน (แอดมิน)
- เซิร์ฟเวอร์ร้าน
- PAYNARA API
- ธนาคารผู้ออกบัตร
- 1
เซิร์ฟเวอร์ร้าน → PAYNARA API
สร้าง payment แบบ capture_method = manual ยอด 6 ชุด + ค่าส่ง
POST /v1/payments - 2
ลูกค้า (คู่บ่าวสาว) → PAYNARA API
ลูกค้ายืนยันบัตร Mastercard ผ่านหน้าชำระ (เหมือนเรื่องแรก)
- 3
PAYNARA API → ธนาคารผู้ออกบัตร
PAYNARA ขอ authorize เท่านั้น ยังไม่ตัดเงิน
- 4
PAYNARA API → เซิร์ฟเวอร์ร้าน
แจ้งว่ามีวงเงินรอ capture ภายในวันที่ 19 ต.ค.
POST /api/paynara/webhookไม่รอผล (async) - 5
ลูกค้า (คู่บ่าวสาว) → หลังร้าน (แอดมิน)
สองวันต่อมาลูกค้าโทรมาขอลดจำนวน แอดมินแก้คำสั่งซื้อในหลังร้าน
- 6
หลังร้าน (แอดมิน) → เซิร์ฟเวอร์ร้าน
แอดมินกดยืนยันการผลิตและวันส่ง
- 7
เซิร์ฟเวอร์ร้าน → PAYNARA API
สคริปต์รุ่นเก่าส่งยอดรวมค่ากล่องพิเศษจนเกินยอดอนุมัติ — ระบบปฏิเสธ
POST /v1/payments/pay_3Rs4Yt/capture - 8
เซิร์ฟเวอร์ร้าน → PAYNARA API
แก้ยอดเป็น 5 ชุด + ค่าส่ง แล้ว capture ใหม่ด้วย Idempotency-Key ใหม่
POST /v1/payments/pay_3Rs4Yt/capture - 9
PAYNARA API → ธนาคารผู้ออกบัตร
ธนาคารตัดยอด 5 ชุดและคืนวงเงินส่วนที่ไม่ได้ใช้ให้ลูกค้า
- 10
PAYNARA API → เซิร์ฟเวอร์ร้าน
ร้านบันทึกยอดรับจริงลงคำสั่งซื้อและออกใบเสร็จ
ไม่รอผล (async)
เก็บจริง ฿4,510 จากที่อนุมัติ ฿5,400 · คืนวงเงิน ฿890 ให้ลูกค้าอัตโนมัติ · ไม่ต้องคืนเงิน (ไม่มีค่าธรรมเนียมส่วนที่ไม่ได้เก็บ)
กด เล่น หรือคลิกลูกศรในแผนภาพ เพื่อดูคำขอและผลลัพธ์ของแต่ละขั้น
1 เซิร์ฟเวอร์ร้าน PAYNARA API
POST /v1/payments (manual)
สร้าง payment แบบ capture_method = manual ยอด 6 ชุด + ค่าส่ง
POST /v1/payments HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"amount": 540000,
"currency": "THB",
"method": "card",
"capture_method": "manual",
"order_ref": "ORD-2610-0154"
}HTTP/1.1 201 Created
{
"id": "pay_3Rs4Yt",
"status": "requires_payment_method"
}2 ลูกค้า (คู่บ่าวสาว) PAYNARA API
ยืนยันบัตร + 3-D Secure
ลูกค้ายืนยันบัตร Mastercard ผ่านหน้าชำระ (เหมือนเรื่องแรก)
3 PAYNARA API ธนาคารผู้ออกบัตร
ขอกันวงเงิน ฿5,400
PAYNARA ขอ authorize เท่านั้น ยังไม่ตัดเงิน
4 PAYNARA API เซิร์ฟเวอร์ร้านasync
webhook payment.amount_capturable_updated
แจ้งว่ามีวงเงินรอ capture ภายในวันที่ 19 ต.ค.
POST /api/paynara/webhook HTTP/1.1
{
"type": "payment.amount_capturable_updated",
"data": {
"id": "pay_3Rs4Yt",
"status": "requires_capture",
"amount_capturable": 540000,
"capture_before": "2026-10-19T10:26:08+07:00"
}
}HTTP/1.1 200 OK5 ลูกค้า (คู่บ่าวสาว) หลังร้าน (แอดมิน)
ขอลดเหลือ 5 ชุด
สองวันต่อมาลูกค้าโทรมาขอลดจำนวน แอดมินแก้คำสั่งซื้อในหลังร้าน
6 หลังร้าน (แอดมิน) เซิร์ฟเวอร์ร้าน
ยืนยันวันส่ง 14 ต.ค.
แอดมินกดยืนยันการผลิตและวันส่ง
7 เซิร์ฟเวอร์ร้าน PAYNARA API
POST …/capture (เกินยอด)
สคริปต์รุ่นเก่าส่งยอดรวมค่ากล่องพิเศษจนเกินยอดอนุมัติ — ระบบปฏิเสธ
POST /v1/payments/pay_3Rs4Yt/capture HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"amount_to_capture": 565000
}HTTP/1.1 409 Conflict
{
"error": {
"code": "amount_exceeds_authorized",
"message": "ยอด capture เกินยอดที่อนุมัติ",
"param": "amount_to_capture",
"request_id": "req_4Mx8Ta"
}
}8 เซิร์ฟเวอร์ร้าน PAYNARA API
POST …/capture ฿4,510
แก้ยอดเป็น 5 ชุด + ค่าส่ง แล้ว capture ใหม่ด้วย Idempotency-Key ใหม่
POST /v1/payments/pay_3Rs4Yt/capture HTTP/1.1
Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr
{
"amount_to_capture": 451000
}HTTP/1.1 200 OK
{
"id": "pay_3Rs4Yt",
"status": "succeeded",
"amount_received": 451000,
"amount_released": 89000
}9 PAYNARA API ธนาคารผู้ออกบัตร
ตัดเงิน + ปล่อยวงเงินที่เหลือ
ธนาคารตัดยอด 5 ชุดและคืนวงเงินส่วนที่ไม่ได้ใช้ให้ลูกค้า
10 PAYNARA API เซิร์ฟเวอร์ร้านasync
webhook payment.succeeded
ร้านบันทึกยอดรับจริงลงคำสั่งซื้อและออกใบเสร็จ
เก็บจริง ฿4,510 จากที่อนุมัติ ฿5,400 · คืนวงเงิน ฿890 ให้ลูกค้าอัตโนมัติ · ไม่ต้องคืนเงิน (ไม่มีค่าธรรมเนียมส่วนที่ไม่ได้เก็บ)
Objects
The Payment object
การรับชำระ 1 ครั้งของคำสั่งซื้อ 1 รายการ — เก็บสถานะตั้งแต่สร้างจนเงินเข้า ค่าธรรมเนียม ยอดสุทธิ และยอดที่คืนได้ (ตัวอย่าง: คำสั่งซื้อของคุณอรอุมาหลังชำระสำเร็จ)
idstringไม่บังคับอ่านอย่างเดียวรหัส payment (ขึ้นต้น pay_)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
amountintegerจำเป็นยอดที่ขอเก็บ (สตางค์) — ต้องเท่ากับผลรวม line_items ถ้าส่ง line_items
amount_capturableintegerไม่บังคับอ่านอย่างเดียวยอดที่ authorize แล้วรอ capture (เฉพาะ capture_method = manual)
amount_receivedintegerไม่บังคับอ่านอย่างเดียวยอดที่เก็บได้จริง
amount_refundedintegerไม่บังคับอ่านอย่างเดียวยอดที่คืนไปแล้วรวมทุกครั้ง (ดูหน้า Refund)
amount_refundableintegerไม่บังคับอ่านอย่างเดียวยอดที่ยังคืนได้ = amount_received − amount_refunded
currencystringไม่บังคับสกุลเงิน
statusstringไม่บังคับอ่านอย่างเดียวสถานะ (ดูแผนภาพในเครื่องมือท้ายหน้า)
capture_methodstringไม่บังคับautomatic = เก็บเงินทันทีเมื่ออนุมัติ · manual = authorize ไว้ก่อนแล้ว capture ภายใน 7 วัน (เฉพาะบัตร)
methodstringจำเป็นช่องทางชำระ
method_detailsobjectไม่บังคับอ่านอย่างเดียวรายละเอียดตามช่องทาง (มีเฉพาะ key ของช่องทางที่ใช้)
ฟิลด์ย่อยของ
method_details(4)cardobjectไม่บังคับข้อมูลบัตร (ปิดบัง)
ฟิลด์ย่อยของ
card(9)brandstringไม่บังคับอ่านอย่างเดียวเครือข่ายบัตร
last4stringไม่บังคับอ่านอย่างเดียวเลข 4 หลักท้าย (ไม่เก็บเลขบัตรเต็ม — PAYNARA เป็นผู้เก็บตามมาตรฐาน PCI DSS)
exp_monthintegerไม่บังคับอ่านอย่างเดียวเดือนหมดอายุ
exp_yearintegerไม่บังคับอ่านอย่างเดียวปีหมดอายุ (ค.ศ.)
countrystringไม่บังคับอ่านอย่างเดียวประเทศผู้ออกบัตร (ISO 3166-1 alpha-2) — ไม่ใช่ TH คิดค่าธรรมเนียมบัตรต่างประเทศ
binstringไม่บังคับอ่านอย่างเดียว6 หลักแรก (ดูรายละเอียดผ่าน GET /v1/bins/{bin} ในหน้า Verification)
fundingstringไม่บังคับอ่านอย่างเดียวชนิดบัตร
three_d_secureobjectไม่บังคับอ่านอย่างเดียวผลการยืนยัน 3-D Secure
ฟิลด์ย่อยของ
three_d_secure(2)resultstringไม่บังคับผล
versionstringไม่บังคับเวอร์ชันโปรโตคอล
authorization_codestringไม่บังคับอ่านอย่างเดียวรหัสอนุมัติจากธนาคารผู้ออกบัตร (ใช้อ้างอิงเมื่อมีข้อพิพาท)
promptpayobjectไม่บังคับQR ล่าสุดของรายการ
ฟิลด์ย่อยของ
promptpay(3)qr_idstringไม่บังคับรหัส QR
payer_bankstringไม่บังคับธนาคารของผู้โอน (หลังชำระ)
transaction_refstringไม่บังคับเลขอ้างอิงธุรกรรมจากเครือข่าย PromptPay
installmentobjectไม่บังคับแผนผ่อน
ฟิลด์ย่อยของ
installment(3)termintegerไม่บังคับจำนวนเดือน
monthly_amountintegerไม่บังคับยอดต่อเดือนที่ลูกค้าเห็น (สตางค์)
absorbed_bystringไม่บังคับผู้รับภาระดอกเบี้ย
mobile_bankingobjectไม่บังคับธนาคารที่ลูกค้าเลือก
ฟิลด์ย่อยของ
mobile_banking(1)bankstringไม่บังคับรหัสธนาคาร (สมมติ)
next_actionobjectไม่บังคับอ่านอย่างเดียวสิ่งที่หน้าเว็บ/แอปต้องทำต่อเมื่อ status = requires_action (null เมื่อไม่ต้องทำอะไร)
ฟิลด์ย่อยของ
next_action(4)typestringไม่บังคับชนิดการกระทำ
redirect_to_urlobjectไม่บังคับหน้า 3-D Secure หรือหน้าธนาคาร
ฟิลด์ย่อยของ
redirect_to_url(2)urlstring · uriไม่บังคับURL ที่ต้องพาลูกค้าไป
return_urlstring · uriไม่บังคับURL ที่จะกลับมาหลังยืนยัน
display_promptpay_qrobjectไม่บังคับQR สำหรับแสดง (object promptpay_qr)
expires_atstring · date-timeไม่บังคับหมดเวลาทำ next_action (3-D Secure 10 นาที · QR ตาม expires_in)
customerobjectไม่บังคับลูกค้าของร้าน (ส่ง id ตอนสร้าง · ตอบกลับแบบปิดบังอีเมล)
ฟิลด์ย่อยของ
customer(2)idstringไม่บังคับรหัสลูกค้า
emailstring · emailไม่บังคับอีเมล (ปิดบังบางส่วน)
order_refstringไม่บังคับเลขคำสั่งซื้อของร้าน (ไม่ซ้ำต่อร้าน — ใช้กระทบยอด)
descriptionstringไม่บังคับคำอธิบายที่แสดงในหน้าชำระและรายงาน
line_itemsarray<object>ไม่บังคับรายการสินค้า (แสดงในหน้าชำระ/ใบเสร็จ · ใช้ตรวจความเสี่ยง)
ฟิลด์ย่อยของ
line_items(5)skustringไม่บังคับรหัสสินค้า
namestringไม่บังคับชื่อสินค้า
quantityintegerไม่บังคับจำนวน
unit_amountintegerไม่บังคับราคาต่อหน่วย (สตางค์ รวม VAT)
amountintegerไม่บังคับอ่านอย่างเดียวquantity × unit_amount
feeobjectไม่บังคับอ่านอย่างเดียวค่าธรรมเนียม PAYNARA ของรายการนี้ (มีเมื่อ succeeded)
ฟิลด์ย่อยของ
fee(4)amountintegerไม่บังคับค่าธรรมเนียม (สตางค์)
vatintegerไม่บังคับVAT 7% ของค่าธรรมเนียม
ratestringไม่บังคับอัตราที่ใช้
fee_keystringไม่บังคับกลุ่มอัตรา (ดู GET /v1/fees)
netintegerไม่บังคับอ่านอย่างเดียวยอดสุทธิที่ร้านจะได้รับ = amount_received − fee.amount − fee.vat
riskobjectไม่บังคับอ่านอย่างเดียวผลตรวจความเสี่ยงอัตโนมัติ (รายละเอียดผ่าน POST /v1/risk/assess)
ฟิลด์ย่อยของ
risk(2)scoreintegerไม่บังคับคะแนน 0–100
decisionstringไม่บังคับผล
last_errorobjectไม่บังคับอ่านอย่างเดียวข้อผิดพลาดล่าสุด (เช่น บัตรถูกปฏิเสธ) — null ถ้าไม่มี
ฟิลด์ย่อยของ
last_error(3)codestringไม่บังคับรหัส error (ดูหัวข้อ Errors)
decline_codestringไม่บังคับเหตุผลจากธนาคาร (ถ้ามี)
messagestringไม่บังคับข้อความภาษาไทยที่แสดงลูกค้าได้
client_secretstringไม่บังคับอ่านอย่างเดียวความลับสำหรับหน้าเว็บ/แอปใช้ยืนยันรายการนี้ (คืนเฉพาะตอนสร้าง · ห้ามบันทึก log)
return_urlstring · uriไม่บังคับURL กลับหลัง 3-D Secure / แอปธนาคาร
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
settlement_idstringไม่บังคับอ่านอย่างเดียวรอบโอนที่รายการนี้อยู่ (ดูหน้า Transaction) — null จนกว่าจะตัดรอบ
captured_atstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาเก็บเงินสำเร็จ
canceled_atstring · date-timeไม่บังคับอ่านอย่างเดียวเวลายกเลิก
cancellation_reasonstringไม่บังคับอ่านอย่างเดียวเหตุผลการยกเลิก
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
updatedstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาเปลี่ยนแปลงล่าสุด
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 104000,
"amount_refunded": 0,
"amount_refundable": 104000,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "succeeded",
"method_details": {
"card": {
"brand": "visa",
"last4": "0101",
"exp_month": 8,
"exp_year": 2029,
"country": "TH",
"bin": "400000",
"funding": "credit",
"issuer": "ธนาคารสยามรุ่ง (สมมติ)",
"three_d_secure": {
"result": "authenticated",
"version": "2.2.0"
},
"authorization_code": "T48213"
}
},
"next_action": null,
"fee": {
"amount": 2756,
"vat": 193,
"rate": "2.65%",
"fee_key": "card"
},
"net": 101051,
"risk": {
"score": 12,
"decision": "allow"
},
"last_error": null,
"updated": "2026-10-12T10:14:32+07:00",
"captured_at": "2026-10-12T10:14:32+07:00",
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": "stl_20261013"
}
The Checkout Session object
หน้าชำระเงินสำเร็จรูปของ PAYNARA 1 ครั้ง — สร้าง payment ให้อัตโนมัติเมื่อลูกค้าเลือกช่องทาง
idstringไม่บังคับอ่านอย่างเดียวรหัส session (ขึ้นต้น cs_)
objectstringไม่บังคับอ่านอย่างเดียวชนิด object
urlstring · uriไม่บังคับอ่านอย่างเดียวลิงก์หน้าชำระเงินสำเร็จรูป — redirect ลูกค้าไปที่นี่ (ใช้ได้ครั้งเดียวจนหมดอายุ)
statusstringไม่บังคับอ่านอย่างเดียวสถานะ session
payment_statusstringไม่บังคับอ่านอย่างเดียวสถานะการจ่าย
amount_totalintegerไม่บังคับอ่านอย่างเดียวยอดรวมที่คำนวณจาก line_items (สตางค์)
currencystringไม่บังคับสกุลเงิน
line_itemsarray<object>จำเป็นรายการสินค้า (เหมือน payment.line_items)
ฟิลด์ย่อยของ
line_items(5)skustringไม่บังคับรหัสสินค้า
namestringไม่บังคับชื่อสินค้า
quantityintegerไม่บังคับจำนวน
unit_amountintegerไม่บังคับราคาต่อหน่วย (สตางค์ รวม VAT)
amountintegerไม่บังคับอ่านอย่างเดียวquantity × unit_amount
allowed_methodsarray<string>ไม่บังคับช่องทางที่แสดงในหน้า (ไม่ส่ง = ทุกช่องทางที่ร้านเปิด)
customerstringไม่บังคับรหัสลูกค้า (ถ้ามี)
customer_emailstring · emailไม่บังคับอีเมลสำหรับส่งใบเสร็จ
localestringไม่บังคับภาษาของหน้า
order_refstringไม่บังคับเลขคำสั่งซื้อของร้าน
success_urlstring · uriจำเป็นกลับมาเมื่อจ่ายสำเร็จ ({CHECKOUT_SESSION_ID} ถูกแทนค่าให้)
cancel_urlstring · uriจำเป็นกลับมาเมื่อลูกค้ากดยกเลิก
paymentstringไม่บังคับอ่านอย่างเดียวpayment ที่เกิดขึ้น (มีเมื่อ complete)
expires_atstring · date-timeไม่บังคับอ่านอย่างเดียวหมดอายุ (ค่าเริ่ม 60 นาที · 30 นาที–24 ชม.)
brandingobjectไม่บังคับโลโก้/สีของร้านในหน้าชำระ
ฟิลด์ย่อยของ
branding(2)logo_urlstring · uriไม่บังคับโลโก้ (PNG/SVG ≤ 512 KB)
colorstringไม่บังคับสีปุ่มหลัก (hex)
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
createdstring · date-timeไม่บังคับอ่านอย่างเดียวเวลาสร้าง (ISO 8601 +07:00)
livemodebooleanไม่บังคับอ่านอย่างเดียวtrue = production · false = sandbox
{
"id": "cs_8Rt3Lp",
"object": "checkout_session",
"url": "https://checkout.sandbox.paynara.example/c/cs_8Rt3Lp",
"status": "open",
"payment_status": "unpaid",
"amount_total": 104000,
"currency": "THB",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"payment": null,
"expires_at": "2026-10-12T11:13:05+07:00",
"branding": {
"logo_url": "https://baanmaeplub.example/logo.png",
"color": "#0f766e"
},
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false
}Endpoints (12)
| Method | Path | ทำอะไร | scope |
|---|---|---|---|
| POST | /v1/payments | สร้าง payment | payments:write |
| GET | /v1/payments/{payment_id} | ดู payment | payments:read |
| PATCH | /v1/payments/{payment_id} | แก้ไข payment | payments:write |
| POST | /v1/payments/{payment_id}/confirm | ยืนยัน payment | payments:write |
| POST | /v1/payments/{payment_id}/capture | Capture ยอดที่ authorize ไว้ | payments:write |
| POST | /v1/payments/{payment_id}/cancel | ยกเลิก payment (void) | payments:write |
| GET | /v1/payments | รายการ payment | payments:read |
| POST | /v1/payments/{payment_id}/qr | ออก QR PromptPay ใหม่ | payments:write |
| GET | /v1/payment-methods/available | ช่องทางที่ใช้ได้สำหรับยอดนี้ | payments:read |
| POST | /v1/checkout-sessions | สร้างหน้าชำระเงินสำเร็จรูป | checkout:write |
| GET | /v1/checkout-sessions/{session_id} | ดู checkout session | checkout:read |
| POST | /v1/checkout-sessions/{session_id}/expire | ปิด checkout session | checkout:write |
สร้าง payment
สร้างรายการรับชำระ 1 รายการ (payment intent) จากเซิร์ฟเวอร์ของร้าน — ยังไม่เก็บเงินจนกว่าจะยืนยัน · ส่ง client_secret ให้หน้าเว็บ/แอปไปยืนยันด้วย PAYNARA.js โดยเลขบัตรไม่ผ่านเซิร์ฟเวอร์ร้าน
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
amountintegerจำเป็นยอด (สตางค์) ขั้นต่ำ 2000 · ต้องเท่ากับผลรวม line_items ถ้าส่งมา
currencystringจำเป็นสกุลเงิน
methodstringจำเป็นช่องทาง
capture_methodstringไม่บังคับautomatic หรือ manual (manual ใช้ได้กับบัตรเท่านั้น)
customerstringไม่บังคับรหัสลูกค้า (ใช้ผูกบัตรที่บันทึกไว้และตรวจความเสี่ยง)
order_refstringไม่บังคับเลขคำสั่งซื้อของร้าน (ซ้ำกับรายการที่ succeeded แล้วจะได้ 409)
descriptionstringไม่บังคับคำอธิบาย
line_itemsarray<object>ไม่บังคับรายการสินค้า
ฟิลด์ย่อยของ
line_items(4)skustringไม่บังคับรหัสสินค้า
namestringไม่บังคับชื่อสินค้า
quantityintegerไม่บังคับจำนวน
unit_amountintegerไม่บังคับราคาต่อหน่วย (สตางค์ รวม VAT)
payment_methodstringไม่บังคับtoken บัตรจาก PAYNARA.js (tok_…) — ส่งพร้อม confirm: true เพื่อสร้างและยืนยันในครั้งเดียว
confirmbooleanไม่บังคับยืนยันทันทีหลังสร้าง
installmentobjectไม่บังคับเมื่อ method = installment
ฟิลด์ย่อยของ
installment(1)termintegerไม่บังคับจำนวนเดือน
mobile_bankingobjectไม่บังคับเมื่อ method = mobile_banking
ฟิลด์ย่อยของ
mobile_banking(1)bankstringไม่บังคับธนาคาร (สมมติ)
promptpayobjectไม่บังคับเมื่อ method = promptpay
ฟิลด์ย่อยของ
promptpay(1)expires_inintegerไม่บังคับอายุ QR (วินาที)
return_urlstring · uriไม่บังคับURL กลับหลัง 3-D Secure/แอปธนาคาร (จำเป็นสำหรับ card และ mobile_banking)
statement_descriptorstringไม่บังคับชื่อที่แสดงในใบแจ้งยอดบัตร (ภาษาอังกฤษ ≤ 22 ตัว)
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
ผลลัพธ์
- 201สร้างแล้ว — status = requires_payment_method (รอข้อมูลบัตรจากหน้าเว็บ)
- 200Idempotency-Key เดิม — คืนผลเดิมโดยไม่สร้างซ้ำ (หัว Idempotent-Replayed: true)
- 400
parameter_missingขาดฟิลด์ที่จำเป็น - 400
amount_too_smallยอดต่ำกว่าขั้นต่ำ - 400
amount_too_largeยอดสูงกว่าเพดาน - 400
currency_unsupportedสกุลเงินไม่รองรับ - 400
method_not_enabledช่องทางนี้ยังไม่เปิดให้ร้าน - 409
idempotency_conflictIdempotency-Key ซ้ำแต่ body ต่าง - 403
merchant_not_verifiedร้านค้ายังไม่ผ่าน KYB - 403
merchant_mismatchX-Merchant-Id ไม่ตรงกับ key - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- เงินเป็นสตางค์เสมอ: ฿1,040.00 = 104000 · ถ้าส่ง line_items ระบบตรวจว่า amount = Σ quantity × unit_amount ไม่งั้นได้ parameter_invalid
- method = promptpay สร้างแล้วได้ status = requires_action พร้อม QR ใน next_action ทันที (ไม่ต้องเรียก confirm)
- ห้ามส่งเลขบัตรเข้า API นี้โดยตรง — ใช้ PAYNARA.js / SDK มือถือแลกเป็น token (tok_…) เพื่อไม่ต้องผ่าน PCI DSS ระดับเต็ม
curl -X POST "https://sandbox.api.paynara.example/v1/payments" \
-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 '{
"amount": 104000,
"currency": "THB",
"method": "card",
"capture_method": "automatic",
"customer": "cus_Or7k2",
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"statement_descriptor": "BAANMAEPLUEM",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments', {
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({
"amount": 104000,
"currency": "THB",
"method": "card",
"capture_method": "automatic",
"customer": "cus_Or7k2",
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"statement_descriptor": "BAANMAEPLUEM",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
}),
});
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/payments",
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={
"amount": 104000,
"currency": "THB",
"method": "card",
"capture_method": "automatic",
"customer": "cus_Or7k2",
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"statement_descriptor": "BAANMAEPLUEM",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_payment_method",
"method_details": null,
"next_action": null,
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"client_secret": "pay_3NqL8k_secret_Xk29vQ",
"updated": "2026-10-12T10:13:05+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}{
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_payment_method",
"method_details": null,
"next_action": null,
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"client_secret": "pay_3NqL8k_secret_Xk29vQ",
"updated": "2026-10-12T10:13:05+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}{
"error": {
"code": "parameter_missing",
"message": "ขาดฟิลด์ที่จำเป็น",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_missing"
}
}{
"error": {
"code": "amount_too_small",
"message": "ยอดต่ำกว่าขั้นต่ำ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_too_small"
}
}{
"error": {
"code": "amount_too_large",
"message": "ยอดสูงกว่าเพดาน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_too_large"
}
}{
"error": {
"code": "currency_unsupported",
"message": "สกุลเงินไม่รองรับ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#currency_unsupported"
}
}{
"error": {
"code": "method_not_enabled",
"message": "ช่องทางนี้ยังไม่เปิดให้ร้าน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#method_not_enabled"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่ body ต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#idempotency_conflict"
}
}{
"error": {
"code": "merchant_not_verified",
"message": "ร้านค้ายังไม่ผ่าน KYB",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#merchant_not_verified"
}
}{
"error": {
"code": "merchant_mismatch",
"message": "X-Merchant-Id ไม่ตรงกับ key",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#merchant_mismatch"
}
}{
"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"
}
}ดู payment
อ่านสถานะล่าสุดของ payment — ใช้ตรวจซ้ำหลังได้ webhook หรือเมื่อลูกค้ากลับจากหน้า 3-D Secure (อย่าเชื่อ query string ใน return_url อย่างเดียว)
Path parameterspath
payment_idstringจำเป็นรหัส payment
Query parametersquery
expand[]array<string>ไม่บังคับขยาย object ที่อ้างถึงให้เป็นข้อมูลเต็ม (customer, settlement, refunds)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200payment ปัจจุบัน
- 404
resource_not_foundไม่พบรายการ - 403
livemode_mismatchข้อมูล sandbox ปนกับ production - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- หน้า return_url ควร poll ทุก 2–3 วินาทีไม่เกิน 60 วินาทีถ้ายังเป็น processing แล้วแสดง "กำลังตรวจสอบ" แทนการแจ้งล้มเหลว
curl -X GET "https://sandbox.api.paynara.example/v1/payments/pay_3NqL8k" \
-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/payments/pay_3NqL8k', {
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/payments/pay_3NqL8k",
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": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 104000,
"amount_refunded": 0,
"amount_refundable": 104000,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "succeeded",
"method_details": {
"card": {
"brand": "visa",
"last4": "0101",
"exp_month": 8,
"exp_year": 2029,
"country": "TH",
"bin": "400000",
"funding": "credit",
"issuer": "ธนาคารสยามรุ่ง (สมมติ)",
"three_d_secure": {
"result": "authenticated",
"version": "2.2.0"
},
"authorization_code": "T48213"
}
},
"next_action": null,
"fee": {
"amount": 2756,
"vat": 193,
"rate": "2.65%",
"fee_key": "card"
},
"net": 101051,
"risk": {
"score": 12,
"decision": "allow"
},
"last_error": null,
"updated": "2026-10-12T10:14:32+07:00",
"captured_at": "2026-10-12T10:14:32+07:00",
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": "stl_20261013"
}{
"error": {
"code": "resource_not_found",
"message": "ไม่พบรายการ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#resource_not_found"
}
}{
"error": {
"code": "livemode_mismatch",
"message": "ข้อมูล sandbox ปนกับ production",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#livemode_mismatch"
}
}{
"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"
}
}แก้ไข payment
PATCH/v1/payments/{payment_id}
แก้ยอด รายการสินค้า คำอธิบาย หรือ metadata ก่อนลูกค้ายืนยัน (เช่น ลูกค้าเพิ่มสินค้าในตะกร้า) · หลังยืนยันแล้วแก้ได้เฉพาะ description และ metadata
Path parameterspath
payment_idstringจำเป็นรหัส payment
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
amountintegerไม่บังคับยอดใหม่ (เฉพาะ requires_payment_method / requires_confirmation)
payment_methodstringไม่บังคับผูก token บัตรไว้ก่อนโดยยังไม่ยืนยัน → status เป็น requires_confirmation (ยืนยันภายหลังด้วย …/confirm)
line_itemsarray<object>ไม่บังคับรายการสินค้าใหม่ (แทนทั้งชุด)
descriptionstringไม่บังคับคำอธิบาย
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
ผลลัพธ์
- 200payment หลังแก้ไข
- 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 400
parameter_invalidค่าฟิลด์ไม่ถูกต้อง - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ส่ง metadata: {"key": ""} เพื่อลบ key นั้น · ส่ง metadata: "" เพื่อล้างทั้งหมด
curl -X PATCH "https://sandbox.api.paynara.example/v1/payments/pay_3NqL8k" \
-H "Authorization: Bearer pn_test_8Qm4ZsT2vXa9Lr" \
-H "Content-Type: application/json" \
-H "Paynara-Version: 2026-08-01" \
-H "X-Merchant-Id: mch_baanmaeplub" \
-d '{
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210",
"gift_note": "ฝากเขียนการ์ดสุขสันต์วันเกิด"
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments/pay_3NqL8k', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Paynara-Version': '2026-08-01',
'X-Merchant-Id': 'mch_baanmaeplub',
},
body: JSON.stringify({
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210",
"gift_note": "ฝากเขียนการ์ดสุขสันต์วันเกิด"
}
}),
});
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/payments/pay_3NqL8k",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Paynara-Version": "2026-08-01",
"X-Merchant-Id": "mch_baanmaeplub",
},
json={
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210",
"gift_note": "ฝากเขียนการ์ดสุขสันต์วันเกิด"
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210",
"gift_note": "ฝากเขียนการ์ดสุขสันต์วันเกิด"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_payment_method",
"method_details": null,
"next_action": null,
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"updated": "2026-10-12T10:13:21+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"error": {
"code": "parameter_invalid",
"message": "ค่าฟิลด์ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_invalid"
}
}{
"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"
}
}ยืนยัน payment
POST/v1/payments/{payment_id}/confirm
ผูกวิธีชำระ (token บัตร / ธนาคาร / แผนผ่อน) แล้วส่งไปขออนุมัติ — ผลอาจเป็น succeeded ทันที, requires_action (ต้องทำ 3-D Secure หรือเปิดแอปธนาคาร), processing หรือ error 402
Path parameterspath
payment_idstringจำเป็นรหัส payment
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
payment_methodstringจำเป็นtoken บัตรจาก PAYNARA.js หรือบัตรที่บันทึกไว้ (pm_…)
return_urlstring · uriไม่บังคับURL กลับหลัง 3-D Secure (แทนค่าที่ตั้งตอนสร้าง)
installmentobjectไม่บังคับแผนผ่อน (method = installment)
ฟิลด์ย่อยของ
installment(1)termintegerไม่บังคับจำนวนเดือน
save_payment_methodbooleanไม่บังคับบันทึกบัตรไว้ใช้ครั้งหน้า (ต้องได้รับความยินยอมจากลูกค้า)
deviceobjectไม่บังคับข้อมูลอุปกรณ์สำหรับตรวจความเสี่ยง (PAYNARA.js ใส่ให้อัตโนมัติ)
ฟิลด์ย่อยของ
device(2)ipstringไม่บังคับIP ของลูกค้า
user_agentstringไม่บังคับUser-Agent
ผลลัพธ์
- 200ต้องยืนยัน 3-D Secure — พาลูกค้าไป next_action.redirect_to_url.url
- 202processing — ธนาคารยังไม่ตอบ รอ webhook payment.succeeded / payment.failed
- 402
card_declinedบัตรถูกปฏิเสธ - 402
insufficient_fundsวงเงิน/ยอดเงินไม่พอ - 402
expired_cardบัตรหมดอายุ - 402
incorrect_cvcCVC ไม่ถูกต้อง - 402
three_d_secure_failedยืนยัน 3-D Secure ไม่ผ่าน - 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 409
idempotency_conflictIdempotency-Key ซ้ำแต่ body ต่าง - 503
service_unavailableปิดปรับปรุงหรือเครือข่ายปลายทางไม่ตอบ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- บัตรทดสอบ sandbox: 4000 0000 0000 0002 = สำเร็จทันที · 4000 0000 0000 0101 = ต้อง 3-D Secure · 4000 0000 0000 0200 = ยอดไม่พอ · 4000 0000 0000 0309 = บัตรหมดอายุ · 5100 0000 0000 0008 = Mastercard เดบิตสำเร็จ (เลขทดสอบเท่านั้น ไม่ใช่บัตรจริง)
- error 402 ไม่เปลี่ยน payment เป็น failed ทันที — status กลับไปเป็น requires_payment_method ให้ลูกค้าลองบัตรอื่นได้ (ไม่เกิน 10 ครั้ง/ชม.)
curl -X POST "https://sandbox.api.paynara.example/v1/payments/pay_3NqL8k/confirm" \
-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 '{
"payment_method": "tok_sbx_visa_0101",
"return_url": "https://baanmaeplub.example/checkout/return",
"device": {
"ip": "203.0.113.24",
"user_agent": "Mozilla/5.0 (iPhone)"
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments/pay_3NqL8k/confirm', {
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({
"payment_method": "tok_sbx_visa_0101",
"return_url": "https://baanmaeplub.example/checkout/return",
"device": {
"ip": "203.0.113.24",
"user_agent": "Mozilla/5.0 (iPhone)"
}
}),
});
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/payments/pay_3NqL8k/confirm",
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={
"payment_method": "tok_sbx_visa_0101",
"return_url": "https://baanmaeplub.example/checkout/return",
"device": {
"ip": "203.0.113.24",
"user_agent": "Mozilla/5.0 (iPhone)"
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_action",
"method_details": {
"card": {
"brand": "visa",
"last4": "0101",
"exp_month": 8,
"exp_year": 2029,
"country": "TH",
"bin": "400000",
"funding": "credit",
"issuer": "ธนาคารสยามรุ่ง (สมมติ)",
"three_d_secure": {
"result": "pending",
"version": "2.2.0"
},
"authorization_code": null
}
},
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": {
"url": "https://3ds.sandbox.paynara.example/auth/ac_6Hs2Pd",
"return_url": "https://baanmaeplub.example/checkout/return"
},
"expires_at": "2026-10-12T10:23:40+07:00"
},
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"updated": "2026-10-12T10:13:40+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}{
"id": "pay_3NqL8k",
"object": "payment",
"status": "processing",
"amount": 104000,
"next_action": null,
"last_error": null
}{
"error": {
"code": "card_declined",
"message": "บัตรถูกปฏิเสธ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#card_declined"
}
}{
"error": {
"code": "insufficient_funds",
"message": "วงเงิน/ยอดเงินไม่พอ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#insufficient_funds"
}
}{
"error": {
"code": "expired_card",
"message": "บัตรหมดอายุ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#expired_card"
}
}{
"error": {
"code": "incorrect_cvc",
"message": "CVC ไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#incorrect_cvc"
}
}{
"error": {
"code": "three_d_secure_failed",
"message": "ยืนยัน 3-D Secure ไม่ผ่าน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#three_d_secure_failed"
}
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"error": {
"code": "idempotency_conflict",
"message": "Idempotency-Key ซ้ำแต่ body ต่าง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#idempotency_conflict"
}
}{
"error": {
"code": "service_unavailable",
"message": "ปิดปรับปรุงหรือเครือข่ายปลายทางไม่ตอบ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#service_unavailable"
}
}{
"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"
}
}Capture ยอดที่ authorize ไว้
POST/v1/payments/{payment_id}/capture
เก็บเงินจริงจาก payment ที่ capture_method = manual และ status = requires_capture · capture ได้ครั้งเดียว เท่ากับหรือน้อยกว่ายอดที่อนุมัติ ส่วนที่เหลือคืนวงเงินให้ลูกค้าอัตโนมัติ
Path parameterspath
payment_idstringจำเป็นรหัส payment ที่รอ capture
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
amount_to_captureintegerไม่บังคับยอดที่เก็บ (ไม่ส่ง = เต็มยอด amount_capturable)
line_itemsarray<object>ไม่บังคับรายการสินค้าหลังปรับ (ให้ใบเสร็จตรงกับยอด)
ผลลัพธ์
- 200เก็บแล้ว 451000 สตางค์ — คืนวงเงิน 89000 สตางค์ให้ลูกค้า
- 409
amount_exceeds_authorizedยอด capture เกินยอดที่อนุมัติ - 409
authorization_expiredการอนุมัติวงเงินหมดอายุ - 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ต้อง capture ภายใน 7 วัน (capture_before) ไม่งั้นระบบยกเลิกเอง (cancellation_reason = authorization_expired) และยิง payment.canceled
- ค่าธรรมเนียมคิดจากยอดที่ capture จริง ไม่ใช่ยอด authorize
curl -X POST "https://sandbox.api.paynara.example/v1/payments/pay_3Rs4Yt/capture" \
-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 '{
"amount_to_capture": 451000,
"line_items": [
{
"sku": "GIFT-9",
"name": "ชุดของขวัญขนมไทย 9 ช่อง",
"quantity": 5,
"unit_amount": 89000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
]
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments/pay_3Rs4Yt/capture', {
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({
"amount_to_capture": 451000,
"line_items": [
{
"sku": "GIFT-9",
"name": "ชุดของขวัญขนมไทย 9 ช่อง",
"quantity": 5,
"unit_amount": 89000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
]
}),
});
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/payments/pay_3Rs4Yt/capture",
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={
"amount_to_capture": 451000,
"line_items": [
{
"sku": "GIFT-9",
"name": "ชุดของขวัญขนมไทย 9 ช่อง",
"quantity": 5,
"unit_amount": 89000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
]
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "pay_3Rs4Yt",
"object": "payment",
"amount": 540000,
"amount_capturable": 0,
"amount_received": 451000,
"currency": "THB",
"status": "succeeded",
"capture_method": "manual",
"method": "card",
"method_details": {
"card": {
"brand": "mastercard",
"last4": "0008",
"country": "TH",
"bin": "510000",
"funding": "debit",
"three_d_secure": {
"result": "authenticated",
"version": "2.2.0"
},
"authorization_code": "M10584"
}
},
"order_ref": "ORD-2610-0154",
"created": "2026-10-12T10:26:08+07:00",
"livemode": false,
"amount_released": 89000,
"fee": {
"amount": 11952,
"vat": 837,
"rate": "2.65%"
},
"net": 438211,
"captured_at": "2026-10-14T09:05:12+07:00"
}{
"error": {
"code": "amount_exceeds_authorized",
"message": "ยอด capture เกินยอดที่อนุมัติ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_exceeds_authorized"
}
}{
"error": {
"code": "authorization_expired",
"message": "การอนุมัติวงเงินหมดอายุ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#authorization_expired"
}
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"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"
}
}ยกเลิก payment (void)
POST/v1/payments/{payment_id}/cancel
ยกเลิกรายการที่ยังไม่เก็บเงิน (requires_payment_method, requires_confirmation, requires_action, requires_capture) — ไม่มีค่าธรรมเนียม · รายการที่ succeeded แล้วต้องใช้การคืนเงิน (หน้า Refund)
Path parameterspath
payment_idstringจำเป็นรหัส payment
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
cancellation_reasonstringไม่บังคับเหตุผล
ผลลัพธ์
- 200ยกเลิกแล้ว (requires_capture จะคืนวงเงินให้ลูกค้าภายใน 1–3 วัน)
- 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- payment ที่ processing ยกเลิกไม่ได้ (409) — รอผลก่อน ถ้าสำเร็จให้คืนเงินแทน
- QR PromptPay ที่ยกเลิกแล้ว ถ้าลูกค้าสแกนภาพเก่า ธนาคารจะปฏิเสธ
curl -X POST "https://sandbox.api.paynara.example/v1/payments/pay_3Vw2Ab/cancel" \
-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 '{
"cancellation_reason": "requested_by_customer"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments/pay_3Vw2Ab/cancel', {
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({
"cancellation_reason": "requested_by_customer"
}),
});
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/payments/pay_3Vw2Ab/cancel",
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={
"cancellation_reason": "requested_by_customer"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "pay_3Vw2Ab",
"object": "payment",
"amount": 22000,
"status": "canceled",
"method": "promptpay",
"order_ref": "ORD-2610-0157",
"canceled_at": "2026-10-12T10:58:02+07:00",
"cancellation_reason": "requested_by_customer",
"livemode": false
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"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"
}
}รายการ payment
ค้นหาและแบ่งหน้าแบบ cursor — เรียงจากใหม่ไปเก่าเป็นค่าเริ่มต้น · กรองตามสถานะ ช่องทาง ลูกค้า เลขคำสั่งซื้อ และช่วงเวลา
Query parametersquery
limitintegerไม่บังคับจำนวนรายการต่อหน้า
starting_afterstringไม่บังคับcursor — id ของรายการสุดท้ายในหน้าก่อน (ไปหน้าถัดไป)
ending_beforestringไม่บังคับcursor — id ของรายการแรกในหน้าปัจจุบัน (ย้อนกลับ) · ห้ามส่งพร้อม starting_after
statusstringไม่บังคับกรองสถานะ (คั่นด้วย , ได้)
methodstringไม่บังคับกรองช่องทาง
customerstringไม่บังคับกรองลูกค้า
order_refstringไม่บังคับค้นเลขคำสั่งซื้อ (ตรงทั้งคำ)
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หน้าแรก 20 รายการ (ตัวอย่างย่อ 2 รายการ)
- 400
cursor_invalidcursor ของการแบ่งหน้าไม่ถูกต้อง - 400
date_range_invalidช่วงวันที่ไม่ถูกต้อง - 400
parameter_invalidค่าฟิลด์ไม่ถูกต้อง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ใช้ next_cursor เป็น starting_after ของคำขอถัดไปจน has_more = false
- ข้อมูลย้อนหลังเกิน 92 วันใช้ POST /v1/reports (หน้า Transaction)
curl -X GET "https://sandbox.api.paynara.example/v1/payments?limit=20&status=succeeded&customer=cus_Or7k2&created[gte]=2026-10-12T00%3A00%3A00%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/payments?limit=20&status=succeeded&customer=cus_Or7k2&created[gte]=2026-10-12T00%3A00%3A00%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/payments?limit=20&status=succeeded&customer=cus_Or7k2&created[gte]=2026-10-12T00%3A00%3A00%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/payments",
"has_more": true,
"data": [
{
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"status": "succeeded",
"method": "card",
"order_ref": "ORD-2610-0153",
"created": "2026-10-12T10:13:05+07:00"
},
{
"id": "pay_3Pq9Xs",
"object": "payment",
"amount": 24000,
"status": "succeeded",
"method": "promptpay",
"order_ref": "ORD-2610-0152",
"created": "2026-10-12T09:38:40+07:00"
}
],
"next_cursor": "pay_3Pq9Xs"
}{
"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": "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"
}
}ออก QR PromptPay ใหม่
POST/v1/payments/{payment_id}/qr
สร้าง QR PromptPay ใบใหม่ให้ payment เดิม (method = promptpay) เมื่อ QR เก่าหมดอายุหรือลูกค้าขอใหม่ — QR เก่าถูกยกเลิกทันที เลข payment และ order_ref คงเดิม
Path parameterspath
payment_idstringจำเป็นรหัส payment ที่ใช้ PromptPay
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
expires_inintegerไม่บังคับอายุ QR (วินาที)
formatstringไม่บังคับรูปแบบที่ต้องการ (payload = ข้อความ EMVCo ให้สร้างภาพเอง)
ผลลัพธ์
- 201QR ใบใหม่
- 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 400
method_not_enabledช่องทางนี้ยังไม่เปิดให้ร้าน - 410
qr_expiredQR หมดอายุ - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- QR ฝังยอดและเลขอ้างอิง (ref1 = order_ref, ref2 = payment id) — ลูกค้าแก้ยอดไม่ได้
- ภาพ PNG มีอายุเท่ากับ QR · แสดงนับถอยหลังจาก expires_at (เวลาฝั่งเซิร์ฟเวอร์ ไม่ใช่นาฬิกาเครื่องลูกค้า)
curl -X POST "https://sandbox.api.paynara.example/v1/payments/pay_3Tu7Zv/qr" \
-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 '{
"expires_in": 900,
"format": "png"
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/payments/pay_3Tu7Zv/qr', {
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({
"expires_in": 900,
"format": "png"
}),
});
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/payments/pay_3Tu7Zv/qr",
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={
"expires_in": 900,
"format": "png"
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"object": "promptpay_qr",
"id": "qr_5Gb2Nn",
"payment": "pay_3Tu7Zv",
"amount": 43000,
"currency": "THB",
"payload": "00020101021230550016A00000067701011201150107536000315080214BMP2610015553037645406430.005802TH6304A1C9",
"image_url": "https://files.sandbox.paynara.example/qr/qr_5Gb2Nn.png",
"ref1": "ORD-2610-0155",
"ref2": "pay_3Tu7Zv",
"created": "2026-10-12T11:08:10+07:00",
"expires_at": "2026-10-12T11:23:10+07:00"
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"error": {
"code": "method_not_enabled",
"message": "ช่องทางนี้ยังไม่เปิดให้ร้าน",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#method_not_enabled"
}
}{
"error": {
"code": "qr_expired",
"message": "QR หมดอายุ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#qr_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"
}
}ช่องทางที่ใช้ได้สำหรับยอดนี้
GET/v1/payment-methods/available
ให้หน้าชำระของร้านแสดงเฉพาะช่องทางที่ใช้ได้กับยอดและลูกค้านี้ พร้อมค่าธรรมเนียมที่ร้านจะถูกหัก (ลูกค้าไม่เห็นค่าธรรมเนียม)
Query parametersquery
amountintegerจำเป็นยอด (สตางค์)
customerstringไม่บังคับรหัสลูกค้า (คืนบัตรที่บันทึกไว้ด้วย)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200ช่องทางพร้อมเหตุผลถ้าใช้ไม่ได้
- 400
parameter_missingขาดฟิลด์ที่จำเป็น - 400
amount_too_smallยอดต่ำกว่าขั้นต่ำ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ผลลัพธ์คำนวณตามยอดที่ส่งมา — ถ้าลูกค้าแก้ตะกร้าให้เรียกใหม่ทุกครั้ง (ผ่อน 0% 3/6 เดือน ขั้นต่ำ ฿3,000 · 10 เดือน ขั้นต่ำ ฿5,000)
- fee ในผลลัพธ์เป็นค่าธรรมเนียมที่ร้านถูกหัก ห้ามแสดงให้ลูกค้าเห็น
curl -X GET "https://sandbox.api.paynara.example/v1/payment-methods/available?amount=104000" \
-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/payment-methods/available?amount=104000', {
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/payment-methods/available?amount=104000",
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",
"amount": 104000,
"data": [
{
"method": "promptpay",
"fee_key": "promptpay",
"label": "PromptPay QR",
"available": true,
"reason": null,
"fee_rate": "0.8%",
"fee_estimate": 890
},
{
"method": "card",
"fee_key": "card",
"label": "บัตร VISA / Mastercard ที่ออกในไทย",
"available": true,
"reason": null,
"fee_rate": "2.65%",
"fee_estimate": 2949
},
{
"method": "mobile_banking",
"fee_key": "mobile_banking",
"label": "โมบายแบงก์กิ้ง (เด้งเข้าแอปธนาคาร)",
"available": true,
"reason": null,
"fee_rate": "1.5%",
"fee_estimate": 1669
},
{
"method": "installment",
"fee_key": "installment_3",
"label": "ผ่อน 0% 3 เดือน (ร้านรับภาระดอกเบี้ย)",
"available": false,
"reason": "ยอดต่ำกว่าขั้นต่ำผ่อนชำระ ฿3,000",
"fee_rate": "3.5%",
"fee_estimate": 3895
}
]
}{
"error": {
"code": "parameter_missing",
"message": "ขาดฟิลด์ที่จำเป็น",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_missing"
}
}{
"error": {
"code": "amount_too_small",
"message": "ยอดต่ำกว่าขั้นต่ำ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_too_small"
}
}{
"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"
}
}สร้างหน้าชำระเงินสำเร็จรูป
ทางเลือกที่ไม่ต้องทำหน้าชำระเอง: สร้าง session แล้ว redirect ลูกค้าไปที่ url — PAYNARA แสดงทุกช่องทาง ทำ 3-D Secure/QR ให้ และสร้าง payment ให้อัตโนมัติ
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Idempotency-Keystring · uuidจำเป็นกันรายการซ้ำเมื่อส่งซ้ำ (เช่น เน็ตหลุด) — ใช้ค่าเดิมได้ภายใน 24 ชม.
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
Request bodyapplication/json
currencystringไม่บังคับสกุลเงิน
line_itemsarray<object>จำเป็นรายการสินค้า (เหมือน payment.line_items)
ฟิลด์ย่อยของ
line_items(5)skustringไม่บังคับรหัสสินค้า
namestringไม่บังคับชื่อสินค้า
quantityintegerไม่บังคับจำนวน
unit_amountintegerไม่บังคับราคาต่อหน่วย (สตางค์ รวม VAT)
amountintegerไม่บังคับอ่านอย่างเดียวquantity × unit_amount
allowed_methodsarray<string>ไม่บังคับช่องทางที่แสดงในหน้า (ไม่ส่ง = ทุกช่องทางที่ร้านเปิด)
customerstringไม่บังคับรหัสลูกค้า (ถ้ามี)
customer_emailstring · emailไม่บังคับอีเมลสำหรับส่งใบเสร็จ
localestringไม่บังคับภาษาของหน้า
order_refstringไม่บังคับเลขคำสั่งซื้อของร้าน
success_urlstring · uriจำเป็นกลับมาเมื่อจ่ายสำเร็จ ({CHECKOUT_SESSION_ID} ถูกแทนค่าให้)
cancel_urlstring · uriจำเป็นกลับมาเมื่อลูกค้ากดยกเลิก
brandingobjectไม่บังคับโลโก้/สีของร้านในหน้าชำระ
ฟิลด์ย่อยของ
branding(2)logo_urlstring · uriไม่บังคับโลโก้ (PNG/SVG ≤ 512 KB)
colorstringไม่บังคับสีปุ่มหลัก (hex)
metadataobjectไม่บังคับข้อมูลของร้านเอง key-value (สูงสุด 20 คู่ · key ≤ 40 ตัว · value ≤ 500 ตัว) — ห้ามเก็บข้อมูลบัตร/ข้อมูลอ่อนไหว
expires_inintegerไม่บังคับอายุ session (วินาที)
ผลลัพธ์
- 201session ใหม่ — redirect ไปที่ url
- 400
parameter_missingขาดฟิลด์ที่จำเป็น - 400
amount_too_smallยอดต่ำกว่าขั้นต่ำ - 400
url_invalidURL ปลายทางไม่ถูกต้อง - 409
idempotency_conflictIdempotency-Key ซ้ำแต่ body ต่าง - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- ยอดรวมคำนวณจาก line_items (ไม่ต้องส่ง amount)
- รู้ผลด้วย webhook checkout.session.completed — อย่าใช้การกลับมาที่ success_url เป็นหลักฐานการจ่าย
curl -X POST "https://sandbox.api.paynara.example/v1/checkout-sessions" \
-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 '{
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"expires_in": 3600,
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
}'const API_KEY = process.env.API_KEY; // pn_test_8Qm4ZsT2vXa9Lr
const res = await fetch('https://sandbox.api.paynara.example/v1/checkout-sessions', {
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({
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"expires_in": 3600,
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
}),
});
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/checkout-sessions",
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={
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"expires_in": 3600,
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
}
},
timeout=10,
)
res.raise_for_status()
print(res.json()){
"id": "cs_8Rt3Lp",
"object": "checkout_session",
"url": "https://checkout.sandbox.paynara.example/c/cs_8Rt3Lp",
"status": "open",
"payment_status": "unpaid",
"amount_total": 104000,
"currency": "THB",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"payment": null,
"expires_at": "2026-10-12T11:13:05+07:00",
"branding": {
"logo_url": "https://baanmaeplub.example/logo.png",
"color": "#0f766e"
},
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false
}{
"error": {
"code": "parameter_missing",
"message": "ขาดฟิลด์ที่จำเป็น",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#parameter_missing"
}
}{
"error": {
"code": "amount_too_small",
"message": "ยอดต่ำกว่าขั้นต่ำ",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_too_small"
}
}{
"error": {
"code": "url_invalid",
"message": "URL ปลายทางไม่ถูกต้อง",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#url_invalid"
}
}{
"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"
}
}ดู checkout session
GET/v1/checkout-sessions/{session_id}
อ่านสถานะ session และ payment ที่เกิดขึ้น — ใช้ในหน้า success_url เพื่อแสดงสรุปคำสั่งซื้อ
Path parameterspath
session_idstringจำเป็นรหัส session
Query parametersquery
expand[]array<string>ไม่บังคับขยาย object ที่อ้างถึงให้เป็นข้อมูลเต็ม (payment, line_items)
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200session ที่จ่ายแล้ว
- 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- หน้า success_url ต้องเรียก endpoint นี้จากเซิร์ฟเวอร์ ห้ามเชื่อ query string ที่ส่งกลับมากับ redirect
- ใช้ expand[]=payment เพื่อได้ payment เต็มในคำขอเดียว
curl -X GET "https://sandbox.api.paynara.example/v1/checkout-sessions/cs_8Rt3Lp" \
-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/checkout-sessions/cs_8Rt3Lp', {
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/checkout-sessions/cs_8Rt3Lp",
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": "cs_8Rt3Lp",
"object": "checkout_session",
"url": "https://checkout.sandbox.paynara.example/c/cs_8Rt3Lp",
"status": "complete",
"payment_status": "paid",
"amount_total": 104000,
"currency": "THB",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"payment": "pay_3NqL8k",
"expires_at": "2026-10-12T11:13:05+07:00",
"branding": {
"logo_url": "https://baanmaeplub.example/logo.png",
"color": "#0f766e"
},
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13: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"
}
}ปิด checkout session
POST/v1/checkout-sessions/{session_id}/expire
ปิด session ที่ยัง open ก่อนเวลา (เช่น ลูกค้าแก้ตะกร้า สร้าง session ใหม่แทน) — ลิงก์เดิมจะแสดง "หมดอายุ"
Path parameterspath
session_idstringจำเป็นรหัส session
Headersheader
X-Merchant-Idstringจำเป็นรหัสร้านค้าที่ทำรายการ (บัญชี platform ใช้สลับร้าน · บัญชีร้านเดียวส่งค่าของตัวเอง)
Paynara-Versionstringไม่บังคับเวอร์ชัน API (ไม่ส่ง = เวอร์ชันที่ผูกกับ key)
ผลลัพธ์
- 200ปิดแล้ว
- 409
payment_state_invalidสถานะ payment ไม่อนุญาตการกระทำนี้ - 404
resource_not_foundไม่พบรายการ - 401
authentication_failedAPI key ไม่ถูกต้อง - 403
insufficient_scopekey ไม่มีสิทธิ์ (scope) ที่ต้องใช้ - 429
rate_limitedเรียกเกินโควตา
- session ที่ลูกค้ากำลังทำ 3-D Secure อยู่ปิดไม่ได้ (409) จนกว่าผลจะออก
curl -X POST "https://sandbox.api.paynara.example/v1/checkout-sessions/cs_8Rt3Lp/expire" \
-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/checkout-sessions/cs_8Rt3Lp/expire', {
method: 'POST',
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.post(
"https://sandbox.api.paynara.example/v1/checkout-sessions/cs_8Rt3Lp/expire",
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": "cs_8Rt3Lp",
"object": "checkout_session",
"url": "https://checkout.sandbox.paynara.example/c/cs_8Rt3Lp",
"status": "expired",
"payment_status": "unpaid",
"amount_total": 104000,
"currency": "THB",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"payment": null,
"expires_at": "2026-10-12T10:20:00+07:00",
"branding": {
"logo_url": "https://baanmaeplub.example/logo.png",
"color": "#0f766e"
},
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false
}{
"error": {
"code": "payment_state_invalid",
"message": "สถานะ payment ไม่อนุญาตการกระทำนี้",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#payment_state_invalid"
}
}{
"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 กันประมวลผลซ้ำ
payment.createdสร้าง payment ใหม่
ส่งเมื่อ: หลัง POST /v1/payments หรือ checkout session สร้าง payment
{
"id": "evt_01JB7Q00",
"type": "payment.created",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_payment_method",
"method_details": null,
"next_action": null,
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"updated": "2026-10-12T10:13:05+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}
}payment.requires_actionต้องให้ลูกค้าทำขั้นต่อไป
ส่งเมื่อ: ต้องทำ 3-D Secure / แสดง QR / เปิดแอปธนาคาร
{
"id": "evt_01JB7Q01",
"type": "payment.requires_action",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 0,
"amount_refunded": 0,
"amount_refundable": 0,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "requires_action",
"method_details": {
"card": {
"brand": "visa",
"last4": "0101",
"exp_month": 8,
"exp_year": 2029,
"country": "TH",
"bin": "400000",
"funding": "credit",
"issuer": "ธนาคารสยามรุ่ง (สมมติ)",
"three_d_secure": {
"result": "pending",
"version": "2.2.0"
},
"authorization_code": null
}
},
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": {
"url": "https://3ds.sandbox.paynara.example/auth/ac_6Hs2Pd",
"return_url": "https://baanmaeplub.example/checkout/return"
},
"expires_at": "2026-10-12T10:23:40+07:00"
},
"fee": null,
"net": null,
"risk": null,
"last_error": null,
"updated": "2026-10-12T10:13:40+07:00",
"captured_at": null,
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": null
}
}payment.processingรอผลจากธนาคาร
ส่งเมื่อ: ธนาคารรับเรื่องแล้วแต่ยังไม่ตอบ (มักเกิดกับโมบายแบงก์กิ้ง)
{
"id": "evt_01JB7Q02",
"type": "payment.processing",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3Gh1Un",
"object": "payment",
"status": "processing",
"method": "mobile_banking",
"amount": 30000,
"method_details": {
"mobile_banking": {
"bank": "fsi"
}
}
}
}payment.amount_capturable_updatedมีวงเงินรอ capture
ส่งเมื่อ: payment แบบ manual ได้รับอนุมัติ (status = requires_capture)
{
"id": "evt_01JB7Q03",
"type": "payment.amount_capturable_updated",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3Rs4Yt",
"object": "payment",
"amount": 540000,
"amount_capturable": 540000,
"amount_received": 0,
"currency": "THB",
"status": "requires_capture",
"capture_method": "manual",
"method": "card",
"method_details": {
"card": {
"brand": "mastercard",
"last4": "0008",
"country": "TH",
"bin": "510000",
"funding": "debit",
"three_d_secure": {
"result": "authenticated",
"version": "2.2.0"
},
"authorization_code": "M10584"
}
},
"capture_before": "2026-10-19T10:26:08+07:00",
"order_ref": "ORD-2610-0154",
"created": "2026-10-12T10:26:08+07:00",
"livemode": false
}
}payment.succeededเก็บเงินสำเร็จ
ส่งเมื่อ: status เปลี่ยนเป็น succeeded — ใช้ event นี้ยืนยันคำสั่งซื้อ
{
"id": "evt_01JB7Q04",
"type": "payment.succeeded",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3NqL8k",
"object": "payment",
"amount": 104000,
"amount_capturable": 0,
"amount_received": 104000,
"amount_refunded": 0,
"amount_refundable": 104000,
"currency": "THB",
"capture_method": "automatic",
"method": "card",
"customer": {
"id": "cus_Or7k2",
"email": "ora***@mail.example"
},
"order_ref": "ORD-2610-0153",
"description": "ขนมไทย 3 รายการ + ส่งแช่เย็น (ORD-2610-0153)",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"return_url": "https://baanmaeplub.example/checkout/return",
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false,
"status": "succeeded",
"method_details": {
"card": {
"brand": "visa",
"last4": "0101",
"exp_month": 8,
"exp_year": 2029,
"country": "TH",
"bin": "400000",
"funding": "credit",
"issuer": "ธนาคารสยามรุ่ง (สมมติ)",
"three_d_secure": {
"result": "authenticated",
"version": "2.2.0"
},
"authorization_code": "T48213"
}
},
"next_action": null,
"fee": {
"amount": 2756,
"vat": 193,
"rate": "2.65%",
"fee_key": "card"
},
"net": 101051,
"risk": {
"score": 12,
"decision": "allow"
},
"last_error": null,
"updated": "2026-10-12T10:14:32+07:00",
"captured_at": "2026-10-12T10:14:32+07:00",
"canceled_at": null,
"cancellation_reason": null,
"settlement_id": "stl_20261013"
}
}payment.failedชำระไม่สำเร็จ (สิ้นสุด)
ส่งเมื่อ: ธนาคารปฏิเสธแบบไม่ให้ลองซ้ำ หรือลองครบ 10 ครั้ง
{
"id": "evt_01JB7Q05",
"type": "payment.failed",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3Ab7Qj",
"object": "payment",
"status": "failed",
"amount": 36000,
"method": "card",
"last_error": {
"code": "insufficient_funds",
"decline_code": "insufficient_funds",
"message": "วงเงินไม่พอ กรุณาใช้ช่องทางอื่น"
},
"order_ref": "ORD-2610-0147"
}
}payment.canceledยกเลิกแล้ว
ส่งเมื่อ: สั่ง cancel, QR หมดอายุแล้วร้านไม่ออกใหม่ภายใน 24 ชม., หรือ authorize หมดอายุ 7 วัน
{
"id": "evt_01JB7Q06",
"type": "payment.canceled",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3Lm2Wq",
"object": "payment",
"status": "canceled",
"cancellation_reason": "expired",
"amount": 50000,
"method": "promptpay",
"order_ref": "ORD-2610-0151",
"canceled_at": "2026-10-11T21:25:38+07:00"
}
}payment.qr_expiredQR PromptPay หมดอายุ
ส่งเมื่อ: ครบ expires_in แล้วยังไม่มีการโอน (payment ยังเปิดอยู่ ออก QR ใหม่ได้)
{
"id": "evt_01JB7Q07",
"type": "payment.qr_expired",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "pay_3Tu7Zv",
"object": "payment",
"status": "requires_action",
"qr": {
"id": "qr_5Fa8Lm",
"expires_at": "2026-10-12T11:07:44+07:00"
},
"last_error": {
"code": "qr_expired"
}
}
}checkout.session.completedลูกค้าจ่ายผ่านหน้าสำเร็จรูปแล้ว
ส่งเมื่อ: payment ของ session เป็น succeeded
{
"id": "evt_01JB7Q08",
"type": "checkout.session.completed",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "cs_8Rt3Lp",
"object": "checkout_session",
"url": "https://checkout.sandbox.paynara.example/c/cs_8Rt3Lp",
"status": "complete",
"payment_status": "paid",
"amount_total": 104000,
"currency": "THB",
"line_items": [
{
"sku": "KC-12",
"name": "ขนมชั้นใบเตย (กล่อง 12 ชิ้น)",
"quantity": 2,
"unit_amount": 18000,
"amount": 36000
},
{
"sku": "TY-MIX",
"name": "กล่องรวมทองหยิบ ทองหยอด ฝอยทอง",
"quantity": 1,
"unit_amount": 32000,
"amount": 32000
},
{
"sku": "KN-MG",
"name": "ข้าวเหนียวมะม่วงน้ำดอกไม้",
"quantity": 2,
"unit_amount": 15000,
"amount": 30000
},
{
"sku": "SHIP-COLD",
"name": "ส่งแช่เย็นภายในวัน",
"quantity": 1,
"unit_amount": 6000,
"amount": 6000
}
],
"allowed_methods": [
"promptpay",
"card",
"installment",
"mobile_banking"
],
"customer": "cus_Or7k2",
"customer_email": "ora***@mail.example",
"locale": "th",
"order_ref": "ORD-2610-0153",
"success_url": "https://baanmaeplub.example/checkout/thanks?cs={CHECKOUT_SESSION_ID}",
"cancel_url": "https://baanmaeplub.example/cart",
"payment": "pay_3NqL8k",
"expires_at": "2026-10-12T11:13:05+07:00",
"branding": {
"logo_url": "https://baanmaeplub.example/logo.png",
"color": "#0f766e"
},
"metadata": {
"channel": "web",
"cart_id": "cart_bm_2210"
},
"created": "2026-10-12T10:13:05+07:00",
"livemode": false
}
}checkout.session.expiredsession หมดอายุ
ส่งเมื่อ: ครบ expires_at หรือสั่ง expire — ใช้คืนสต็อกที่จองไว้
{
"id": "evt_01JB7Q09",
"type": "checkout.session.expired",
"created": "2026-10-12T10:00:00+07:00",
"livemode": false,
"data": {
"id": "cs_8Rt3Lp",
"object": "checkout_session",
"status": "expired",
"order_ref": "ORD-2610-0153"
}
}ส่งซ้ำเมื่อปลายทางไม่ตอบ
- 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": "amount_too_small",
"message": "ยอดต่ำกว่าขั้นต่ำ",
"param": "items[0].quantity",
"request_id": "req_8Fq2LmX0",
"doc_url": "https://docs.paynara.example/errors#amount_too_small"
}
}| HTTP | code | ความหมาย | วิธีแก้ |
|---|---|---|---|
| 400 | amount_too_small | ยอดต่ำกว่าขั้นต่ำ ยอดขั้นต่ำ ฿20 (2000 สตางค์) · ผ่อนชำระขั้นต่ำ ฿3,000 | รวมยอดให้ถึงขั้นต่ำ หรือเลือกช่องทางอื่น |
| 400 | amount_too_large | ยอดสูงกว่าเพดาน PromptPay ต่อรายการไม่เกิน ฿200,000 · บัตรไม่เกิน ฿500,000 (ปรับได้ตามสัญญา) | แบ่งชำระหลายรายการ หรือติดต่อเพื่อเพิ่มเพดาน |
| 400 | currency_unsupported | สกุลเงินไม่รองรับ รองรับเฉพาะ THB | ส่ง currency: "THB" |
| 400 | method_not_enabled | ช่องทางนี้ยังไม่เปิดให้ร้าน ร้านยังไม่ได้เปิดช่องทาง (เช่น ผ่อนชำระ) หรือช่องทางไม่รองรับยอดนี้ | เรียก GET /v1/payment-methods/available เพื่อดูช่องทางที่ใช้ได้ |
| 402 | card_declined | บัตรถูกปฏิเสธ ธนาคารผู้ออกบัตรปฏิเสธโดยไม่ระบุเหตุผล (decline_code อยู่ใน payment.last_error) | ให้ลูกค้าใช้บัตรอื่นหรือช่องทางอื่น · ห้ามลองซ้ำอัตโนมัติเกิน 3 ครั้ง |
| 402 | insufficient_funds | วงเงิน/ยอดเงินไม่พอ วงเงินบัตรหรือยอดในบัญชีไม่พอ | แนะนำ PromptPay หรือผ่อนชำระ |
| 402 | expired_card | บัตรหมดอายุ เดือน/ปีหมดอายุผ่านไปแล้ว | ให้ลูกค้ากรอกบัตรใหม่ |
| 402 | incorrect_cvc | CVC ไม่ถูกต้อง รหัสหลังบัตร 3 หลักไม่ตรง | ให้ลูกค้ากรอกใหม่ (ระบบล็อกบัตรชั่วคราวเมื่อผิด 5 ครั้งใน 1 ชม.) |
| 402 | three_d_secure_failed | ยืนยัน 3-D Secure ไม่ผ่าน ลูกค้ายืนยัน OTP ไม่สำเร็จ ปิดหน้าธนาคาร หรือหมดเวลา 10 นาที | สร้างการยืนยันใหม่ด้วย POST …/confirm หรือให้เลือกช่องทางอื่น |
| 409 | payment_state_invalid | สถานะ payment ไม่อนุญาตการกระทำนี้ เช่น capture รายการที่ succeeded แล้ว หรือ cancel รายการที่กำลัง processing | อ่าน status ล่าสุดด้วย GET /v1/payments/{id} ก่อนสั่ง · ดูแผนภาพสถานะในหน้า Payment |
| 409 | amount_exceeds_authorized | ยอด capture เกินยอดที่อนุมัติ amount_to_capture มากกว่า amount_capturable | capture ไม่เกินยอดที่อนุมัติ ถ้าต้องเก็บเพิ่มให้สร้าง payment ใหม่ |
| 409 | authorization_expired | การอนุมัติวงเงินหมดอายุ ไม่ได้ capture ภายใน 7 วัน วงเงินถูกปล่อยคืนแล้ว (payment เป็น canceled) | สร้าง payment ใหม่และให้ลูกค้ายืนยันอีกครั้ง |
| 410 | qr_expired | QR หมดอายุ QR PromptPay ใช้ได้ 15 นาที (ค่าเริ่มต้น) หลังจากนั้นสแกนแล้วธนาคารจะปฏิเสธ | เรียก POST /v1/payments/{id}/qr เพื่อออก QR ใหม่ (id เดิม) |
| 409 | idempotency_conflict | Idempotency-Key ซ้ำแต่ body ต่าง ใช้ Idempotency-Key เดิมภายใน 24 ชม. กับคำขอที่เนื้อหาไม่เหมือนเดิม | สร้าง Idempotency-Key ใหม่ (UUID v4) ต่อ 1 การกระทำ |
| 400 | parameter_missing | ขาดฟิลด์ที่จำเป็น ไม่ได้ส่งฟิลด์ที่ทำเครื่องหมาย "จำเป็น" (ชื่อฟิลด์อยู่ใน error.param) | เพิ่มฟิลด์ตาม error.param แล้วส่งใหม่ |
| 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 สำหรับช่วงยาว |
| 400 | url_invalid | URL ปลายทางไม่ถูกต้อง ต้องเป็น https:// ที่เข้าถึงได้จากอินเทอร์เน็ต ไม่ใช่ localhost/IP ภายใน | ใช้โดเมนที่มี TLS ใช้ได้ (ทดสอบบนเครื่องใช้ CLI ส่งต่อ event) |
| 400 | invalid_request | คำขอไม่ถูกต้อง JSON อ่านไม่ได้ หรือโครงคำขอไม่ตรงกับ schema · ดูฟิลด์ที่ผิดใน error.param | ตรวจ body ตาม schema ของ endpoint และส่ง Content-Type: application/json |
| 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 |
| 403 | livemode_mismatch | ข้อมูล sandbox ปนกับ production อ้าง id ที่สร้างใน sandbox ด้วย live key (หรือกลับกัน) | ใช้ key และ id จากสภาพแวดล้อมเดียวกัน |
| 403 | merchant_not_verified | ร้านค้ายังไม่ผ่าน KYB ร้านที่ยังไม่ผ่านการยืนยันตัวตนใช้ live key รับเงินจริงไม่ได้ | ส่งเอกสาร KYB ให้ครบ (ดูหน้า Verification) แล้วรอผล |
| 404 | resource_not_found | ไม่พบรายการ id ไม่มีอยู่ หรือเป็นของร้านค้าอื่น | ตรวจ id และ X-Merchant-Id |
| 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 | หมายเหตุ |
|---|---|---|---|
| ทุก endpoint ของ Payment (ต่อ key) | 100 ครั้ง/วินาที | 200 | sandbox 25 ครั้ง/วินาที |
| POST /v1/payments · /v1/checkout-sessions | 50 ครั้ง/วินาที | 100 | นับรวมทุกช่องทาง |
| POST …/confirm (ต่อ payment) | 10 ครั้ง/ชม. | — | กันการสุ่มเลขบัตร (card testing) — เกินแล้ว payment เป็น failed |
| POST …/qr (ต่อ payment) | 6 ครั้ง/ชม. | — | ออก QR ใหม่ได้ไม่เกิน 6 ใบ/ชม. |
| GET /v1/payments (list) | 20 ครั้ง/วินาที | — | ดึงจำนวนมากใช้ POST /v1/reports แทน |
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-01payment.qr_expired ยิงซ้ำ 2 ครั้งเมื่อออก QR ใหม่ภายใน 1 วินาทีหลังหมดอายุ — แก้แล้ว
- เพิ่ม
2026-08-01เพิ่ม amount_released ใน payment หลัง capture บางส่วน และ capture_before ใน requires_capture
- เปลี่ยน
2026-08-01next_action.type "display_qr" เปลี่ยนชื่อเป็น "display_promptpay_qr" (เวอร์ชันเก่ายังได้ชื่อเดิม)
- ความปลอดภัย
2025-11-15จำกัด POST …/confirm 10 ครั้ง/ชม./payment เพื่อกันการสุ่มเลขบัตร
- เพิ่ม
2025-11-15POST /v1/checkout-sessions/{id}/expire ปิด session ก่อนเวลา
- เพิ่ม
2025-11-15ผ่อน 0% 10 เดือน (installment_10) ขั้นต่ำ ฿5,000
- เพิ่ม
2025-11-15Checkout Session (หน้าชำระสำเร็จรูป) · GET /v1/payment-methods/available · POST /v1/payments/{id}/qr
- เลิกใช้
2025-11-15ฟิลด์ payment.source (เวอร์ชัน 2024-06-01) เลิกใช้ ใช้ method + method_details แทน — รองรับถึง 31 ธ.ค. 2569
- แก้ไข
2024-06-01payment ที่ 3-D Secure หมดเวลาค้างสถานะ requires_action — ตอนนี้กลับเป็น requires_payment_method ภายใน 10 นาที
- ความปลอดภัย
2024-06-01client_secret คืนเฉพาะตอนสร้างและถูกปิดบังใน log ของแดชบอร์ด
- เพิ่ม
2024-06-01capture_method = manual สำหรับบัตร (authorize 7 วัน)
เครื่องมือ: State machine การชำระเงิน
เลือกช่องทางและวิธี capture แล้วคลิกเหตุการณ์ทีละขั้น — แผนภาพไฮไลต์สถานะปัจจุบัน (กรอบทึบ) และสถานะที่ไปต่อได้ (กรอบประ) · ยกเลิกได้จากทุกสถานะที่ยังไม่เก็บเงิน · ด้านล่างเห็น payment object เปลี่ยนจริงและ webhook ที่ระบบจะยิง · เหตุการณ์ที่ไม่อนุญาตกดได้เพื่อดู error 409 payment_state_invalid
payment object ตอนนี้
{}ลำดับเหตุการณ์ + webhook (ใหม่อยู่บน)
เครื่องมือ: QR PromptPay จำลอง
QR ของคำสั่งซื้อ ORD-2610-0155 (payment pay_3Tu7Zv) อายุ 15 นาที — เร่งเวลาเพื่อดูตอนหมดอายุ แล้วออก QR ใหม่ (สูงสุด 6 ใบ/ชม. ใบที่ 7 ได้ 429) หรือจำลองให้ลูกค้าสแกนจ่ายทั้งก่อนและหลังหมดอายุ · ลวดลาย QR เป็นภาพจำลอง สแกนไม่ได้
ร้านขนมบ้านแม่ปลื้ม
PromptPay QR
฿430.00
ref1 ORD-2610-0155 · qr_5Fa8Lm
หมดอายุใน 15:00
QR ที่ออกแล้ว 1/6
{}