Skip to content

ดูสถานะ Job ​

ดึงสถานะปัจจุบัน (และผลลัพธ์เมื่อเสร็จ) ของ async verify job ด้วย jobId ใช้เมื่อรับ webhook ไม่ได้ หรือเพื่อกระทบยอดผลที่อาจพลาดไป

Endpoint ​

http
GET /verify/bank/jobs/:jobId

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

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

จำเป็น ใช้ HMAC-SHA256 กับ Branch UUID เป็น X-API-Key ดูคู่มือ Authentication

http
X-API-Key: YOUR_BRANCH_UUID
X-Timestamp: 1700000000
X-Nonce: 550e8400-e29b-41d4-a716-446655440000
X-Signature: HMAC_SHA256_SIGNATURE

Request ​

Path Parameters ​

พารามิเตอร์ประเภทจำเป็นคำอธิบาย
jobIdstringใช่UUID ที่คืนจาก POST /verify/bank/async หรือ /batch

Job อ่านได้เฉพาะ branch ที่สร้างเท่านั้น jobId ของ branch อื่นจะได้ 404 JOB_NOT_FOUND เหมือนกับที่ไม่มีอยู่จริง (ป้องกันการไล่เดา job ID ข้าม branch)

Type Definitions ​

typescript
type JobStatus = 'queued' | 'processing' | 'retrying' | 'done' | 'failed';

// Response
interface JobStatusResponse {
  success: true;
  data: {
    jobId: string;
    status: JobStatus;
    attempts: number;         // จำนวนครั้งที่พยายามประมวลผล
    batchId?: string | null;  // มีเมื่อ job ถูกส่งผ่าน /batch
    result?: { status: 'success'; data: VerifyBankData } | { status: 'not_found'; data: unknown };
    error?: unknown;          // มีเมื่อ status เป็น 'failed'
  };
  message: string;
}

Job record เก็บไว้ 7 วัน หลังสร้าง จากนั้นจะหมดอายุ

ผลลัพธ์ที่จบแล้ว ​

  • done คือจบการตรวจ โดย result.status เป็น success หรือ not_found ตรวจซ้ำครบแล้วยังไม่พบไม่ใช่ job ล้มเหลว
  • failed คือตรวจต่อไม่ได้ ดู error.code/message เช่นเดียวกับ failure callback ส่ง callback สำเร็จแล้วสถานะยังเป็น failed ไม่เปลี่ยนเป็น done
  • ส่ง callback ไม่สำเร็จจะคง error ต้นเหตุ และเพิ่ม error.webhook: "failed" พร้อมรายละเอียด งาน done ก็มี error เฉพาะการส่ง callback ได้
  • result ครอบ { status, data } โดยสลิปที่ตรวจแล้วอยู่ใน result.data

ตัวอย่าง ​

bash
curl https://api-partners.easyslip.com/v2/verify/bank/jobs/550e8400-e29b-41d4-a716-446655440000 \
  -H "X-API-Key: YOUR_BRANCH_UUID" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}"
javascript
const getJob = async (jobId) => {
  const path = `/verify/bank/jobs/${jobId}`;
  const response = await fetch(`https://api-partners.easyslip.com/v2${path}`, {
    method: 'GET',
    headers: signRequest({ method: 'GET', path, apiKey: 'YOUR_BRANCH_UUID', secretKey: 'YOUR_SECRET_KEY' })
  });

  const result = await response.json();
  if (!result.success) throw new Error(result.error.message);

  return result.data; // { jobId, status, result?, ... }
};

// poll จนกว่า job จะเสร็จ
const waitForJob = async (jobId, { intervalMs = 2000, timeoutMs = 60000 } = {}) => {
  const deadline = Date.now() + timeoutMs;
  while (Date.now() < deadline) {
    const job = await getJob(jobId);
    if (job.status === 'done') return job.result;
    if (job.status === 'failed') throw new Error('Verification failed');
    await new Promise((r) => setTimeout(r, intervalMs));
  }
  throw new Error('Timed out waiting for job');
};
typescript
type JobStatus = 'queued' | 'processing' | 'retrying' | 'done' | 'failed';

async function getJob(jobId: string) {
  const path = `/verify/bank/jobs/${jobId}`;
  const response = await fetch(`https://api-partners.easyslip.com/v2${path}`, {
    method: 'GET',
    headers: signRequest({ method: 'GET', path, apiKey: process.env.EASYSLIP_API_KEY!, secretKey: process.env.EASYSLIP_SECRET_KEY! })
  });

  const result = await response.json();
  if (!result.success) throw new Error(result.error?.message || 'Failed to fetch job');

  return result.data as { jobId: string; status: JobStatus; attempts: number; result?: unknown; error?: unknown };
}
php
function getJob(string $jobId): array
{
    $path = "/verify/bank/jobs/{$jobId}";

    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => "https://api-partners.easyslip.com/v2{$path}",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            // ใช้ helper signRequest() - ดูคู่มือ Authentication
        ]
    ]);

    $response = curl_exec($ch);
    curl_close($ch);

    $result = json_decode($response, true);
    if (!$result['success']) {
        throw new Exception($result['error']['message']);
    }

    return $result['data'];
}
python
import requests
import os

def get_job(job_id: str) -> dict:
    path = f'/verify/bank/jobs/{job_id}'
    response = requests.get(
        f'https://api-partners.easyslip.com/v2{path}',
        headers=sign_request('GET', path, None, os.environ['EASYSLIP_API_KEY'], os.environ['EASYSLIP_SECRET_KEY'])
    )

    result = response.json()
    if not result['success']:
        raise Exception(result['error']['message'])

    return result['data']

Response ​

Queued / Processing (200) ​

json
{
  "success": true,
  "data": {
    "jobId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "processing",
    "attempts": 1
  },
  "message": "OK"
}

Done (200) ​

json
{
  "success": true,
  "data": {
    "jobId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "done",
    "attempts": 1,
    "result": {
      "status": "success",
      "data": {
        "isDuplicate": false,
        "rawSlip": {
          "transRef": "68370160657749I376388B35",
          "amount": {
            "amount": 1500,
            "local": {
              "amount": 1500,
              "currency": "THB"
            }
          },
          "sender": {
            "bank": {
              "id": "004",
              "short": "KBANK"
            }
          },
          "receiver": {
            "bank": {
              "id": "014",
              "short": "SCB"
            }
          }
        }
      }
    }
  },
  "message": "OK"
}

เมื่อตรวจสำเร็จ result.data มี shape เดียวกับ data ของ POST /verify/bank แบบ synchronous

Failed (200) ​

json
{
  "success": true,
  "data": {
    "jobId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "failed",
    "attempts": 3,
    "error": {
      "code": "API_SERVER_ERROR",
      "message": "External API service is temporarily unavailable"
    }
  },
  "message": "OK"
}

Error Responses ​

ไม่พบ Job (404) ​

json
{
  "success": false,
  "error": {
    "code": "JOB_NOT_FOUND",
    "message": "Job 550e8400-e29b-41d4-a716-446655440000 not found"
  }
}

ได้ทั้งเมื่อ jobId ไม่มีอยู่จริง และเมื่อเป็นของ branch อื่น

หมายเหตุ ​

  • ค่าสถานะ: queued → processing → done; ถ้าล้มเหลวชั่วคราวจะเป็น retrying และถ้าล้มเหลวถาวรจะจบที่ failed
  • แนะนำให้ใช้webhook เป็นหลัก ใช้ polling เป็นทางเลือกสำรองหรือกระทบยอด
  • Job record หมดอายุ 7 วัน หลังสร้าง

Bank Slip Verification API for Thai Banking