> 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/customer-scan.md).

# 消費者主掃

## Request

### Header

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

### Data

| 欄位           | 必填  | 型別          | 範例             | 說明                                                        |
| ------------ | --- | ----------- | -------------- | --------------------------------------------------------- |
| TimeExpire   | NO  | String      | 20180101120100 | <p>訂單(QR Code)失效時間, 格式為yyyyMMddHHmmss <br>未帶入預設為15分鐘後</p> |
| DeviceInfo   | YES | String      | skb0001        | 終端機編號, 固定為skb0001                                         |
| StoreOrderNo | YES | String(20)  | 2018010100001  | 訂單編號, 須為英數字母組合字串，長度不超過20字元                                |
| Body         | YES | String(128) | 雞排             | 商品名稱                                                      |
| FeeType      | NO  | String      | TWD            | 交易幣別, 預設為台幣TWD                                            |
| TotalFee     | YES | Integer     | 70             | 正整數，不得為負值，如非特殊應用目的，請勿打0元交易，0元交易視為可由消費者自行輸入任意交易金額          |
| Detail       | NO  | String(200) | 香酥大雞排          | 訂單詳細資訊                                                    |
| StoreInfo    | NO  | String      | A0001          | 門市代號                                                      |
| Cashier      | NO  | String      | 王小明            | 收銀員                                                       |
| StoreName    | NO  | String      | 忠孝店            | 分店名稱                                                      |
| StoreType    | NO  | String      | 直營店            | 分店類型                                                      |
| DeviceOS     | NO  | String      | 2              | 裝置類型 (1: iOS / 2: Android / 3: Windows / 4:Others)        |

{% hint style="danger" %}
訂單編碼(StoreOrderNo)不可超過20字元，且只能使用英文字母和數字，不能使用符號或是特殊字元，以免導致部分支付交易失敗
{% endhint %}

{% hint style="info" %}
Detail欄位傳入json字串內帶有下列參數時: \
CallBackUrl:本次交易完成跳轉網址 \
Delay:交易完成，延遲跳轉秒數 \
example : {"CallBackUrl":"<https://intella.co/","Delay":"5"}>
{% endhint %}

## Response

### Header

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

### Data

| 欄位       | 型別     | 範例                            | 說明                    |
| -------- | ------ | ----------------------------- | --------------------- |
| urlToken | String | <https://s.intella.co/hdjkhd> | 交易網址, 轉換為QR Code供客戶掃描 |

{% hint style="warning" %}
消費者掃描QR Code進行支付後, 收款端若無[接收伺服器通知](/scan2pay/api-callback.md), 則需使用輪詢(polling)方式, 透過呼叫[單筆訂單查詢](/scan2pay/api-specification/single-order-query.md)來查詢交易結果.
{% endhint %}

## API Example

### Request

```
{
  "Header": {
    "Method": "00000",
    "ServiceType": "OLPay",
    "MchId": "myMchId",
    "TradeKey": "9af15b336e6a9619928537df30b2e6a2376569fcf9d7e773eccede65606529a0",
    "CreateTime": "20180715101009"
  },
  "Data": "{\"DeviceInfo\":\"skb0001\",\"StoreOrderNo\":\"PO20180715001\",\"Body\":\"Chicken Rice\",\"TotalFee\":\"1\"}"
}
```

### Response

```
{
  "Header": {
    "StatusCode": "0000",
    "StatusDesc": "執行成功",
    "ServiceType": "OLPay",
    "MchId": "myMchId",
    "ResponseTime": "20180715101012"
  },
  "Data": {
    "urlToken": "https://s.intella.co/tf6oc66cgfp"
  }
}
```
