> For the complete documentation index, see [llms.txt](https://merch-int.moneyhoney.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://merch-int.moneyhoney.io/api/auth/podpis.md).

# Подпись

**Подпись создается для обеспечения целостности запроса.**&#x20;

Подпись формируется путем объединения тела запроса и пути запроса с параметрами запроса, после чего выполняется хэширование с использованием алгоритма HMAC SHA-256 и секрета ( sign\_token) , предоставленного менеджером HM.

#### Пример:

```
{
  "amount": 123.456
}/v2/merchant/transactions?queryParam1=123&queryParam2=456
```

Для запросов с Content-Type = multipart/form-data,  для подписи используется только путь запроса с параметрами запроса.

####

#### Примеры кода для вычисления хэша:&#x20;

{% tabs %}
{% tab title="Python" %}

```python
import hashlib
import hmac
def calculate_signature(url, request_json, secret):
    request_json_string = json.dumps(request_json)
    parsed_url = urlparse(url)
    signature_string = request_json_string + parsed_url.path + parsed_url.query
    signature = hmac.new(secret.encode('utf-8'), signature_string.encode('utf-8'), hashlib.sha256).hexdigest()

    return signature
```

{% endtab %}

{% tab title="PHP" %}

```php
function calculateSignature($url, $requestJson, $secret) {
    $signatureString = $requestJson.parse_url($url, PHP_URL_PATH).parse_url($url, PHP_URL_QUERY);
    $signature = hash_hmac('sha256', $signatureString, $secret);
    return $signature;
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const crypto = require('crypto');
function calculateSignature(url, requestJson, secret) {
 const signatureString = requestJson + url.pathname + url.search;
 const hmac = crypto.createHmac('sha256', secret);
 hmac.update(signatureString);
 return hmac.digest('hex');
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System.Security.Cryptography;

public string CalculateSignature(string url, string requestJson, string secret)
{
    string signatureString = requestJson + url;

    using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret)))
    {
        byte[] hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(signatureString));
        return Convert.ToBase64String(hashBytes);
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.codec.binary.Hex;
import java.net.URI;
import java.nio.charset.StandardCharsets;

public String calculateSignature(URI url, String requestJson, String secret) {
   String signatureString = requestJson + url.getPath() + url.getQuery();

   byte[] hmacSha256 = HmacUtils.hmacSha256(secret.getBytes(StandardCharsets.UTF_8), signatureString);
   
   return Hex.encodeHexString(hmacSha256);
}
```

{% endtab %}
{% endtabs %}


---

# 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://merch-int.moneyhoney.io/api/auth/podpis.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.
