Skip to content

ตรวจสอบ TrueMoney Wallet ​

ตรวจสอบสลิปการโอนเงิน TrueMoney Wallet ด้วยการอัปโหลดรูปภาพ หรือส่งข้อความใน QR ของสลิป

API อ่าน QR โอนเงิน TrueMoney (P2P) บนสลิปแล้วตรวจกับ TrueMoney โดยตรง ไม่ได้อ่านตัวหนังสือบนสลิป รูปจึงต้องมี QR นี้ ถ้าเป็น QR ของสลิปธนาคารจะได้ invalid_wallet_qr

Endpoint ​

http
POST /verify/truewallet

URL เต็ม: https://api.thunder.in.th/v1/verify/truewallet

การยืนยันตัวตน ​

จำเป็น ดูคู่มือการยืนยันตัวตน

http
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-data

มีใน v2 แล้ว

การตรวจสอบ TrueMoney Wallet มีให้ใช้งานใน API v2 แล้ว พร้อมฟีเจอร์เพิ่มเติม เช่น Base64, URL, จับคู่บัญชี และตรวจสอบจำนวนเงิน

Request ​

พารามิเตอร์ ​

ส่ง file หรือ payload อย่างใดอย่างหนึ่งเท่านั้น file ส่งแบบ multipart/form-data ส่วน payload ส่งใน JSON body หรือเป็น form field ก็ได้

พารามิเตอร์ประเภทจำเป็นคำอธิบาย
fileFileอย่างใดอย่างหนึ่งไฟล์รูปสลิป
payloadstringอย่างใดอย่างหนึ่งข้อความใน QR ของ TrueMoney (1-256 ตัวอักษร)
checkDuplicatebooleanไม่ตรวจสอบสลิปซ้ำ

ข้อกำหนดรูปภาพ ​

ข้อกำหนดค่า
ขนาดสูงสุด4 MB
รูปแบบที่รองรับJPEG, PNG, GIF, WebP
QR Codeต้องมี QR โอนเงิน TrueMoney (P2P) ที่อ่านได้

Type Definitions ​

typescript
// Request: ส่ง file (multipart/form-data) หรือ payload อย่างใดอย่างหนึ่ง
interface VerifyTrueMoneyRequest {
  file?: File;
  payload?: string;              // ข้อความใน QR ของ TrueMoney (1-256 ตัวอักษร)
  checkDuplicate?: boolean;
}

// Response
interface VerifyTrueMoneyResponse {
  status: 200;
  data: TrueMoneySlipData;
}

interface TrueMoneySlipData {
  transactionId: string;
  date: string;                  // ISO 8601
  amount: number;
  sender?: {                 // มีเมื่อ TrueMoney ส่งเบอร์ผู้โอนมา
    phone: string;           // เบอร์มือถือปิดบังบางส่วน เช่น 08-xxx-2345
  };
  receiver?: {               // มีเมื่อ TrueMoney ส่งเบอร์ผู้รับมา
    phone: string;           // เบอร์มือถือปิดบังบางส่วน เช่น 08-xxx-4567
  };
}

// Error Response
interface ErrorResponse {
  status: number;
  message: string;
  data?: TrueMoneySlipData;     // สำหรับกรณีสลิปซ้ำ
}

ตัวอย่าง ​

bash
curl -X POST https://api.thunder.in.th/v1/verify/truewallet \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@/path/to/truemoney-slip.jpg" \
  -F "checkDuplicate=true"
bash
curl -X POST https://api.thunder.in.th/v1/verify/truewallet \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"payload": "TRUEMONEY_QR_TEXT", "checkDuplicate": true}'
javascript
const verifyTrueMoney = async (file, options = {}) => {
  const formData = new FormData();
  formData.append('file', file);

  if (options.checkDuplicate) {
    formData.append('checkDuplicate', 'true');
  }

  const response = await fetch(
    'https://api.thunder.in.th/v1/verify/truewallet',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      },
      body: formData
    }
  );

  const result = await response.json();

  if (result.status !== 200) {
    throw new Error(result.message);
  }

  return result.data;
};

// การใช้งานกับ file input
const fileInput = document.getElementById('slipFile');
fileInput.addEventListener('change', async (e) => {
  const file = e.target.files[0];
  try {
    const slip = await verifyTrueMoney(file, { checkDuplicate: true });
    console.log('Transaction ID:', slip.transactionId);
    console.log('จำนวนเงิน:', slip.amount);
  } catch (error) {
    console.error('Error:', error.message);
  }
});
php
function verifyTrueMoney(string $filePath, bool $checkDuplicate = false): array
{
    $apiKey = getenv('THUNDER_API_KEY');

    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => 'https://api.thunder.in.th/v1/verify/truewallet',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . $apiKey
        ],
        CURLOPT_POSTFIELDS => [
            'file' => new CURLFile($filePath),
            'checkDuplicate' => $checkDuplicate ? 'true' : 'false'
        ]
    ]);

    $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 = verifyTrueMoney('/path/to/truemoney-slip.jpg', true);
