ตรวจสอบ TrueMoney Wallet
ตรวจสอบสลิปการโอนเงิน TrueMoney Wallet ด้วยการอัปโหลดรูปภาพ หรือส่งข้อความใน QR ของสลิป
API อ่าน QR โอนเงิน TrueMoney (P2P) บนสลิปแล้วตรวจกับ TrueMoney โดยตรง ไม่ได้อ่านตัวหนังสือบนสลิป รูปจึงต้องมี QR นี้ ถ้าเป็น QR ของสลิปธนาคารจะได้ invalid_wallet_qr
Endpoint
POST /verify/truewalletURL เต็ม: https://api.thunder.in.th/v1/verify/truewallet
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-dataมีใน v2 แล้ว
การตรวจสอบ TrueMoney Wallet มีให้ใช้งานใน API v2 แล้ว พร้อมฟีเจอร์เพิ่มเติม เช่น Base64, URL, จับคู่บัญชี และตรวจสอบจำนวนเงิน
Request
พารามิเตอร์
ส่ง file หรือ payload อย่างใดอย่างหนึ่งเท่านั้น file ส่งแบบ multipart/form-data ส่วน payload ส่งใน JSON body หรือเป็น form field ก็ได้
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
file | File | อย่างใดอย่างหนึ่ง | ไฟล์รูปสลิป |
payload | string | อย่างใดอย่างหนึ่ง | ข้อความใน QR ของ TrueMoney (1-256 ตัวอักษร) |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ |
ข้อกำหนดรูปภาพ
| ข้อกำหนด | ค่า |
|---|---|
| ขนาดสูงสุด | 4 MB |
| รูปแบบที่รองรับ | JPEG, PNG, GIF, WebP |
| QR Code | ต้องมี QR โอนเงิน TrueMoney (P2P) ที่อ่านได้ |
Type Definitions
// Request: ส่ง file (multipart/form-data) หรือ payload อย่างใดอย่างหนึ่ง
interface VerifyTrueMoneyRequest {
file?: File;
payload?: string; // ข้อความใน QR ของ TrueMoney (1-256 ตัวอักษร)
checkDuplicate?: boolean;
}
// Response
interface VerifyTrueMoneyResponse {
status: 200;
data: TrueMoneySlipData;
}
interface TrueMoneySlipData {
transactionId: string;
date: string; // ISO 8601
amount: number;
sender?: { // มีเมื่อ TrueMoney ส่งเบอร์ผู้โอนมา
phone: string; // เบอร์มือถือปิดบังบางส่วน เช่น 08-xxx-2345
};
receiver?: { // มีเมื่อ TrueMoney ส่งเบอร์ผู้รับมา
phone: string; // เบอร์มือถือปิดบังบางส่วน เช่น 08-xxx-4567
};
}
// Error Response
interface ErrorResponse {
status: number;
message: string;
data?: TrueMoneySlipData; // สำหรับกรณีสลิปซ้ำ
}ตัวอย่าง
curl -X POST https://api.thunder.in.th/v1/verify/truewallet \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/truemoney-slip.jpg" \
-F "checkDuplicate=true"curl -X POST https://api.thunder.in.th/v1/verify/truewallet \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"payload": "TRUEMONEY_QR_TEXT", "checkDuplicate": true}'const verifyTrueMoney = async (file, options = {}) => {
const formData = new FormData();
formData.append('file', file);
if (options.checkDuplicate) {
formData.append('checkDuplicate', 'true');
}
const response = await fetch(
'https://api.thunder.in.th/v1/verify/truewallet',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
}
);
const result = await response.json();
if (result.status !== 200) {
throw new Error(result.message);
}
return result.data;
};
// การใช้งานกับ file input
const fileInput = document.getElementById('slipFile');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
try {
const slip = await verifyTrueMoney(file, { checkDuplicate: true });
console.log('Transaction ID:', slip.transactionId);
console.log('จำนวนเงิน:', slip.amount);
} catch (error) {
console.error('Error:', error.message);
}
});function verifyTrueMoney(string $filePath, bool $checkDuplicate = false): array
{
$apiKey = getenv('THUNDER_API_KEY');
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.thunder.in.th/v1/verify/truewallet',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey
],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile($filePath),
'checkDuplicate' => $checkDuplicate ? 'true' : 'false'
]
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] !== 200) {
throw new Exception($result['message']);
}
return $result['data'];
}
// การใช้งาน
$slip = verifyTrueMoney('/path/to/truemoney-slip.jpg', true);
echo "Transaction ID: " . $slip['transactionId'];
echo "จำนวนเงิน: " . $slip['amount'];import requests
import os
def verify_truemoney(file_path: str, check_duplicate: bool = False) -> dict:
with open(file_path, 'rb') as f:
files = {'file': f}
data = {'checkDuplicate': 'true' if check_duplicate else 'false'}
response = requests.post(
'https://api.thunder.in.th/v1/verify/truewallet',
headers={
'Authorization': f'Bearer {os.environ["THUNDER_API_KEY"]}'
},
files=files,
data=data
)
result = response.json()
if result['status'] != 200:
raise Exception(result['message'])
return result['data']
# การใช้งาน
slip = verify_truemoney('./truemoney-slip.jpg', check_duplicate=True)
print(f"Transaction ID: {slip['transactionId']}")
print(f"จำนวนเงิน: {slip['amount']}")Response
สำเร็จ (200)
{
"status": 200,
"data": {
"transactionId": "12345678901234",
"date": "2024-01-15T14:30:00+07:00",
"amount": 500.00,
"sender": {
"phone": "08-xxx-2345"
},
"receiver": {
"phone": "08-xxx-4567"
}
}
}ฟิลด์ใน Response
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
transactionId | string | รหัสธุรกรรม TrueMoney |
date | string | วันเวลาธุรกรรม (ISO 8601) |
amount | number | จำนวนเงินที่โอน |
sender.phone | string | เบอร์มือถือผู้โอนที่ปิดบังบางส่วน เช่น 08-xxx-2345 |
receiver.phone | string | เบอร์มือถือผู้รับที่ปิดบังบางส่วน เช่น 08-xxx-4567 |
API ส่งข้อมูลที่ TrueMoney ส่งกลับมาจาก QR ของรายการโอน ไม่มีชื่อผู้โอนและผู้รับ sender และ receiver มีแค่เบอร์มือถือที่ปิดบังบางส่วนในรูป 0X-xxx-NNNN และจะมีแต่ละ object ก็ต่อเมื่อ TrueMoney ส่งเบอร์นั้นมา
Error Responses
รูปภาพไม่ถูกต้อง (400)
{
"status": 400,
"message": "invalid_image"
}รูปภาพใหญ่เกินไป (400)
{
"status": 400,
"message": "image_size_too_large"
}ไม่พบ QR ของ TrueMoney (400)
{
"status": 400,
"message": "invalid_wallet_qr"
}ข้อมูลที่ส่งไม่ถูกต้อง (400)
ไม่ได้ส่ง file หรือ payload ส่งมาทั้งคู่ หรือ payload ว่างหรือยาวเกิน 256 ตัวอักษร
{
"status": 400,
"message": "invalid_input"
}ไม่พบสลิป (404)
{
"status": 404,
"message": "slip_not_found"
}สลิปซ้ำ (400)
{
"status": 400,
"message": "duplicate_slip",
"data": {
"transactionId": "12345678901234",
"date": "2024-01-15T14:30:00+07:00",
"amount": 500.00,
"receiver": {
"phone": "08-xxx-4567"
}
}
}TrueMoney ใช้งานไม่ได้ (502/503)
message คือรหัส error เช่น {"status": 503, "message": "wallet_provider_busy"} ให้ลองใหม่ภายหลัง ถ้า Response มี Header Retry-After ให้รออย่างน้อยตามจำนวนวินาทีนั้น
| Status | Message | กรณี |
|---|---|---|
| 503 | wallet_provider_busy | มี Request ไปที่ TrueMoney มากเกินไปในตอนนี้ |
| 503 | wallet_provider_unavailable | TrueMoney ไม่ตอบภายในเวลาที่กำหนด |
| 503 | wallet_provider_not_configured | ระบบฝั่งเรายังไม่ได้ตั้งค่าการตรวจกับ TrueMoney |
| 502 | wallet_provider_invalid_response | TrueMoney ส่งข้อมูลที่ API ใช้ไม่ได้ |
หมายเหตุ
- หักโควต้าสำหรับแต่ละ Request ตรวจสอบ
- สลิปซ้ำจาก Service เดียวกันไม่หักโควต้า
- การโอน TrueMoney มักมีระยะเวลาตรวจสอบสั้นกว่าธนาคาร
- QR Code ต้องมองเห็นได้ชัดเจน
- โฟกัสที่ QR Code เพื่อประมวลผลเร็วขึ้น
- ใช้
checkDuplicate=trueเสมอเพื่อป้องกันการฉ้อโกง
