⚠️ Timeout: การตรวจสอบอาจใช้เวลาสูงสุด 25 วินาที — ตั้ง HTTP timeout ที่ 30 วินาที ขึ้นไป
POST/api/slip
ตรวจจับจำนวนเงินอัตโนมัติจากรูปสลิป (ช้าที่สุด — ใช้ OCR)
{
"img": "data:image/jpeg;base64,...",
"tos": true,
"privacy": true,
"eula": true
}
POST/api/slip/:amount
ตรวจสอบสลิปโดยระบุจำนวนเงิน (เร็วกว่า — ข้ามขั้นตอน OCR)
{
"img": "data:image/jpeg;base64,...",
"tos": true,
"privacy": true,
"eula": true
}
POST/api/slip/:amount/no_slip
ตรวจสอบผ่านข้อมูล QR Code โดยไม่ใช้รูปภาพ (เร็วที่สุด)
{
"qrcode_data": "004XXXX",
"tos": true,
"privacy": true,
"eula": true
}
Response
{
"message": "Slip processed successfully.",
"fromCache": false,
"data": {
"ref": "202602032204376094",
"date": "2026-03-17T10:00:00.000Z",
"amount": 100.00,
"sender_bank": "004",
"sender_name": "John Doe",
"sender_id": "xxx-x-xxxxx-x",
"receiver_bank": "014",
"receiver_name": "Jane Doe",
"receiver_id": "xxx-x-xxxxx-x"
}
}
Error Codes
| HTTP | slug | สาเหตุ |
| 400 | bad-request | body ไม่ถูกต้อง / ขาด field |
| 400 | terms-not-accepted | ไม่ได้ยอมรับ TOS/Privacy/EULA |
| 400 | invalid-image | base64 image ไม่ถูกต้อง |
| 422 | qr-not-found | หา QR ในรูปไม่เจอ |
| 422 | invalid-qr | QR format ไม่ถูกต้อง |
| 422 | amount-not-found | OCR อ่านจำนวนเงินไม่ได้ |
| 422 | amount-not-verified | OCR อ่านยอดได้ แต่ยอดนั้นตรวจสอบกับธนาคารไม่ผ่าน |
| 422 | invalid-slip-data | ข้อมูลสลิปไม่สมบูรณ์ |
| 404 | slip-not-found | ไม่พบสลิปในระบบธนาคาร |
ตรวจสอบสลิปพร้อมระบุจำนวนเงิน (แนะนำ)
const fs = require('fs');
const imageBase64 = 'data:image/jpeg;base64,'
+ fs.readFileSync('slip.jpg').toString('base64');
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000);
try {
const res = await fetch('/api/slip/100', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
img: imageBase64,
tos: true,
privacy: true,
eula: true,
}),
signal: controller.signal,
});
if (!res.ok) {
const err = await res.json();
throw new Error(err.slug);
}
const data = await res.json();
console.log(data);
} finally {
clearTimeout(timeout);
}
มีแค่ QR data ใช้ no_slip (เร็วสุด)
const res = await fetch('/api/slip/100/no_slip', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
qrcode_data: '00401xxxxxx',
tos: true,
privacy: true,
eula: true,
}),
// ตั้ง timeout ที่ client ด้วยเสมอ
signal: AbortSignal.timeout(30000),
});
ส่งรูปสลิปพร้อมระบุยอด 100 บาท
IMG=$(base64 -w 0 slip.jpg)
curl -X POST https://your-domain/api/slip/100 \
--max-time 30 \
-H "Content-Type: application/json" \
-d "{
\"img\": \"data:image/jpeg;base64,$IMG\",
\"tos\": true,
\"privacy\": true,
\"eula\": true
}"
ส่งแค่ QR data
curl -X POST https://your-domain/api/slip/100/no_slip \
--max-time 30 \
-H "Content-Type: application/json" \
-d '{
"qrcode_data": "00401xxxxxx",
"tos": true,
"privacy": true,
"eula": true
}'
<?php
$imageData = 'data:image/jpeg;base64,'
. base64_encode(file_get_contents('slip.jpg'));
$ch = curl_init('https://your-domain/api/slip/100');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30, // ⚠️ ต้องตั้งด้วยเสมอ
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'img' => $imageData,
'tos' => true,
'privacy' => true,
'eula' => true,
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
$err = json_decode($body, true);
throw new Exception($err['slug']);
}
$result = json_decode($body, true);
var_dump($result);