ตรวจสอบสลิปด้วย Payload
ตรวจสอบสลิปธนาคารด้วยข้อมูล QR Code Payload
Endpoint
http
GET /verifyURL เต็ม: https://developer.easyslip.com/api/v1/verify
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEYRequest
Query Parameters
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
payload | string | ใช่ | QR Code Payload (1-255 ตัวอักษร) |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ |
Type Definitions
typescript
// Request (Query Parameters)
interface VerifyByPayloadRequest {
payload: string; // 1-255 ตัวอักษร
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 GET "https://developer.easyslip.com/api/v1/verify?payload=YOUR_QR_PAYLOAD&checkDuplicate=true" \
-H "Authorization: Bearer YOUR_API_KEY"javascript
const verifyByPayload = async (payload, options = {}) => {
const params = new URLSearchParams({
payload,
...(options.checkDuplicate && { checkDuplicate: 'true' })
});
const response = await fetch(
`https://developer.easyslip.com/api/v1/verify?${params}`,
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}
);
const result = await response.json();
if (result.status !== 200) {
throw new Error(result.message);
}
return result.data;
};
// การใช้งาน
const slip = await verifyByPayload('YOUR_QR_PAYLOAD', { checkDuplicate: true });
console.log('จำนวนเงิน:', slip.amount.amount);
console.log('ผู้โอน:', slip.sender.account.name.th);php
function verifyByPayload(string $payload, bool $checkDuplicate = false): array
{
$apiKey = getenv('EASYSLIP_API_KEY');
$params = http_build_query([
'payload' => $payload,
'checkDuplicate' => $checkDuplicate ? 'true' : 'false'
]);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://developer.easyslip.com/api/v1/verify?' . $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey
]
]);
$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 = verifyByPayload('YOUR_QR_PAYLOAD', true);
echo "จำนวนเงิน: " . $slip['amount']['amount'];python
import requests
import os
def verify_by_payload(payload: str, check_duplicate: bool = False) -> dict:
params = {
'payload': payload,
'checkDuplicate': 'true' if check_duplicate else 'false'
}
response = requests.get(
'https://developer.easyslip.com/api/v1/verify',
headers={
'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}'
},
params=params
)
result = response.json()
if result['status'] != 200:
raise Exception(result['message'])
return result['data']
# การใช้งาน
slip = verify_by_payload('YOUR_QR_PAYLOAD', 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",
"countryCode": "TH",
"amount": {
"amount": 1000,
"local": {
"amount": 0,
"currency": ""
}
},
"fee": 0,
"ref1": "",
"ref2": "",
"ref3": "",
"sender": {
"bank": {
"id": "004",
"name": "กสิกรไทย",
"short": "KBANK"
},
"account": {
"name": {
"th": "นาย ผู้โอน ทดสอบ",
"en": "MR. SENDER TEST"
},
"bank": {
"type": "BANKAC",
"account": "1234xxxx5678"
}
}
},
"receiver": {
"bank": {
"id": "014",
"name": "ไทยพาณิชย์",
"short": "SCB"
},
"account": {
"name": {
"th": "นาย รับเงิน ทดสอบ"
},
"bank": {
"type": "BANKAC",
"account": "12xxxx3456"
}
}
}
}
}Error Responses
Payload ไม่ถูกต้อง (400)
json
{
"status": 400,
"message": "invalid_payload"
}สลิปซ้ำ (400)
json
{
"status": 400,
"message": "duplicate_slip",
"data": { ... }
}ไม่ได้รับอนุญาต (401)
json
{
"status": 401,
"message": "unauthorized"
}แอปพลิเคชันหมดอายุ (403)
json
{
"status": 403,
"message": "application_expired"
}เกินโควต้า (403)
json
{
"status": 403,
"message": "quota_exceeded"
}ไม่พบสลิป (404)
json
{
"status": 404,
"message": "slip_not_found"
}หมายเหตุ
- นี่เป็นวิธีที่เร็วที่สุด (ไม่ต้องประมวลผลรูปภาพ)
- Payload ควรเป็นตัวอักษรและตัวเลข 1-255 ตัวอักษร
- ใช้
checkDuplicate=trueเพื่อป้องกันการเครดิตซ้ำ - สลิปซ้ำจะคืนข้อมูลสลิปเดิมด้วย