# Refund

<table><thead><tr><th width="161">Method</th><th width="198">Refund Type</th><th width="213">Require user_info</th><th>Require bank_info</th></tr></thead><tbody><tr><td>Pix</td><td>Refund to original source</td><td>N/A (Refund to original source)</td><td>N/A (Refund to original source)A</td></tr><tr><td>Boleto</td><td>Refund through banktransfer</td><td>Require</td><td>Not Require. System will send email to user when bank_info is empty</td></tr><tr><td>Lottery</td><td>Refund through banktransfer</td><td>Require</td><td>Not Require. System will send email to user when bank_info is empty</td></tr><tr><td>SPEI</td><td>Refund through SPEI banktransfer (3 working days)</td><td>Require</td><td>Require</td></tr><tr><td>Wallet</td><td>Refund to original source</td><td>N/A (Refund to original source)</td><td>N/A (Refund to original source)</td></tr><tr><td>CreditCard</td><td>Refund to original source</td><td>N/A (Refund to original source)</td><td>N/A (Refund to original source)</td></tr></tbody></table>

#### Request Base URL <a href="#request-base-url" id="request-base-url"></a>

```
  Test Environment : https://gateway-test.pagsmile.com
  Prod Environment : https://gateway.pagsmile.com
```

#### EndPoints <a href="#endpoints" id="endpoints"></a>

```
  /trade/refund
```

#### Request Header <a href="#request-header" id="request-header"></a>

| Parameter     | Required    | Description                         |
| ------------- | ----------- | ----------------------------------- |
| Content-Type  | Recommended | Application/json                    |
| Authorization | Yes         | Basic Base64(app\_id:security\_key) |

#### Request Body (JSON format) <a href="#request-body-json-format" id="request-body-json-format"></a>

<table><thead><tr><th>Parameter</th><th width="82">Type</th><th>Required</th><th width="98">Max Length(or Default Value)</th><th>Description</th></tr></thead><tbody><tr><td>app_id</td><td>string</td><td>yes</td><td>32</td><td>App's ID is in dashboard</td></tr><tr><td>timestamp</td><td>string</td><td>yes</td><td>19</td><td>yyyy-MM-dd HH:mm:ss</td></tr><tr><td>trade_no</td><td>string</td><td>yes</td><td>64</td><td>Pagsmile trade NO.(can NOT be empty with out_trade_no at same time)</td></tr><tr><td>out_trade_no</td><td>string</td><td>yes</td><td>64</td><td>ID given by the merchant in their system (can NOT be empty with trade_no at same time)</td></tr><tr><td>out_request_no</td><td>string</td><td>no</td><td>16</td><td>refund request unique NO.(can NOT be empty when request a partial refund)</td></tr><tr><td>refund_currency</td><td>string</td><td>yes</td><td>3</td><td></td></tr><tr><td>refund_amount</td><td>decimal</td><td>yes</td><td>0.01 ~ 99999999999999.99</td><td></td></tr><tr><td>refund_reason</td><td>string</td><td>no</td><td>128</td><td></td></tr><tr><td>user_info.identify.number</td><td>string</td><td>yes (not require for PIX, Wallet and CreditCard)</td><td>16</td><td>User ID</td></tr><tr><td>user_info.identify.type</td><td>string</td><td>no</td><td>16</td><td>User's ID type</td></tr><tr><td>user_info.name</td><td>string</td><td>yes (not require for PIX, Wallet and CreditCard)</td><td>64</td><td>User's name</td></tr><tr><td>user_info.email</td><td>string</td><td>yes (not require for PIX, Wallet and CreditCard)</td><td>64</td><td>User's email</td></tr><tr><td>user_info.phone</td><td>string</td><td>no</td><td>64</td><td>User's phone</td></tr><tr><td>bank_info.bank_id</td><td>string</td><td>no (required for SPEI)</td><td>64</td><td>User's bank ID. Check <a href="/pages/-Mhw9-oATVp7R8lEndu0#supported-bank-list">here</a></td></tr><tr><td>bank_info.bank_name</td><td>string</td><td>no (required for SPEI)</td><td>64</td><td>User's bank name to receive the refund</td></tr><tr><td>bank_info.agency</td><td>string</td><td>no</td><td>64</td><td>User's bank agency to receive the refund</td></tr><tr><td>bank_info.type</td><td>string</td><td>no</td><td>64</td><td>User's bank type to receive the refund</td></tr><tr><td>bank_info.number</td><td>string</td><td>no (required for SPEI)</td><td>64</td><td>User's bank number to receive refund. For SPEI refund, fill CLABE number.</td></tr></tbody></table>

#### Request Sample <a href="#request-sample" id="request-sample"></a>

```
curl --location --request POST 'https://gateway.pagsmile.com/trade/refund' \
--header 'Authorization: Basic Base64(appid:security_key)' \
--header 'Content-Type: application/json' \
--data-raw '{
    * "app_id": "app_id",
    * "timestamp": "",
    * "content": "content",
      "trade_no": "trade_no", //Require when "out_trade_no" is empty
      "out_trade_no": "", //Require when "trade_no" is empty
      "out_request_no": "", //Require for partial refund
    * "refund_amount": 10,
    * "refund_currency": "BRL",
      "out_trade_no": "{{$randomUUID}}",
      "user_info": {
          "identify": {
              "number": "**********",
              "type": "document type"
          },
          "name": "refund name",
          "email": "refund@email.com" //If bank_info is empty, system will send email to this address to collect bank_info
      },
      "bank_info": {
          "bank_id": "****",
          "bank_name": "bank name",
          "number": "**********"
      }
}'
```

#### Http Response (JSON format) <a href="#http-response-json-format" id="http-response-json-format"></a>

| Parameter      | Type   | Description                 |
| -------------- | ------ | --------------------------- |
| code           | string | Return code                 |
| msg            | string | Return msg                  |
| sub\_code      | string | Return sub code(only error) |
| sub\_msg       | string | Return sub msg(only error)  |
| refund\_status | string |                             |

#### Return Sample (Success) <a href="#return-sample-success" id="return-sample-success"></a>

```
{
    "code": "10000",
    "msg": "Success",
    "refund_status": "{refund_status}"
}
```

#### Return Sample (Fail) <a href="#return-sample-fail" id="return-sample-fail"></a>

```
{
    "code": "40002",
    "msg": "Business Failed",
    "sub_code": "invalid-signature",
    "sub_msg": "invalid signature"
}
```


---

# Agent Instructions: 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:

```
GET https://docs.pagsmile.com/payin/refund.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
