> 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/single-order-query.md).

# 單筆交易查詢

## 說明

單筆交易查詢

{% hint style="warning" %}
若使用單筆交易作為交易結果輪詢(polling), 請兩秒鐘呼叫一次此API. (同一個特店帳號, 若短時間內有過多的交易查詢, 會使系統將其IP位址鎖定不允許呼叫API)
{% endhint %}

## Request

### Header

| 欄位          | 必填  | 型別          | 範例                   | 說明                                          |
| ----------- | --- | ----------- | -------------------- | ------------------------------------------- |
| Method      | YES | String(5)   | 00000                | 請填入固定值00000                                 |
| ServiceType | YES | String(32)  | **SingleOrderQuery** | 所選用的Scan2Pay服務代碼                            |
| MchId       | YES | String(32)  | Account0001          | 由intella所提供的特店帳號                            |
| TradeKey    | YES | String(128) | sha256...hash        | 由intella所提供的交易密碼, 此密碼須先經過SHA256加密，再進行Hex編碼。 |
| CreateTime  | YES | String(14)  | 20180101120000       | Request建立時間, 格式為yyyyMMddHHmmss              |

### Data

| 欄位           | 必填  | 型別         | 範例          | 說明        |
| ------------ | --- | ---------- | ----------- | --------- |
| StoreOrderNo | YES | String(20) | PO180101001 | 所要查詢的訂單編號 |

## Response

### Header

| 欄位           | 型別        | 範例                   | 說明                                                   |
| ------------ | --------- | -------------------- | ---------------------------------------------------- |
| StatusCode   | String(4) | 0000                 | [交易結果代碼](/scan2pay/appendix/scan2pay-error-codes.md) |
| StatusDesc   | String    | 交易成功                 | 交易結果代碼說明                                             |
| Method       | String(5) | 10100                | [支付平台代碼](/scan2pay/appendix/payment-type.md)         |
| ServiceType  | String    | **SingleOrderQuery** | 所選用的Scan2Pay服務代碼                                     |
| MchId        | String    | Account0001          | 特店帳號                                                 |
| ResponseTime | String    | 20180101120000       | 交易回應時間, 格式為yyyyMMddHHmmss                            |

### Data

| 欄位           | 型別     | 範例                  | 說明                                                                                 |
| ------------ | ------ | ------------------- | ---------------------------------------------------------------------------------- |
| SysOrderNo   | String | 2018010110074205610 | 系統訂單編號                                                                             |
| StoreOrderNo | String | PO180101001         | 特店訂單編號                                                                             |
| TotalFee     | String | 90                  | 訂單交易金額                                                                             |
| Body         | String | 雞排                  | 商品描述                                                                               |
| OrderStatus  | String | 1                   | 訂單狀態 (0: 處理中 / 1: 交易成功 / 2:失敗 / 3: 退款)                                             |
| CarrierNum   | String | /RRJFVKQ            | 電子發票載具                                                                             |
| MemberId     | String | M35812649           | 商家會員卡{類別名稱需與支付洽談確認}                                                                |
| PaidAt       | String | 20180101100755      | 與支付方的交易日期/時間                                                                       |
| RefundedMsg  | String | Refund success      | OrderStatus為3(退款)時, 會帶有此欄位, 此欄位會顯示退款狀態訊息 (退款成功: Refund success, 退款失敗: Refund fail) |

## API Example

### Request

```
{
  "Header": {
    "Method": "00000",
    "ServiceType": "SingleOrderQuery",
    "MchId": "myMchId",
    "TradeKey": "9af15b336e6a9619928537df30b2e6a2376569fcf9d7e773eccede65606529a0",
    "CreateTime": "20180715102627"
  },
  "Data": "{\"StoreOrderNo\":\"PO-20180715-001\"}"
}
```

### Response

```
{
  "Header": {
    "StatusCode": "0000",
    "StatusDesc": "執行成功",
    "Method": "11500",
    "ServiceType": "SingleOrderQuery",
    "MchId": "myMchId",
    "ResponseTime": "20180715102629"
  },
  "Data": {
    "SysOrderNo": "2018071544571196210",
    "StoreOrderNo": "PO-20180715-001",
    "TotalFee": "90",
    "PaidAt": "20180101100755",
    "Body": "Chicken Rice-6485",
    "OrderStatus": "1",
    "CarrierNum":"/RRJFVKQ",
    "MemberId":"M35812649"
  }
}
```
