Setup Webhook

ตั้งค่า Webhook URL และการกำหนดค่าต่างๆ เพื่อรับการแจ้งเตือนแบบ Real-time

สำคัญ: Webhook มีโอกาสถูกส่งซ้ำได้ในกรณีที่ไม่ได้รับ HTTP 200 หรือ timeout - กรุณาออกแบบ endpoint ให้รองรับการประมวลผลซ้ำ (idempotent) โดยตรวจสอบ request_id ก่อนประมวลผลทุกครั้ง

Webhook Configuration

URL ที่จะรับ webhook requests จาก Payment

Webhook Request Example

POST https://yourdomain.com/webhook
{
  "Content-Type": "application/json",
  "User-Agent": "Payment-Webhooks/1.0",
  "X-Webhook-Event": "payment.paid",
  "X-Webhook-Timestamp": "1703766330000"
}
{
  "event": "payment.paid",
  "timestamp": 1703766330000,
  "data": {
    "id": "05fc1385-c4cf-4c6a-8cef-a04f63c3d0cb",
    "order_id": "052c381b-1f77-47d7-934c-6326864438e8",
    "payment_status": "PAYMENT_PAID",
    "amount": "2.5",
    "currency": "THB"
  }
}

Test Your Webhook

ทดสอบ webhook endpoint ของคุณก่อนใช้งานจริง

Test Results

Status: Success

Response Time: 245ms

Response Code: 200 OK

Best Practices

สิ่งที่ควรทำ

  • ใช้ HTTPS URL เท่านั้น
  • ตรวจสอบ webhook headers
  • ตอบกลับ 200 OK ภายใน 10 วินาที
  • บันทึก webhook logs

สิ่งที่ไม่ควรทำ

  • ใช้ HTTP URL
  • ไม่ตรวจสอบ headers
  • ประมวลผลนานเกินไป
  • ไม่จัดการ errors