ตรวจสอบด้วย Payload
ตรวจสอบสลิปธนาคารด้วยข้อมูล QR Code Payload
Endpoint
http
POST /verify/bankURL เต็ม: https://api.easyslip.com/v2/verify/bank
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest
พารามิเตอร์
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
payload | string | ใช่ | QR Code Payload (1-128 ตัวอักษร) |
remark | string | ไม่ | หมายเหตุ (1-255 ตัวอักษร) |
matchAccount | boolean | ไม่ | จับคู่ผู้รับกับบัญชีที่ลงทะเบียน |
matchAmount | number | ไม่ | จำนวนเงินที่คาดหวัง |
checkDuplicate | boolean | ไม่ | ตรวจสอบสลิปซ้ำ (ค่าเริ่มต้น: false) |
Request Body
json
{
"payload": "00000000000000000000000000000000000000000000000",
"remark": "Order #12345",
"matchAccount": true,
"matchAmount": 1500.00,
"checkDuplicate": true
}Type Definitions
typescript
// Request
interface VerifyByPayloadRequest {
payload: string; // 1-128 ตัวอักษร
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" \
-H "Content-Type: application/json" \
-d '{
"payload": "00000000000000000000000000000000000000000000000",
"checkDuplicate": true
}'javascript
const verifyByPayload = async (payload, options = {}) => {
const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ payload, ...options })
});
const result = await response.json();
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
};
// การใช้งาน
const slip = await verifyByPayload('00000000000000000000000000000000000000000000000', {
checkDuplicate: true,
matchAmount: 1500.00
});
console.log('จำนวนเงิน:', slip.rawSlip.amount.amount);
console.log('ผู้โอน:', slip.rawSlip.sender.account.name.th);php
function verifyByPayload(string $payload, array $options = []): array
{
$apiKey = getenv('EASYSLIP_API_KEY');
$data = array_merge(['payload' => $payload], $options);
$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,
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$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 = verifyByPayload('00000000000000000000000000000000000000000000000', [
'checkDuplicate' => true
]);
echo "จำนวนเงิน: " . $slip['rawSlip']['amount']['amount'];python
import requests
import os
def verify_by_payload(payload: str, **options) -> dict:
response = requests.post(
'https://api.easyslip.com/v2/verify/bank',
headers={
'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}',
'Content-Type': 'application/json'
},
json={'payload': payload, **options}
)
result = response.json()
if not result['success']:
raise Exception(result['error']['message'])
return result['data']
# การใช้งาน
slip = verify_by_payload(
'00000000000000000000000000000000000000000000000',
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",
"countryCode": "TH",
"amount": {
"amount": 1500.00,
"local": {
"amount": 1500.00,
"currency": "THB"
}
},
"fee": 0,
"sender": {
"bank": {
"id": "004",
"name": "กสิกรไทย",
"short": "KBANK"
},
"account": {
"name": {
"th": "นาย ผู้โอน ทดสอบ",
"en": "MR. SENDER TEST"
},
"bank": {
"type": "BANKAC",
"account": "123-4-xxxxx-5"
}
}
},
"receiver": {
"bank": {
"id": "014",
"name": "ไทยพาณิชย์",
"short": "SCB"
},
"account": {
"name": {
"th": "นาย รับเงิน ทดสอบ"
},
"bank": {
"type": "BANKAC",
"account": "xxx-x-x5678-x"
}
}
}
}
},
"message": "Bank slip verified successfully"
}Error Responses
Payload ไม่ถูกต้อง (400)
json
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid payload format"
}
}ไม่พบสลิป (404)
json
{
"success": false,
"error": {
"code": "SLIP_NOT_FOUND",
"message": "The slip could not be found or is invalid"
}
}หมายเหตุ
- นี่เป็นวิธีที่เร็วที่สุด (ไม่ต้องประมวลผลรูปภาพ)
- Payload ควรเป็นตัวอักษรและตัวเลข 1-128 ตัวอักษร
- ใช้
checkDuplicate: trueเพื่อป้องกันการเครดิตซ้ำ - ใส่ Order ID ใน
remarkเพื่อการติดตาม