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

# Win

当玩家赢得一局时会发送 `win` 回调。你的服务器必须将中奖金额记入玩家余额，并返回更新后的余额。该操作是幂等的——若钱包收到多个带有相同 transactionId 的请求，该交易只能登记一次。

***无需在回调 URL 末尾添加“Win”；您可以获取请求正文“command”来识别哪个回调即将到来。***

* **URL:** 你配置的 Callback URL(ex: [***https://mycallback.com/cb***](https://mycallback.com/cb))
* **Method:** POST
* **Headers:** `X-Request-Signature`, `Content-Type`, `Accept`

## Request parameters

<ParamField body="command" type="string" required>
  此回调类型固定为 `"win"`
</ParamField>

<ParamField body="transactionId" type="long" required>
  我方系统中创建的交易唯一引用。用于保证幂等性
</ParamField>

<ParamField body="playerId" type="string" required>
  你方系统中的玩家唯一标识
</ParamField>

<ParamField body="roundId" type="long" required>
  游戏局次的唯一引用
</ParamField>

<ParamField body="providerId" type="number" required>
  我方系统中游戏提供商的唯一标识
</ParamField>

<ParamField body="gameCode" type="number" required>
  我方系统中该游戏的唯一 game id
</ParamField>

<ParamField body="amount" type="number" required>
  需记入玩家余额的中奖金额
</ParamField>

<ParamField body="isRoundFinished" type="boolean" required>
  表示此赢款后该局是否已结束。若为 `true`，本局不会再发送后续 `win` 回调；若为 `false`，之后可能还有额外的 `win` 回调
</ParamField>

<ParamField body="bonusId" type="long" required>
  0：无奖金；否则为相关奖金 id
</ParamField>

<ParamField body="timestamp" type="number" required>
  请求的 Unix 时间戳
</ParamField>

## Response fields

你的服务器必须以 HTTP 200 响应，且 JSON 正文包含以下字段：

<ResponseField name="balance" type="number" required>
  记入中奖金额后玩家的最新余额
</ResponseField>

<ResponseField name="statusCode" type="string" required>
  操作结果。成功时必须为 `"OK"`。所有可能取值见下方状态码表
</ResponseField>

## Status codes

| 状态码                          | 说明        |
| :--------------------------- | :-------- |
| `OK`                         | 请求成功      |
| `ERR_INTEGRITY_CHECK_FAILED` | 消息完整性校验失败 |
| `ERR_NOT_AUTHENTICATED`      | 玩家未认证     |
| `ERR_UNKNOWN`                | 内部服务器错误   |

<Warning>
  你的响应必须在 **4 秒** 内返回。若请求超时或返回错误，我们会自动再重试最多 **2 次**。
</Warning>

## Examples

<CodeGroup>
  ```json Request theme={null}
  {
    "command": "win",
    "transactionId": "SP215202",
    "playerId": "1101",
    "roundId": "65215842315484512",
    "providerId": 1,
    "gameCode": 655,
    "amount": 100,
    "isRoundFinished": true,
    "bonusId": 0,
    "timestamp": 1586335186372
  }
  ```

  ```json Success response theme={null}
  {
    "balance": 19839891,
    "statusCode": "OK"
  }
  ```

  ```json Error response theme={null}
  {
    "statusCode": "ERR_UNKNOWN",
    "balance": 19839880
  }
  ```
</CodeGroup>