echo "Transaction ID: " . $slip['transactionId'];
echo "จำนวนเงิน: " . $slip['amount'];
python
import requests
import os

def verify_truemoney(file_path: str, check_duplicate: bool = False) -> dict:
    with open(file_path, 'rb') as f:
        files = {'file': f}
        data = {'checkDuplicate': 'true' if check_duplicate else 'false'}

        response = requests.post(
            'https://api.thunder.in.th/v1/verify/truewallet',
            headers={
                'Authorization': f'Bearer {os.environ["THUNDER_API_KEY"]}'
            },
            files=files,
            data=data
        )

    result = response.json()

    if result['status'] != 200:
        raise Exception(result['message'])

    return result['data']

# การใช้งาน
slip = verify_truemoney('./truemoney-slip.jpg', check_duplicate=True)
print(f"Transaction ID: {slip['transactionId']}")
print(f"จำนวนเงิน: {slip['amount']}")

Response ​

สำเร็จ (200) ​

json
{
  "status": 200,
  "data": {
    "transactionId": "12345678901234",
    "date": "2024-01-15T14:30:00+07:00",
    "amount": 500.00,
    "sender": {
      "phone": "08-xxx-2345"
    },
    "receiver": {
      "phone": "08-xxx-4567"
    }
  }
}

ฟิลด์ใน Response ​

ฟิลด์ประเภทคำอธิบาย
transactionIdstringรหัสธุรกรรม TrueMoney
datestringวันเวลาธุรกรรม (ISO 8601)
amountnumberจำนวนเงินที่โอน
sender.phonestringเบอร์มือถือผู้โอนที่ปิดบังบางส่วน เช่น 08-xxx-2345
receiver.phonestringเบอร์มือถือผู้รับที่ปิดบังบางส่วน เช่น 08-xxx-4567

API ส่งข้อมูลที่ TrueMoney ส่งกลับมาจาก QR ของรายการโอน ไม่มีชื่อผู้โอนและผู้รับ sender และ receiver มีแค่เบอร์มือถือที่ปิดบังบางส่วนในรูป 0X-xxx-NNNN และจะมีแต่ละ object ก็ต่อเมื่อ TrueMoney ส่งเบอร์นั้นมา

Error Responses ​

รูปภาพไม่ถูกต้อง (400) ​

json
{
  "status": 400,
  "message": "invalid_image"
}

รูปภาพใหญ่เกินไป (400) ​

json
{
  "status": 400,
  "message": "image_size_too_large"
}

ไม่พบ QR ของ TrueMoney (400) ​

json
{
  "status": 400,
  "message": "invalid_wallet_qr"
}

ข้อมูลที่ส่งไม่ถูกต้อง (400) ​

ไม่ได้ส่ง file หรือ payload ส่งมาทั้งคู่ หรือ payload ว่างหรือยาวเกิน 256 ตัวอักษร

json
{
  "status": 400,
  "message": "invalid_input"
}

ไม่พบสลิป (404) ​

json
{
  "status": 404,
  "message": "slip_not_found"
}

สลิปซ้ำ (400) ​

json
{
  "status": 400,
  "message": "duplicate_slip",
  "data": {
    "transactionId": "12345678901234",
    "date": "2024-01-15T14:30:00+07:00",
    "amount": 500.00,
    "receiver": {
      "phone": "08-xxx-4567"
    }
  }
}

TrueMoney ใช้งานไม่ได้ (502/503) ​

message คือรหัส error เช่น {"status": 503, "message": "wallet_provider_busy"} ให้ลองใหม่ภายหลัง ถ้า Response มี Header Retry-After ให้รออย่างน้อยตามจำนวนวินาทีนั้น

StatusMessageกรณี
503wallet_provider_busyมี Request ไปที่ TrueMoney มากเกินไปในตอนนี้
503wallet_provider_unavailableTrueMoney ไม่ตอบภายในเวลาที่กำหนด
503wallet_provider_not_configuredระบบฝั่งเรายังไม่ได้ตั้งค่าการตรวจกับ TrueMoney
502wallet_provider_invalid_responseTrueMoney ส่งข้อมูลที่ API ใช้ไม่ได้

หมายเหตุ ​

  • หักโควต้าสำหรับแต่ละ Request ตรวจสอบ
  • สลิปซ้ำจาก Service เดียวกันไม่หักโควต้า
  • การโอน TrueMoney มักมีระยะเวลาตรวจสอบสั้นกว่าธนาคาร
  • QR Code ต้องมองเห็นได้ชัดเจน
  • โฟกัสที่ QR Code เพื่อประมวลผลเร็วขึ้น
  • ใช้ checkDuplicate=true เสมอเพื่อป้องกันการฉ้อโกง

ที่เกี่ยวข้อง ​

Bank Slip Verification API for Thai Banking