> ## Documentation Index
> Fetch the complete documentation index at: https://devzone.nayax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 验证

为确保通信安全，集成商发送的每个请求都必须包含两个特定的身份验证标头。这些标头用于验证您的身份并确保交易数据的完整性。

## 先决条件

开始之前，请确保您已准备好 Nayax 提供的以下资源：

* 有效的 Header Hash Key（通常为 16 个字符），也称为签名密钥（Sign Key）
* 关联的 Header Hash Key ID，也称为签名密钥 ID（Sign Key ID）

> [!WARNING]
>
> 您的请求正文必须包含 `SparkTransactionId` 字段。

## 验证请求

拥有所需的资源后，您可以按照以下步骤开始向 Spark 验证您的 API 请求：

1. 将静态字符串 `IntegratorId` 与您的 ID 按以下格式组合：`IntegratorId: {HeaderHashKeyID}`。请参见下面的示例：
   ```
   IntegratorId: 927
   ```
2. 将请求正文中的 `SparkTransactionId` 与您的 `Header Hash Key` 用分号（`;`）连接，格式如下：`SparkTransactionId;HeaderHashKey`
   ```
   123456789123456789abcdefghijklmnopqr;RbtdDsiVNjkAeRty
   ```
3. 使用 UTF-8 编码对结果字符串执行 SHA-256 哈希运算。得到的哈希值：
   ```
   1b7dd1c4010698824de66f13e1387efc28a4bba00b720d4be8cdb3b598b9603e
   ```
4. 最终的标题应如下所示：
   ```
   TransactionSignature: 1b7dd1c4010698824de66f13e1387efc28a4bba00b720d4be8cdb3b598b9603e
   ```

## 请求示例（cURL）

参见 `/StartAuthentication` 端点的示例请求：

> [!NOTE]
>
> 基本 URL
>
> Spark API 的基础 URL 为 `https://nayax-spark-dmz.nayax.com/api`。集成环境和生产环境使用同一个主机。

```bash theme={null}
curl --location 'https://nayax-spark-dmz.nayax.com/api/StartAuthentication' \
--header 'IntegratorId: 927' \
--header 'TransactionSignature: 1b7dd1c4010698824de66f13e1387efc28a4bba00b720d4be8cdb3b598b9603e' \
--header 'Content-Type: application/json' \
--data '{
 "TokenId": 116383,
 "TerminalId": "0434334921100366",
 "TerminalIdType": 1,
 "Random": "123456789qwertyui",
 "Cipher": "X305dITNTAw2vHsxE+taVcn6UvgBC3fdI6QbqeABgHbo8CKsoZhqISJfslehCiA+L7XYrqvKFci7C6BNj/tr zBuNJwBEjgBzKhhgpJ5ggnw=",
 "SparkTransactionId": "123456789123456789abcdefghijklmnopqr"
}'
```

## 参见

> **[交互式身份验证工具](https://devzone.nayax.com/docs/integrate-pos-device/spark/security-authentication/spark-auth-tool.md)**
>
> 在浏览器中构建和检查密文与签名请求头，无需编写代码。

> **[交易流程](https://devzone.nayax.com/docs/integrate-pos-device/spark/payment-flows/transaction-flows-spark)**
>
> 身份验证如何融入完整的 Spark 交易流程。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.