> For the complete documentation index, see [llms.txt](https://intella.gitbook.io/scan2pay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intella.gitbook.io/scan2pay/api-specification/easycard-api/device-query.md).

# 取得裝置清單

DeviceQuery - 讀取特店帳號下綁定的讀卡機資訊

## Request

### Header

| 欄位          | 必填  | 型別        | 範例              | 描述                   |
| ----------- | --- | --------- | --------------- | -------------------- |
| Method      | YES | String(5) | 31800           | 支付方式, 悠遊卡使用31800     |
| ServiceType | YES | String    | **DeviceQuery** | 服務代碼                 |
| MchId       | YES | String    | Account0001     | 特店帳號                 |
| TradeKey    | YES | String    | sha256...hash   | 交易密碼(sha256編碼)       |
| CreateTime  | YES | String    | 20180101120000  | 建立日期, yyyyMMddHHmmss |

### Data

| 欄位       | 必填  | 型別     | 範例       | 描述           |
| -------- | --- | ------ | -------- | ------------ |
| DeviceId | YES | String | 00000000 | 固定帶入00000000 |
| Retry    | YES | String | 0        | 重試次數, 請帶入0   |

## Response

### Header

| 欄位           | 型別        | 範例              | 說明                                                   |
| ------------ | --------- | --------------- | ---------------------------------------------------- |
| StatusCode   | String(4) | 0000            | [交易結果代碼](/scan2pay/appendix/scan2pay-error-codes.md) |
| StatusDesc   | String    | 交易成功            | 交易結果描述                                               |
| Method       | String(5) | 31800           | 支付方式 (悠遊卡為31800)                                     |
| ServiceType  | String    | **DeviceQuery** | 服務代碼                                                 |
| MchId        | String    | Account0001     | 特店帳號                                                 |
| ResponseTime | String    | 20180101120000  | 回應時間                                                 |

### Data

| 欄位             | 型別         | 範例    | 說明        |
| -------------- | ---------- | ----- | --------- |
| **DeviceList** | JSON Array | 見下表說明 | 裝置(讀卡機)列表 |

#### DeviceList 陣列內容

| 欄位                | 型別     | 範例               | 說明    |
| ----------------- | ------ | ---------------- | ----- |
| type              | String | ezc              |       |
| **ownerDeviceId** | String | 01301234         | 讀卡機機號 |
| batchNumber       | String | 1                |       |
| ezcDongleId       | String | 08100DE0A57E     |       |
| aesKey            | String | f3c013cb...27934 |       |

{% hint style="warning" %}
特店帳號下的讀卡機機號綁定, 由intella管理, 需洽詢intella取得讀卡機以及開通設定
{% endhint %}

{% hint style="info" %}
此API在讀卡機未上線時仍可正確取得回傳資料
{% endhint %}

## API Example

### Request

```
{
  "Header": {
    "Method": "31800",
    "ServiceType": "DeviceQuery",
    "MchId": "ACCOUNT001",
    "TradeKey": "9af15b33........606529a0",
    "CreateTime": "20170830192428"
  },
  "Data": "{\"DeviceId\":\"00000000\",\"Retry\":\"0\"}"
}
```

### Response

```
{
  "Header": {
    "StatusCode": "0000",
    "StatusDesc": "STATUS_SUCCESS",
    "Method": "31800",
    "ServiceType": "DeviceQuery",
    "MchId": "ACCOUNT001",
    "ResponseTime": "20170830192427"
  },
  "Data": {
    "DeviceList": [
      {
        "type": "ezc",
        "ownerDeviceId": "12341234",
        "batchNumber": 9,
        "ezcDongleId": "0C100DE0A57E",
        "aesKey": "2fb7....4786"
      }
    ]
  }
}
```
