> For the complete documentation index, see [llms.txt](https://piqpay.gitbook.io/merchant-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://piqpay.gitbook.io/merchant-integration/ru/kollbek/podpis-kollbeka.md).

# Подпись коллбэка

Чтобы убедится что коллбэки приходят от PiqPay, используйте подпись, которая  приходит в заголовке X-Signature. Подпись вычисляется по алгоритму HmacSha256, используя "Secret", полученный при активации подписки в разделе Subscriptions (secret) и тело полученного коллбэка в формате JSON String (data), и дальше вычисленная подпись кодируется в формат BASE64.&#x20;

Чтобы найти "Secret" для расшифровки подписи коллбэка, вам следует перейти во вкладку "Merchant brands" в бизнес-офисе, затем кликнуть на нужный бренд (каждый бренд имеет свой Secret) и перейти в разделе "Subscriptions".

<figure><img src="/files/H2xxTYcjzVb4LFD16bXC" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Важно**: для корректной расшифровки подписи в коллбэке не должно быть пробелов.
{% endhint %}

**Пример вычисления на Kotlin**

{% code overflow="wrap" %}

```kotlin
fun calculateBase64HmacSha256(secretKey: String, data: String): String {
 val secretKeySpec = SecretKeySpec(secretKey.toByteArray(), "HmacSHA256")
    val mac = Mac.getInstance("HmacSHA256").apply { init(secretKeySpec) }
    return Base64.getEncoder().encodeToString(mac.doFinal(data.toByteArray()))
}
```

{% endcode %}

&#x20;&#x20;

**Пример вычисления на JS (NodeJS)**

{% code overflow="wrap" %}

```javascript
const crypto = require('crypto');
function hmacSha256Node(s, d) {
    const hmac = crypto.createHmac('sha256', s);
    hmac.update(d);
    // Get the hash in BASE64 format
    const hash = hmac.digest('base64');
    return hash;
  }
  let sig = hmacSha256Node(secretKey, data);
  console.log(sig);
```

{% endcode %}

Для тестирования алгоритма вычисления подписи вы можете использовать следующий данные:

data:

{% code overflow="wrap" %}

```json
'{"type":"PAYMENT_ORDER_CREATED","id":"25c9d5ab-c5df-4d87-adc6-c0dc7c75e6da","orderId":"9f7348d0-6522-48b2-8743-d89a0e0a5451","merchantId":"8481fd2a-16f3-45cf-8eb0-7de1285d518a","storeId":"d8440d52-25a5-4e8e-907d-3d73dd3763a8","clientId":"4d331ccdс73fft12fcfcr2","externalId":"davvcd17dd344d2ftfc3jrc1cdk","amount":{"minorAmount":500000,"currency":"PKR"},"createdAt":"2026-02-15T10:43:48.218Z","callbackUrl":"https://webhook.site/f2161c53-8364-4614-94b6-78c604250a4a"}'
```

{% endcode %}

secretKey:

{% code overflow="wrap" %}

```
'qrswmtlc8f'
```

{% endcode %}

Signature:&#x20;

{% code overflow="wrap" %}

```
U7E+wLPCDLufYPJtFUY2ryWp1QSRp9rnmvdfaqfZOg8=
```

{% endcode %}

Мы отправляем коллбэки со следующих IP адресов. При необходимости вы можете внести их в вайтлист на своем сервере.

| DEV  | 51.17.52.88                                               |
| ---- | --------------------------------------------------------- |
| PROD | <p>51.17.160.132</p><p>154.205.145.213<br>38.54.42.66</p> |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://piqpay.gitbook.io/merchant-integration/ru/kollbek/podpis-kollbeka.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.
