# 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"" %}

```
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;***.***&#x20;
* ***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               |

{% hint style="danger" %}
Our notifications will be sent from these IP addresses, please add them to your whitelist.
{% endhint %}


---

# 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/payout/notification.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.
