ตรวจสอบสลิปด้วย URL
ตรวจสอบสลิปธนาคารด้วย URL ของรูปภาพ
Endpoint
http
POST /verifyURL เต็ม: https://developer.easyslip.com/api/v1/verify
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest
พารามิเตอร์
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
url | string | ใช่ | URL ของรูปสลิป (สูงสุด 2048 ตัวอักษร) |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ |
ข้อกำหนด URL
| ข้อกำหนด | ค่า |
|---|---|
| Protocol | HTTP หรือ HTTPS เท่านั้น |
| ความยาวสูงสุด | 2048 ตัวอักษร |
| Content type | ต้องเป็นรูปภาพที่ถูกต้อง |
| ขนาดสูงสุด | 4 MB |
| ข้อจำกัด IP | ไม่รองรับ Private/Internal IP |
URL ที่ถูกบล็อก
ไม่อนุญาตสิ่งต่อไปนี้เพื่อความปลอดภัย:
- Private IP ranges:
10.x.x.x,172.16-31.x.x,192.168.x.x - Localhost:
127.0.0.1,localhost - Link-local:
169.254.x.x - Non-HTTP protocols:
file://,ftp://, ฯลฯ
Type Definitions
typescript
// Request
interface VerifyByUrlRequest {
url: string; // สูงสุด 2048 ตัวอักษร
checkDuplicate?: boolean;
}
// Response
interface VerifyResponse {
status: 200;
data: SlipData;
}
interface SlipData {
payload: string;
transRef: string;
date: string; // ISO 8601
countryCode: string;
amount: Amount;
fee: number;
ref1: string;
ref2: string;
ref3: string;
sender: Party;
receiver: Party;
}
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 {
status: number;
message: string;
data?: SlipData; // สำหรับกรณีสลิปซ้ำ
}ตัวอย่าง
bash
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/slips/slip-12345.jpg",
"checkDuplicate": true
}'javascript
const verifyByUrl = async (url, options = {}) => {
const response = await fetch('https://developer.easyslip.com/api/v1/verify', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url,
checkDuplicate: options.checkDuplicate
})
});
const result = await response.json();
if (result.status !== 200) {
throw new Error(result.message);
}
return result.data;
};
// การใช้งาน
const slip = await verifyByUrl('https://example.com/slips/slip-12345.jpg', {
checkDuplicate: true
});
console.log('จำนวนเงิน:', slip.amount.amount);php
function verifyByUrl(string $url, 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',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'url' => $url,
'checkDuplicate' => $checkDuplicate
])
]);
$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 = verifyByUrl('https://example.com/slips/slip-12345.jpg', true);
echo "จำนวนเงิน: " . $slip['amount']['amount'];python
import requests
import os
def verify_by_url(url: str, check_duplicate: bool = False) -> dict:
response = requests.post(
'https://developer.easyslip.com/api/v1/verify',
headers={
'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}',
'Content-Type': 'application/json'
},
json={
'url': url,
'checkDuplicate': check_duplicate
}
)
result = response.json()
if result['status'] != 200:
raise Exception(result['message'])
return result['data']
# การใช้งาน
slip = verify_by_url(
'https://example.com/slips/slip-12345.jpg',
check_duplicate=True
)
print(f"จำนวนเงิน: {slip['amount']['amount']}")Response
สำเร็จ (200)
json
{
"status": 200,
"data": {
"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": "นาย รับเงิน ทดสอบ" } }
}
}
}Error Responses
URL ไม่ถูกต้อง (400)
json
{
"status": 400,
"message": "invalid_url"
}Protocol URL ไม่อนุญาต (400)
json
{
"status": 400,
"message": "url_protocol_not_allowed"
}IP Range ไม่ถูกต้อง (400)
json
{
"status": 400,
"message": "url_invalid_ip_range"
}เข้าถึง URL ไม่ได้ (400)
json
{
"status": 400,
"message": "image_url_unreachable"
}รูปภาพใหญ่เกินไป (400)
json
{
"status": 400,
"message": "image_size_too_large"
}หมายเหตุ
- ใช้ HTTPS URL เพื่อความปลอดภัย
- URL ต้องเข้าถึงได้สาธารณะ
- Server ควรส่ง Content-Type ที่ถูกต้อง
- API มี timeout 10 วินาทีสำหรับดึง URL
- โฮสต์รูปบน CDN เพื่อความเสถียร