> 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/refund-1.md).

# 部分退款

## 說明

交易退款, 將以交易成功的訂單予以部分金額退款.

{% hint style="warning" %}
僅指定店家帳號可以使用 (**目前仍在測試中，尚未正式上線**)
{% endhint %}

## Request

### Header

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

### Data

| 欄位            | 必填  | 型別         | 範例            | 說明                                    |
| ------------- | --- | ---------- | ------------- | ------------------------------------- |
| StoreRefundNo | YES | String(20) | RF180101001   | 退款單編號, 全英數, 不超過20字元                   |
| StoreOrderNo  | YES | String(20) | PO180101001   | 原交易的訂單編號                              |
| DeviceInfo    | YES | String(32) | skb0001       | 請填固定值skb0001                          |
| StoreInfo     | NO  | String(16) | 00001         | 門市代號                                  |
| Cashier       | NO  | String(8)  | 王小明           | 收銀員                                   |
| RefundKey     | YES | String(32) | sha256...hash | 由intella所提供的退款密碼, 此密碼須先經過SHA256編碼後再填入 |
| RefundFee     | YES | Integer    | 100           | 可填入小於未退款金額之整數                         |
| RefundedMsg   | YES | String     | 產品瑕疵          | 退款說明訊息                                |

## Response

### Header

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

### Data

| 欄位            | 型別         | 範例                  | 說明     |
| ------------- | ---------- | ------------------- | ------ |
| SysRefundNo   | String(64) | 2018010112000005610 | 系統退款編號 |
| StoreRefundNo | String(20) | RF180101001         | 特店退款編號 |
| StoreOrderNo  | String(20) | PO180101001         | 特店訂單編號 |

## API Example

### Request

```
{
  "Header": {
    "Method": "00000",
    "ServiceType": "Refund",
    "MchId": "myMchId",
    "TradeKey": "9af15b336e6a9619928537df30b2e6a2376569fcf9d7e773eccede65606529a0",
    "CreateTime": "20180715102813"
  },
  "Data": "{\"DeviceInfo\":\"skb0001\",\"StoreOrderNo\":\"PO20180715001\",\"StoreRefundNo\":\"PO-20180715-001\",\"RefundKey\":\"9af15b336e6a9619928537df30b2e6a2376569fcf9d7e773eccede65606529a0\",\"RefundFee\":\"1\",\"RefundedMsg\":\"Broken\"}"
}
```

### Response

```
{
  "Header": {
    "StatusCode": "0000",
    "StatusDesc": "執行成功",
    "Method": "11500",
    "ServiceType": "Refund",
    "MchId": "myMchId",
    "ResponseTime": "20180715102816"
  },
  "Data": {
    "SysOrderNo": "2018071544571196210",
    "SysRefundNo": "2018071544571328811",
    "StoreOrderNo": "PO-20180715-001",
    "StoreRefundNo": "PO-20180715-001",
    "RefundedAt": "20180715102816",
    "PlatformRsp": "{\"returnCode\":\"0000\",\"returnMessage\":\"Success.\",\"info\":{\"refundTransactionId\":2018071544571328811,\"refundTransactionDate\":\"2018-07-15T02:28:15Z\"}}"
  }
}
```


---

# 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/refund-1.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.
