ตรวจสอบด้วยรูปภาพ
ตรวจสอบสลิปธนาคารด้วยการอัปโหลดไฟล์รูปภาพ
Endpoint
http
POST /verify/bankURL เต็ม: https://api.easyslip.com/v2/verify/bank
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-dataRequest
พารามิเตอร์
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
image | File | ใช่ | ไฟล์รูปสลิป |
remark | string | ไม่ | หมายเหตุ (1-255 ตัวอักษร) |
matchAccount | boolean | ไม่ | จับคู่ผู้รับกับบัญชีที่ลงทะเบียน |
matchAmount | number | ไม่ | จำนวนเงินที่คาดหวัง |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ |
ข้อกำหนดรูปภาพ
| ข้อกำหนด | ค่า |
|---|---|
| ขนาดสูงสุด | 4 MB (4,194,304 bytes) |
| รูปแบบที่รองรับ | JPEG, PNG, GIF, WebP |
| QR Code | ต้องมองเห็นได้ชัดเจน |
Type Definitions
typescript
// Request (multipart/form-data)
interface VerifyByImageRequest {
image: File; // ไฟล์รูปภาพ
remark?: string; // 1-255 ตัวอักษร
matchAccount?: boolean;
matchAmount?: number;
checkDuplicate?: boolean;
}
// Response
interface VerifyBankResponse {
success: true;
data: VerifyBankData;
message: string;
}
interface VerifyBankData {
remark?: string;
isDuplicate: boolean;
matchedAccount: MatchedAccount | null;
amountInOrder?: number;
amountInSlip: number;
isAmountMatched?: boolean;
rawSlip: RawSlip;
}
interface MatchedAccount {
bank: {
nameTh: string;
nameEn: string;
code: string;
shortCode: string;
};
nameTh: string;
nameEn: string;
type: 'PERSONAL' | 'JURISTIC';
bankNumber: string;
}
interface RawSlip {
payload: string;
transRef: string;
date: string; // ISO 8601
countryCode: string;
amount: Amount;
fee: number;
ref1: string;
ref2: string;
ref3: string;
sender: Party;
receiver: Party & { merchantId?: string | null };
}
interface Amount {
amount: number;
local: {
amount: number;
currency: string;
};
}
interface Party {
bank: {
id: string;
name: string;
short: string;
};
account: {
name: {
th?: string;
en?: string;
};
bank?: {
type: 'BANKAC' | 'TOKEN' | 'DUMMY';
account: string;
};
proxy?: {
type: 'NATID' | 'MSISDN' | 'EWALLETID' | 'EMAIL' | 'BILLERID';
account: string;
};
};
}
// Error Response
interface ErrorResponse {
success: false;
error: {
code: string;
message: string;
};
}ตัวอย่าง
bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@/path/to/slip.jpg" \
-F "checkDuplicate=true"javascript
const verifyByImage = async (file, options = {}) => {
const formData = new FormData();
formData.append('image', file);
Object.entries(options).forEach(([key, value]) => {
formData.append(key, String(value));
});
const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
});
const result = await response.json();
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
};
// การใช้งานกับ file input
const fileInput = document.getElementById('slipImage');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
try {
const slip = await verifyByImage(file, { checkDuplicate: true });
console.log('จำนวนเงิน:', slip.rawSlip.amount.amount);
} catch (error) {
console.error('Error:', error.message);
}
});php
function verifyByImage(string $filePath, array $options = []): array
{
$apiKey = getenv('EASYSLIP_API_KEY');
$postFields = ['image' => new CURLFile($filePath)];
foreach ($options as $key => $value) {
$postFields[$key] = is_bool($value) ? ($value ? 'true' : 'false') : $value;
}
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.easyslip.com/v2/verify/bank',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
CURLOPT_POSTFIELDS => $postFields
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if (!$result['success']) {
throw new Exception($result['error']['message']);
}
return $result['data'];
}
// การใช้งาน
$slip = verifyByImage('/path/to/slip.jpg', ['checkDuplicate' => true]);
echo "จำนวนเงิน: " . $slip['rawSlip']['amount']['amount'];python
import requests
import os
def verify_by_image(file_path: str, **options) -> dict:
with open(file_path, 'rb') as f:
files = {'image': f}
data = {k: str(v).lower() if isinstance(v, bool) else v for k, v in options.items()}
response = requests.post(
'https://api.easyslip.com/v2/verify/bank',
headers={'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}'},
files=files,
data=data
)
result = response.json()
if not result['success']:
raise Exception(result['error']['message'])
return result['data']
# การใช้งาน
slip = verify_by_image('./slip.jpg', checkDuplicate=True)
print(f"จำนวนเงิน: {slip['rawSlip']['amount']['amount']}")Response
สำเร็จ (200)
json
{
"success": true,
"data": {
"isDuplicate": false,
"rawSlip": {
"payload": "00000000000000000000000000000000000000000000000",
"transRef": "68370160657749I376388B35",
"date": "2024-01-15T14:30:00+07:00",
"amount": {
"amount": 1500.00
},
"sender": {
"bank": { "id": "004", "name": "กสิกรไทย", "short": "KBANK" },
"account": { "name": { "th": "นาย ผู้โอน ทดสอบ" } }
},
"receiver": {
"bank": { "id": "014", "name": "ไทยพาณิชย์", "short": "SCB" },
"account": { "name": { "th": "นาย รับเงิน ทดสอบ" } }
}
}
},
"message": "Bank slip verified successfully"
}Error Responses
รูปภาพใหญ่เกินไป (400)
json
{
"success": false,
"error": {
"code": "IMAGE_SIZE_TOO_LARGE",
"message": "Image size exceeds 4MB limit"
}
}รูปแบบไฟล์ไม่ถูกต้อง (400)
json
{
"success": false,
"error": {
"code": "INVALID_IMAGE_FORMAT",
"message": "The file is not a valid image"
}
}ไม่พบ QR Code (404)
json
{
"success": false,
"error": {
"code": "SLIP_NOT_FOUND",
"message": "No QR code found in the image"
}
}หมายเหตุ
- QR Code ต้องมองเห็นได้ชัดเจนและไม่เบลอ
- ครอปรูปให้เห็น QR Code ชัดๆ เพื่อประมวลผลเร็วขึ้น
- บีบอัดรูปขนาดใหญ่ก่อนอัปโหลด
- API จัดการการหมุนรูปอัตโนมัติ