> For the complete documentation index, see [llms.txt](https://docs.pagsmile.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pagsmile.com/reference/payout/notification.md).

# Notification

Once the payout is confirmed by the bank, Pagsmile will send a notification to the merchant notification URL informing you of the result of the transaction. This URL is defined when submitting the payout transaction, by using the *notify\_url* parameter for each payout request. Notification will retry **6** times when your processing failed.

## Notifcation

<mark style="color:green;">`POST`</mark> `$notify_url which defined when submitting the payout transaction.`

Notification Parameters

#### Headers

| Name                                            | Type   | Description                           |
| ----------------------------------------------- | ------ | ------------------------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | string | application/json; charset=UTF-8       |
| Authorization<mark style="color:red;">\*</mark> | string | SHA256(*$sorted\_params + $app*\_key) |

#### Request Body

| Name                                           | Type    | Description                                                                                     |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------- |
| payoutId<mark style="color:red;">\*</mark>     | string  | pagsmile transaction id                                                                         |
| custom\_code<mark style="color:red;">\*</mark> | string  | merchant custom\_code                                                                           |
| status<mark style="color:red;">\*</mark>       | string  | PAID, REJECTED, REFUNDED or PARTIAL\_REFUNDED                                                   |
| msg                                            | string  | success or rejected message                                                                     |
| timestamp<mark style="color:red;">\*</mark>    | integer | unix timestamp                                                                                  |
| source\_currency                               | string  | source\_currency of the original payout transaction. Only applicable for Brazil QRCODE payout   |
| arrival\_currency                              | string  | arrival\_currency of the original payout transaction. Only applicable for Brazil QRCODE payout  |
| amount\_in\_arrival\_currency                  | string  | Only applicable for Brazil QRCODE payout                                                        |
| amount\_in\_source\_currency                   | string  | Only applicable for Brazil QRCODE payout                                                        |
| exchange\_rate\_id                             | string  | exchange\_rate\_id of the original payout transaction. Only applicable for Brazil QRCODE payout |
| exchange\_rate                                 | string  | exchange\_rate of the original payout transaction. Only applicable for Brazil QRCODE payout     |

{% tabs %}
{% tab title="200 Merchant process the callback, and response " %}

```
success
```

{% endtab %}
{% endtabs %}

## Authorization Check

* Get callback's body parameters, and sort them ascendingly.
* Concatenate *sorted\_params with app\_key.*
* Use *sha256(sorted\_params + app\_key)* to generate **App Authorization**.
* Get **Pagsmile Authorization** from callback's Header.
* Verify if **Pagsmile Authorization** matches with **App Authorization**.

{% hint style="danger" %}
When sorting parameters, strip the ones with no value.
{% endhint %}

## Notification Events

* PAID
* REJECTED
* REFUNDED
* PARTIAL\_REFUNDED

{% hint style="danger" %}

* ***PIX (Brazil), BankTransfer (Brazil), QRCODE (Brazil), SPEI (Mexico), BankTransfer (Chile),** and **Pagsmile Wallet*** supported ***REFUNDED*** notificatio&#x6E;***.***
* ***PIX (Brazil), BankTransfer (Brazil),** and **QRCODE (Brazil)** supported **PARTIAL\_REFUNDED*** notification. A payout transaction can receive multiple ***PARTIAL\_REFUNDED*** notifications until the payout amount is fully refunded. When multiple partial refunds fully refund a payout transaction, a ***REFUNDED*** notification will be sent right after the ***PARTIAL\_REFUNDED*** notification of the last partial refund.
  {% endhint %}

## Notification Example

#### General

{% tabs %}
{% tab title="PAID" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payoutId": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "PAID",
    "msg": "success",
    "timestamp": 1628564650
}'
```

{% endtab %}

{% tab title="REJECTED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payoutId": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "REJECTED",
    "msg": "Rejected by bank",
    "timestamp": 1628564650
}'
```

{% endtab %}

{% tab title="REFUNDED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payoutId": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "REFUNDED",
    "msg": "Refund by the recipient or the recipient's bank",
    "timestamp": 1628564650
}'
```

{% endtab %}

{% tab title="PARTIAL\_REFUNDED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payoutId": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "PARTIAL_REFUNDED",
    "refunded_id": "D182361*********************ca9d", //The refund id of this partial refund, usually start with D.
    "refunded_amount": "0.01", //The amount of this partial refund.
    "msg": "Refund by the recipient or the recipient's bank",
    "timestamp": 1628564650
}'
```

{% endtab %}
{% endtabs %}

#### Brazil QRCODE payout

{% tabs %}
{% tab title="PAID" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transaction_id": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "PAID",
    "msg": "success",
    "timestamp": 1628564650,
    "source_currency": "USD",
    "arrival_currency": "BRL",
    "amount_in_arrival_currency": "",
    "amount_in_source_currency": "",
    "exchange_rate_id": "ERxxxxxxxxxx",
    "exchange_rate": "6.987234"
}'
```

{% endtab %}

{% tab title="REJECTED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transaction_id": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "REJECTED",
    "msg": "Rejected by bank",
    "timestamp": 1628564650,
    "source_currency": "USD",
    "arrival_currency": "BRL",
    "amount_in_arrival_currency": "",
    "amount_in_source_currency": "",
    "exchange_rate_id": "ERxxxxxxxxxx",
    "exchange_rate": "6.987234"
}'
```

{% endtab %}

{% tab title="REFUNDED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transaction_id": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "REFUNDED",
    "msg": "Refund by the recipient or the recipient's bank",
    "timestamp": 1628564650,
    "source_currency": "USD",
    "arrival_currency": "BRL",
    "amount_in_arrival_currency": "",
    "amount_in_source_currency": "",
    "exchange_rate_id": "ERxxxxxxxxxx",
    "exchange_rate": "6.987234"
}'
```

{% endtab %}

{% tab title="PARTIAL\_REFUNDED" %}

```
curl --location --request POST ${MERCHANT_NOTIFY_URL} \
--header 'Authorization: ${SIGNATURE}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transaction_id": "TS202310121355544******7kJPB",
    "custom_code": "custom_code_test",
    "status": "PARTIAL_REFUNDED",
    "refunded_id": "D182361*********************ca9d", //The refund id of this partial refund, usually start with D.
    "refunded_amount": "0.01", //The amount of this partial refund.
    "msg": "Refund by the recipient or the recipient's bank",
    "timestamp": 1628564650,
    "source_currency": "USD",
    "arrival_currency": "BRL",
    "amount_in_arrival_currency": "",
    "amount_in_source_currency": "",
    "exchange_rate_id": "ERxxxxxxxxxx",
    "exchange_rate": "6.987234"
}'
```

{% endtab %}
{% endtabs %}

## Notification Retries

Pagsmile will send notifications with the following schedule of retries and confirmation awaiting times. You must return an HTTP STATUS 200 (OK) with response data "success" before the corresponding time expires. If not, it will be assumed that you did not receive it correctly and you will be notified again.

It is recommended that you respond to the notification before executing business logic or prior to accessing external resources so as not to exceed the estimated response times.

This communication is exclusively between the servers of Pagsmile and your server, so there will not be a physical user seeing any type of result.

| Event     | Time after first dispatch |
| --------- | ------------------------- |
| Dispatch  | --                        |
| 1st retry | 10 minutes                |
| 2nd retry | 30 minutes                |
| 3rd retry | 60 minutes                |
| 4th retry | 120 minutes               |
| 5th retry | 360 minutes               |
| 6th retry | 840 minutes               |

### Outbound IP Addresses

Pagsmile payout notifications are sent from the following outbound IP addresses. If your system has IP whitelist restrictions, please add the corresponding IP address to your whitelist.

| Environment | Outbound IP Address |
| ----------- | ------------------- |
| Sandbox     | `44.237.251.97`     |
| Production  | `3.101.4.103`       |
