> 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/jiao-yi-ding-dan-qu-xiao.md).

# 交易訂單取消

## 說明

取消 15 分鐘內交易中的訂單，超過 15 分鐘後需以[退款](/scan2pay/api-specification/refund.md)進行

## Request

### Header

| 欄位          | 必填  | 型別          | 範例              | 說明                                          |
| ----------- | --- | ----------- | --------------- | ------------------------------------------- |
| Method      | YES | String(5)   | 00000           | 請填入00000 (不指定支付方式)                          |
| ServiceType | YES | String(32)  | **CancelOrder** | 所選用的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   | 原交易的訂單編號                              |
| RefundKey    | YES | String(32) | sha256...hash | 由intella所提供的退款密碼, 此密碼須先經過SHA256編碼後再填入 |

## Response

### Header

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

### Data

| 欄位           | 型別         | 範例          | 說明     |
| ------------ | ---------- | ----------- | ------ |
| StoreOrderNo | String(20) | PO180101001 | 特店訂單編號 |

## API Example

### Request

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

### Response

```
{
  "Header": {
    "StatusCode": "0000",
    "StatusDesc": "執行成功",
    "Method": "00000",
    "ServiceType": "CancelOrder",
    "MchId": "myMchId",
    "ResponseTime": "20180715102816"
  },
  "Data": {
    "StoreOrderNo": "PO-20180715-001"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://intella.gitbook.io/scan2pay/api-specification/jiao-yi-ding-dan-qu-xiao.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
