Skip to content

GET /verify/bank/jobs/:jobId

ดึงสถานะและผลลัพธ์ของ Job การตรวจสอบแบบ async ใช้เป็น ทางสำรอง หากคุณพลาด Webhook Callback หรือเพื่อกระทบยอดผลลัพธ์

Endpoint

http
GET /verify/bank/jobs/:jobId

URL เต็ม: https://api.easyslip.com/v2/verify/bank/jobs/{jobId}

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

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

http
Authorization: Bearer YOUR_API_KEY

เฉพาะเจ้าของเท่านั้น

Job อ่านได้เฉพาะ Branch ที่สร้างมัน เท่านั้น การขอ Job ที่เป็นของ Branch อื่นจะได้ 404 JOB_NOT_FOUND (แยกไม่ออกจาก Job ที่ไม่มีอยู่จริง)

Path Parameters

พารามิเตอร์ประเภทคำอธิบาย
jobIdstringjobId ที่ได้จาก /async หรือ /batch

สถานะของ Job

สถานะความหมาย
queuedรับเข้าแล้ว รอประมวลผล
processingกำลังตรวจสอบอยู่
retryingรอตรวจซ้ำ, รอ rate limit หรือรอ billing กลับมา
doneจบการตรวจ: result.status เป็น success หรือ not_found; callback อาจยังรอส่ง
failedตรวจต่อไม่ได้เพราะ error/ข้อจำกัดบริการ ดู error และ failed callback

Type Definitions

typescript
interface JobRecord {
  jobId: string;
  batchId?: string;                  // มีเมื่อ Job เป็นส่วนหนึ่งของ batch
  status: 'queued' | 'processing' | 'retrying' | 'done' | 'failed';
  result?:
    | { status: 'success'; data: VerifyBankData }
    | { status: 'not_found'; data: unknown };
  error?: {
    code?: string;
    message?: string;
    webhook?: 'failed';
    status?: number; // callback HTTP status
    url?: string;
    at?: string;
  };
  attempts: number;                  // metadata ที่เก็บไว้ ไม่ใช่ตัวนับ retry ที่เชื่อถือได้
  createdAt: string;                 // ISO 8601
  updatedAt: string;                 // ISO 8601
}

interface JobResponse {
  success: true;
  data: JobRecord;
}

result ครอบ { status, data } เมื่อสำเร็จ result.data ตรงกับ data ของ POST /verify/bank แบบ sync ถ้าตรวจซ้ำครบแล้วยังไม่พบ จะเป็น done พร้อม result.status: "not_found" ไม่ใช่ failed

ส่ง failure callback สำเร็จแล้ว Job ยังคงเป็น failed ถ้าส่งไม่สำเร็จจะคง error.code/message เดิม และเพิ่ม error.webhook พร้อมรายละเอียดการส่ง งาน done ก็มี error เฉพาะการส่ง callback ได้

ตัวอย่าง

bash
curl https://api.easyslip.com/v2/verify/bank/jobs/3f2b1c8a-9d4e-4f10-b7a2-6c5d4e3f2a1b \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

กำลังประมวลผล (200)

json
{
  "success": true,
  "data": {
    "jobId": "3f2b1c8a-9d4e-4f10-b7a2-6c5d4e3f2a1b",
    "status": "retrying",
    "attempts": 0,
    "createdAt": "2024-01-15T14:30:00+07:00",
    "updatedAt": "2024-01-15T14:31:10+07:00"
  }
}

เสร็จแล้ว (200)

json
{
  "success": true,
  "data": {
    "jobId": "3f2b1c8a-9d4e-4f10-b7a2-6c5d4e3f2a1b",
    "status": "done",
    "result": {
      "status": "success",
      "data": {
        "remark": "Order #1001",
        "isDuplicate": false,
        "amountInSlip": 1500,
        "isAmountMatched": true,
        "rawSlip": {
          "payload": "00000000000000000000000000000000000000",
          "transRef": "68370160657749I376388B35",
          "date": "2024-01-15T14:30:00+07:00",
          "countryCode": "TH",
          "amount": {
            "amount": 1500,
            "local": {
              "amount": 1500,
              "currency": "THB"
            }
          },
          "fee": 0,
          "ref1": "",
          "ref2": "",
          "ref3": "",
          "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"
              }
            },
            "merchantId": null
          }
        }
      }
    },
    "attempts": 0,
    "createdAt": "2024-01-15T14:30:00+07:00",
    "updatedAt": "2024-01-15T14:32:05+07:00"
  }
}

ล้มเหลว (200)

json
{
  "success": true,
  "data": {
    "jobId": "3f2b1c8a-9d4e-4f10-b7a2-6c5d4e3f2a1b",
    "status": "failed",
    "error": {
      "code": "API_SERVER_ERROR",
      "message": "External API service is temporarily unavailable"
    },
    "attempts": 0,
    "createdAt": "2024-01-15T14:30:00+07:00",
    "updatedAt": "2024-01-15T14:35:00+07:00"
  }
}

Error Responses

Job Not Found (404)

คืนค่าสำหรับ Job ที่ไม่รู้จักหรือหมดอายุ หรือ Job ที่เป็นของ Branch อื่น

json
{
  "success": false,
  "error": {
    "code": "JOB_NOT_FOUND",
    "message": "Job 3f2b1c8a-9d4e-4f10-b7a2-6c5d4e3f2a1b not found"
  }
}

หมายเหตุ

  • Job หมดอายุ 7 วันหลังการเขียน job record ครั้งล่าสุด ทุกการอัปเดตสถานะ/ผลการส่งจะต่อ TTL ใหม่ หลังหมดอายุได้ 404
  • ปัจจุบัน worker ยังเก็บ attempts เป็น 0 แม้มี retry ห้ามใช้ค่านี้นับจำนวนครั้งที่เรียกธนาคารหรือตัดสินว่า retry ครบแล้ว ให้ดู status, result และ error
  • processing เป็นสถานะที่นิยามไว้ แต่ worker ปัจจุบันยังไม่ได้เขียน ไม่ควรบังคับว่าต้องเห็นทุกสถานะระหว่างทาง
  • งานที่ไม่ใช่ batch จะไม่มี batchId ใน polling แต่ Webhook ใช้ batchId: null; polling อาจมี metadata เจ้าของเป็นตัวเลข branchId และ serviceId ด้วย
  • แนะนำให้ใช้ Webhook รับผลลัพธ์ ใช้ polling เป็นทางสำรองหรือกระทบยอดเท่านั้น
  • HTTP Response ที่นี่จะเป็น 200 เสมอตราบใดที่ Job ยังอยู่ — ผลของ Job อยู่ในฟิลด์ status/result/error ไม่ใช่ที่ HTTP Status

Bank Slip Verification API for Thai Banking