> For the complete documentation index, see [llms.txt](https://docs.payvalida.com/api-recaudo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payvalida.com/api-recaudo/api-recaudo-en/notification.md). Agents can also search and read this documentation through its [MCP server](https://docs.payvalida.com/api-recaudo/~gitbook/mcp).

# Notification

This is the notification process Payvalida uses to report the payment or expiration of a registered order.

<figure><img src="https://2646475391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ly_b6lZywQ5rYRHAN2H-1525464909%2Fuploads%2FGgnYy5nbnUqCIhnBMtOP%2Fimage.png?alt=media&amp;token=5f23a941-b117-4660-ba83-950d971b8ac6" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
You must build a REST service that Payvalida can call. The notification process is carried out through this service.
{% endhint %}

{% hint style="info" %}
The notification URL is configured within our [merchant module](https://docs.payvalida.com/guia-del-modulo-comercial/) (Spanish), specifically in the account profile. You can find the detailed steps to follow [here](https://docs.payvalida.com/guia-del-modulo-comercial/configuraciones/perfil-de-cuenta) (Spanish).
{% endhint %}

When an order is registered, it is created with a **PENDIENTE** (pending) status. The order can change status for several reasons:

1. The corresponding payment is received → changes from **PENDIENTE** to **APROBADA** (approved) and is notified with status ***approved***.
2. The corresponding payment is not received before the expiration date → changes from **PENDIENTE** to **VENCIDA** (expired) and is notified with status ***cancelled***.
3. The merchant *deletes* the order (using the API) → changes from **PENDIENTE** to **CANCELADA** (cancelled). It is not notified.
4. The customer files a refund claim for the payment made → changes from **APROBADA** to **ANULADA** (voided) and is notified with status ***cancelled***.
5. The merchant requests a refund of a customer's payment → changes from **APROBADA** to **ANULADA**. It is not notified.

The system notifies automatically at the moment the order status changes, but more than one notification may be sent for the same order.

{% hint style="danger" %}
It is the merchant's responsibility to avoid delivering the purchased product to the customer more than once if there is more than one notification.
{% endhint %}

{% hint style="success" %}
This notification is sent to the **URL** provided by the merchant.
{% endhint %}

{% tabs %}
{% tab title="Request (sent by Payvalida)" %}

| Field         | Type   | Description                                                                       |
| ------------- | ------ | --------------------------------------------------------------------------------- |
| pv\_po\_id    | int    | Payvalida order identifier.                                                       |
| po\_id        | string | Merchant order identifier.                                                        |
| status        | string | Order status. Can be ***approved*** or ***cancelled***.                           |
| pv\_checksum  | string | Verification string calculated with SHA256(`po_id + status + NOTIFICATION_HASH`). |
| amount        | string | Order amount.                                                                     |
| iso\_currency | string | Currency in which the order was registered.                                       |
| pv\_payment   | string | Payment method with which the order was registered or approved.                   |
| {% endtab %}  |        |                                                                                   |

{% tab title="Request (example)" %}
{% code overflow="wrap" %}

```bash
curl --location --request POST 'https://url-comercio.com/notificacion/payvalida' \
--header 'Content-Type: application/json' \
--data-raw '{
    "pv_po_id":1934480,
    "po_id":"999999991",
    "status":"approved",
    "pv_checksum":"0C08309AE28D15E8D337344E88668E2047947F653B126B7F62B0EACC4B1A30FD680DBE25BD8B38413032A219B86BDAE52D9554D45A892CA4B5C5103597876EAD",
    "amount":"10500.0",
    "iso_currency":"COP",
    "pv_payment":"PSE"
}'
```

{% endcode %}
{% endtab %}

{% tab title="Expected response" %}
{% code overflow="wrap" %}

```json
// In this case you can respond in the body with plain text and a message
OK

// You can also respond in the body with a JSON structure
{"status":"OK"}
```

{% endcode %}
{% endtab %}

{% tab title="Headers" %}

| Header        | Value            |
| ------------- | ---------------- |
| Content-Type  | application/json |
| {% endtab %}  |                  |
| {% endtabs %} |                  |

{% hint style="warning" %}
For security reasons, on the merchant side we recommend building the **pv\_checksum** with the **NOTIFICATION\_HASH** credential delivered at registration, and comparing it with the one received to verify that the notification comes from Payvalida
{% endhint %}

{% hint style="info" %}
When an approved order is notified, the value of the **pv\_payment** field is the payment method used to pay the order.

When an expired order is notified, the value of the **pv\_payment** field is the payment method indicated when the order was registered. If no payment method was specified, this field is not sent in the request.
{% endhint %}

The system records the response obtained at the time of the notification, so we recommend responding with text appropriate to the notification process, for example **OK** for success and **ERROR** otherwise. We also recommend adding a short description, for example **"OK. Payment registered"** or **"ERROR. Order not recognized"**.

In the sandbox environment, it is possible to simulate payments to receive notifications at the webhook. To learn how to simulate payments, click [here](https://docs.payvalida.com/guia-del-modulo-comercial/simular-pagos/simular-pagos-en-sandbox) (spanish).
