ข้ามไปยังเนื้อหาหลัก
กลับไปหน้า API Docs
POST/api/v2/payins

สร้างรายการรับเงินอัตโนมัติ (POST /v2/payins)

ENDPOINT OVERVIEW

เรียก POST /api/v2/payins พร้อมลายเซ็น HMAC-SHA256 บน Path /v2/payins (ตัดคำนำหน้า /api ออกก่อนคำนวณ) ระบบจะคัดเลือกช่องทางรับเงินที่พร้อมที่สุดและส่งคืน paypage_url ทันที ทั้งนี้ตัวอย่างโค้ดใช้ api.example.com ส่วน Endpoint จริงจะออกให้เมื่อผ่านขั้นตอน Onboarding

กฎสำคัญของโปรโตคอล

  • ต้องแนบ X-API-Key, X-Timestamp และ X-Signature (HMAC-SHA256) โดยตัดคำนำหน้า /api ออกก่อนคำนวณลายเซ็น จึงต้องเซ็นบน /v2/payins
  • ใช้ฟิลด์มาตรฐาน merchant_ref_id, currency_code, request_amount, customer_id (UUIDv7), customer_account_id และ redirect_url
  • อ่านสถานะย้อนหลังได้ตลอดเวลาผ่าน GET /api/v1/payins/{id} หรือยกเลิกรายการที่ยังค้างผ่าน POST /api/v2/payins/{id}/cancel

ตัวอย่าง Request

# Note: api.example.com is a placeholder — your Sandbox & Production endpoints are issued at onboarding.
# Middleware strips /api before verifying, so compute X-Signature over /v2/payins.
curl -X POST https://api.example.com/api/v2/payins \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <your-api-key>" \
  -H "X-Timestamp: <unix-timestamp>" \
  -H "X-Signature: <hmac-sha256-of-path>" \
  -d '{
    "merchant_ref_id": "unique-order-ref-id-2025001",
    "currency_code": "THB",
    "request_amount": 1000,
    "customer_id": "0198cbc6-fd02-7459-a671-78c306d0a1ad",
    "customer_account_id": "0198cbc7-35ec-7c8c-8994-d3ac3e7f5255",
    "redirect_url": "https://merchant.example.com/payment/success"
  }'

ตัวอย่าง JSON Response

{
  "id": "0198cbff-db9b-7b6a-9f82-6a55fdfb6575",
  "merchant_ref_id": "unique-order-ref-id-2025001",
  "status": "pending",
  "request_amount": 1000,
  "paypage_url": "https://pay.example.com/pay/0198cbff-db9b-7b6a-9f82-6a55fdfb6575"
}