# Payment Validation

This guide explains how you can reply to Tip4Serv webhooks and how to control the validation (DELIVERED) of orders, either server-wide or per individual command.

### Response Semantics

#### A) `200 OK` response with no body

**Effect:**

* All orders contained in the event are marked as **DELIVERED**.
* The related financial object (payment or subscription) is marked as **processed**.

> This is the default behavior: simple and global. Code example: [#create-an-endpoint](https://docs.tip4serv.com/handle-webhook#create-an-endpoint "mention")

***

#### B) `200 OK` response with a targeted JSON

To validate only specific servers and/or commands, return `application/json` in the following format:

```json
{
  "ok": true,
  "results": [
    {
      "server_id": "20859",
      "commands": [
        { "command_id": "0", "delivered": true },
        { "command_id": "1", "delivered": false, "error": "server unreachable" }
      ]
    },
    {
      "server_id": "20861",
      "delivered": true
    }
  ]
}
```

***

#### Priority Rules

1. Servers/commands absent from the JSON are **not modified** (they remain undelivered).
2. If `delivered: false` + `error` is provided, the platform logs the error and **does not attempt to mark the command as delivered**.

***

#### Headers & Content-Type

* `Content-Type: application/json; charset=utf-8`
* Always return **HTTP 200** if the request was authenticated and functionally processed (even if you reject some commands with `delivered: false`).
* Use **401** only for invalid signature/timestamp: [#secure-and-handle-webhook](https://docs.tip4serv.com/handle-webhook#secure-and-handle-webhook "mention")

***

### 3) Usage Examples

#### Example 1 — Validate everything (global)

Response:

```
HTTP/1.1 200 OK
Content-Length: 2

ok
```

***

#### Example 2 — Validate only some commands of a server

```json
{
  "ok": true,
  "results": [
    {
      "server_id": "20859",
      "commands": [
        { "command_id": "0", "delivered": true },
        { "command_id": "1", "delivered": false, "error": "server unreachable" }
      ]
    }
  ]
}
```

***

#### Example 3 — Validate an entire server at once

```json
{
  "ok": true,
  "results": [
    { "server_id": "20861", "delivered": true }
  ]
}
```

***

#### Example 4 — Validate nothing (acknowledged but functionally refused)

```json
{
  "ok": true
}
```
