ตัวอย่าง cURL
ตัวอย่างคำสั่ง cURL สำหรับใช้งาน EasySlip API
Authentication
ทุก Request ต้องมี API Key ใน Authorization header:
bash
-H "Authorization: Bearer YOUR_API_KEY"ตรวจสอบสลิปธนาคาร
ตรวจสอบด้วย Payload
bash
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": "00020101021230...",
"checkDuplicate": true
}'ตรวจสอบด้วยรูปภาพ
bash
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/slip.jpg" \
-F "checkDuplicate=true"ตรวจสอบด้วย Base64
bash
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...",
"checkDuplicate": true
}'ตรวจสอบด้วย URL
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.jpg",
"checkDuplicate": true
}'API v2
ตรวจสอบสลิปธนาคาร (v2)
bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": "00020101021230..."
}'ตรวจสอบด้วย Account Matching (v2)
bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": "00020101021230...",
"receiverAccount": "1234567890",
"amount": 1000.00
}'ตรวจสอบด้วยรูปภาพ (v2)
bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/slip.jpg" \
-F "checkDuplicate=true" \
-F "receiverAccount=1234567890"ข้อมูลบัญชี (v2)
bash
curl https://api.easyslip.com/v2/info \
-H "Authorization: Bearer YOUR_API_KEY"ข้อมูลบัญชี (v1)
bash
curl https://developer.easyslip.com/api/v1/me \
-H "Authorization: Bearer YOUR_API_KEY"ตรวจสอบ TrueMoney Wallet
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"สร้าง QR Code
PromptPay QR
bash
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "PROMPTPAY",
"msisdn": "0812345678",
"amount": 100.00
}'PromptPay ด้วยเลขบัตรประชาชน
bash
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "PROMPTPAY",
"natId": "1234567890123",
"amount": 500.00
}'K-Shop QR
bash
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "KSHOP",
"ref1": "ORDER12345",
"amount": 250.00
}'Mae Manee QR
bash
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "MAE_MANEE",
"ref1": "ORDER12345",
"amount": 500.00
}'Tungngern QR
bash
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "TUNGNGERN",
"ref1": "ORDER12345",
"merchantName": "ร้านของฉัน",
"amount": 750.00
}'บันทึก QR Code เป็นไฟล์
bash
# สร้าง QR แล้วบันทึกเป็นไฟล์
curl -X POST https://developer.easyslip.com/api/v1/qr/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "PROMPTPAY",
"msisdn": "0812345678",
"amount": 100.00
}' | jq -r '.data.image' | base64 -d > qr-code.pngใช้งานกับ Environment Variables
bash
# ตั้งค่า API Key
export EASYSLIP_API_KEY="your-api-key-here"
# ตรวจสอบสลิป
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer $EASYSLIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": "00020101021230..."
}'แสดง Response แบบสวยงาม
bash
# ใช้ jq สำหรับ format JSON
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"payload": "00020101021230..."}' | jq .
# ดึงเฉพาะ field ที่ต้องการ
curl -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"payload": "00020101021230..."}' | jq '.data.amount'Debug Mode
bash
# แสดง request และ response headers
curl -v -X POST https://developer.easyslip.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"payload": "00020101021230..."}'ตัวอย่าง Response
สำเร็จ
json
{
"status": 200,
"data": {
"payload": "00020101021230...",
"transRef": "2024011512345678",
"date": "2024-01-15T10:30:00+07:00",
"countryCode": "TH",
"amount": {
"amount": 1000.00,
"local": {
"amount": 1000.00,
"currency": "THB"
}
},
"fee": 0,
"sender": {
"displayName": "นาย ผู้โอน ทดสอบ",
"name": "นาย ผู้โอน ทดสอบ",
"proxy": {
"type": "MSISDN",
"value": "08x-xxx-xx78"
},
"account": {
"type": "BANKAC",
"value": "xxx-x-xx678-x"
}
},
"receiver": {
"displayName": "นาย รับเงิน ทดสอบ",
"name": "นาย รับเงิน ทดสอบ",
"proxy": {
"type": "MSISDN",
"value": "08x-xxx-xx89"
},
"account": {
"type": "BANKAC",
"value": "xxx-x-xx789-x"
}
}
}
}Error
json
{
"status": 400,
"message": "invalid_payload"
}รหัส HTTP Status
| Status | ความหมาย |
|---|---|
| 200 | สำเร็จ |
| 400 | Request ไม่ถูกต้อง |
| 401 | ไม่ได้รับอนุญาต |
| 404 | ไม่พบข้อมูล |
| 429 | เรียกใช้ API มากเกินไป |
| 500 | Server Error |