ตรวจสอบ TrueMoney Wallet
ตรวจสอบสลิปการโอนเงิน TrueMoney Wallet ด้วยการอัปโหลดรูปภาพ
Endpoint
http
POST /verify/truewalletURL เต็ม: https://developer.easyslip.com/api/v1/verify/truewallet
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-datav1 เท่านั้น
การตรวจสอบ TrueMoney Wallet มีเฉพาะใน API v1
Request
พารามิเตอร์
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
file | File | ใช่ | ไฟล์รูปสลิป |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ |
ข้อกำหนดรูปภาพ
| ข้อกำหนด | ค่า |
|---|---|
| ขนาดสูงสุด | 4 MB |
| รูปแบบที่รองรับ | JPEG, PNG, GIF, WebP |
| QR Code | ต้องมองเห็นได้ชัดเจน |
Type Definitions
typescript
// Request (multipart/form-data)
interface VerifyTrueMoneyRequest {
file: File;
checkDuplicate?: boolean;
}
// Response
interface VerifyTrueMoneyResponse {
status: 200;
data: TrueMoneySlipData;
}
interface TrueMoneySlipData {
transactionId: string;
date: string; // ISO 8601
amount: number;
sender: {
name: string;
};
receiver: {
name: string;
phone: string; // ปิดบังบางส่วน
};
}
// Error Response
interface ErrorResponse {
status: number;
message: string;
data?: TrueMoneySlipData; // สำหรับกรณีสลิปซ้ำ
}ตัวอย่าง
bash
curl -X POST https://developer.easyslip.com/api/v1/verify/truewallet \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/truemoney-slip.jpg" \
-F "checkDuplicate=true"javascript
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://developer.easyslip.com/api/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);
}
});php
function verifyTrueMoney(string $filePath, bool $checkDuplicate = false): array
{
$apiKey = getenv('EASYSLIP_API_KEY');
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://developer.easyslip.com/api/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'];python
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://developer.easyslip.com/api/v1/verify/truewallet',
headers={
'Authorization': f'Bearer {os.environ["EASYSLIP_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)
json
{
"status": 200,
"data": {
"transactionId": "1234567890123456",
"date": "2024-01-15T14:30:00+07:00",
"amount": 500.00,
"sender": {
"name": "นาย ผู้โอน ทดสอบ"
},
"receiver": {
"name": "นาย รับเงิน ทดสอบ",
"phone": "08x-xxx-xx89"
}
}
}ฟิลด์ใน Response
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
transactionId | string | รหัสธุรกรรม TrueMoney |
date | string | วันเวลาธุรกรรม (ISO 8601) |
amount | number | จำนวนเงินที่โอน |
sender.name | string | ชื่อผู้โอน |
receiver.name | string | ชื่อผู้รับ |
receiver.phone | string | เบอร์โทรผู้รับ (ปิดบังบางส่วน) |
Error Responses
รูปภาพไม่ถูกต้อง (400)
json
{
"status": 400,
"message": "invalid_image"
}รูปภาพใหญ่เกินไป (400)
json
{
"status": 400,
"message": "image_size_too_large"
}ไม่พบ QR Code (404)
json
{
"status": 404,
"message": "qrcode_not_found"
}ไม่พบสลิป (404)
json
{
"status": 404,
"message": "slip_not_found"
}สลิปซ้ำ (400)
json
{
"status": 400,
"message": "duplicate_slip",
"data": { ... }
}กระบวนการตรวจสอบ
- ดึง QR Code: API พยายามอ่าน QR Code จากรูป
- OCR สำรอง: ถ้า QR ล้มเหลว จะใช้ OCR ดึงรหัสธุรกรรม
- ตรวจสอบกับ TrueMoney: ตรวจสอบธุรกรรมกับ Server TrueMoney
- Response: คืนข้อมูลธุรกรรมในรูปแบบที่จัดการแล้ว
หมายเหตุ
- หักโควต้าสำหรับแต่ละ Request ตรวจสอบ
- สลิปซ้ำจาก Service เดียวกันไม่หักโควต้า
- การโอน TrueMoney มักมีระยะเวลาตรวจสอบสั้นกว่าธนาคาร
- QR Code ต้องมองเห็นได้ชัดเจน
- โฟกัสที่ QR Code เพื่อประมวลผลเร็วขึ้น
- ใช้
checkDuplicate=trueเสมอเพื่อป้องกันการฉ้อโกง