DUAL API GATEWAY

TH3 ONLINE API Documentation

รองรับทั้ง Modern REST API /api/v1/ และ Legacy Drop-In Adapter /apipp.php

Download OpenAPI 3.1 Spec
1. REST API v1 (แนะนำสำหรับระบบใหม่)

ใช้ Header Authorization: Bearer <token> และ Idempotency-Key: <uuid> บนคำขอ POST

# สร้าง Payment Order
POST https://api.th3online.com/api/v1/orders
Authorization: Bearer <YOUR_SANCTUM_TOKEN>
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
Content-Type: application/json

{
  "con_id": 111185,
  "amount": "500.00",
  "ref1": "ORD-2026-001",
  "include_qr": true
}

# ยืนยันการชำระเงิน (Atomic Claim)
POST https://api.th3online.com/api/v1/orders/{id_pay_or_ulid}/confirm

# ยกเลิกรายการ
POST https://api.th3online.com/api/v1/orders/{id_pay_or_ulid}/cancel
2. Legacy Drop-In Adapter (/apipp.php)

เข้ากันได้ 100% กับหน้าร้านเดิม (เช่น pay.card.in.th) เพียงชี้ URL มาที่ https://api.th3online.com/apipp.php

# create_pay
POST https://api.th3online.com/apipp.php
username=merchant&password=API_PASS&con_id=111185&method=create_pay&amount=500&ref1=ORD123
→ {"status":1,"id_pay":3066017,"amount_check":"50001","pathner_domain":"th3online.com"}

# detail_pay (พร้อม PromptPay QR PNG card)
method=detail_pay&id_pay=3066017

# confirm / cancel
method=confirm&id_pay=3066017
method=cancel&id_pay=3066017
3. Outbound Webhook Callbacks

รองรับทั้ง hmac_sha256 (ค่าเริ่มต้น) และ legacy_md5 พร้อม Retry 5 รอบและ SSRF Guard

// โหมด hmac_sha256 (ตรวจสอบ Replay ภายใน ±300 วินาที)
X-TH3-Event: payment_order.paid
X-TH3-Timestamp: 1764000000
X-TH3-Signature: sha256=HMAC_SHA256(timestamp + "." + rawBody, callback_api_key)

// โหมด legacy_md5 (Form POST)
data={"id_pay":"...","con_id":"...","ref1":"...","amount":500,"amount_check":"50001","status":1}
signature=md5(data + ":" + callback_api_key)
4. Verification Feeds (Push Webhook & LINE Connect)

ส่งยอดโอนเข้าได้ทั้งแบบ JSON ระบุจำนวนเงิน หรือข้อความแจ้งเตือน 12 ธนาคารไทย

# Push Webhook
POST https://api.th3online.com/api/incoming_transfer.php
X-Webhook-Secret: whsec_...
{"message": "เงินเข้าบัญชี x6789-0 จำนวน 500.01 บาท เวลา 10:15 น."}

# LINE Connect Extension
POST https://api.th3online.com/api/line_connect.php
X-Sync-Key: 111185:<token>
{"action":"ingest","line_logged_in":true,"messages":[{"sender":"KBank LIVE","message":"..."}]}