> For the complete documentation index, see [llms.txt](https://intella2.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://intella2.gitbook.io/scan2pay/api-specification/refund.md).

# Refund

Full refund of the transaction

{% hint style="warning" %}
Partial refund is not available.
{% endhint %}

## Request

### Header

| Item        | Mandatory | Data Type   | Sample         | Description                                                                    |
| ----------- | --------- | ----------- | -------------- | ------------------------------------------------------------------------------ |
| Method      | YES       | String(5)   | 00000          | Fill in 00000 (indefinite payment method)                                      |
| ServiceType | YES       | String(32)  | **Refund**     | Selected Scan2Pay Service type                                                 |
| MchId       | YES       | String(32)  | Account0001    | Merchant ID provided by intella                                                |
| TradeKey    | YES       | String(128) | sha256...hash  | Marchant password provided by intella, this password must be encoded by SHA256 |
| CreateTime  | YES       | String(14)  | 20180101120000 | Request time, the format is "yyyyMMddHHmmss"                                   |

### Data

| Item          | Mandatory | Data Type  | Sample              | Description                                                                               |
| ------------- | --------- | ---------- | ------------------- | ----------------------------------------------------------------------------------------- |
| StoreRefundNo | YES       | String(20) | RF180101001         | Refund number, composition shall be an alphanumeric string and no more than 20 characters |
| StoreOrderNo  | YES       | String(20) | PO180101001         | Original order number                                                                     |
| DeviceInfo    | YES       | String(32) | skb0001             | Terminal number is fixed as skb0001                                                       |
| StoreInfo     | NO        | String(16) | 00001               | Store ID                                                                                  |
| Cashier       | NO        | String(8)  | 王小明                 | Cashier                                                                                   |
| RefundKey     | YES       | String(32) | sha256...hash       | Marchant password provided by intella, this password must be encoded by SHA256            |
| RefundFee     | YES       | Integer    | 100                 | To match the amount of original order, partial refund is not available                    |
| RefundedMsg   | YES       | String     | Product Malfunction | Description of purchase refund                                                            |

## Response

### Header

| Item         | Data Type | Sample         | Description                                                                                                                      |
| ------------ | --------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| StatusCode   | String(4) | 0000           | [Transaction Status Code](https://intella2.gitbook.io/scan2pay/~/edit/drafts/-L_RhHH-JdlFCMIfEWGU/appendix/scan2pay-error-codes) |
| StatusDesc   | String    | Success        | Description of transaction status                                                                                                |
| Method       | String(5) | 10100          | Payment method code                                                                                                              |
| ServiceType  | String    | **Refund**     | Selected Scan2Pay Service type                                                                                                   |
| MchId        | String    | Account0001    | Merchant ID                                                                                                                      |
| ResponseTime | String    | 20180101120000 | Transaction response time, the format is "yyyyMMddHHmmss"                                                                        |

### Data

| Item          | Data Type  | Sample              | Description          |
| ------------- | ---------- | ------------------- | -------------------- |
| SysRefundNo   | String(64) | 2018010112000005610 | System refund number |
| StoreRefundNo | String(20) | RF180101001         | Store refund number  |
| StoreOrderNo  | String(20) | PO180101001         | Store order number   |

## API Example

### Request

```
{
  "Header": {
    "Method": "00000",
    "ServiceType": "Refund",
    "MchId": "myMchId",
    "TradeKey": "9af15b336e6a9619928537df30b2e6a2376569fcf9d7e773eccede65606529a0",
    "CreateTime": "20180715102813"
  },
  "Data": "{\"DeviceInfo\":\"skb0001\",\"StoreOrderNo\":\"PO-20180715-001\",\"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\"}}"
  }
}
```
