# 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: [Handle Webhook](/webhooks-developers-only/handle-webhook.md#create-an-endpoint)

***

#### 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: [Handle Webhook](/webhooks-developers-only/handle-webhook.md#secure-and-handle-webhook)

***

### 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
}
```


---

# 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.tip4serv.com/webhooks-developers-only/payment-validation.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.
