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

# Settlement

> This API is to process settlement transactions. It ensures that players whose payouts could not be processed earlier are retried automatically according to a fixed schedule.

```http theme={null}
  POST  /transaction/settlement
```

## Functionality

* This API is used to resend all transactions that were not processed earlier due to technical issues. All payout transactions are submitted for settlement. This API also addresses transactions that have been active for more than 24 hours and have not yet been processed.
* Upon receiving a successful response from your system, the transactions will be processed.
* Any transactions that fail will be treated as lost bets. No bet reversals will be performed.
* Please ensure your wallet balances are updated accordingly.

Returns an array of responses with each user's updated balance.

## Headers

<ParamField header="x-api-key" type="string" required>
  A unique identifier associated with operator calling API.
</ParamField>

<ParamField header="x-signature" type="string" required>
  A SHA256 HMAC signature generated using the request body and timestamp.
  Format: HMAC\_SHA256(JSON.stringify(data) + '|' + timestamp), signed using the
  provided secret key.
</ParamField>

<ParamField header="x-timestamp" type="string" required>
  An Unix timestamp (milliseconds) when the request was sent. Ensure the same
  value is used in signature generation.
</ParamField>

<ParamField header="content-type" type="string" required>
  Must be set to `application/json`
</ParamField>

## Request Body

<ParamField body="transactions" type="array" required>
  <Expandable title="properties">
    <ParamField body="transactionId" type="string" required example="dd96bda3-9990-4aed-9679-f451a4b82ac4">
      The unique transaction identifier. An action with same transactionId shouldn’t be processed more than once.
    </ParamField>

    <ParamField body="refTransactionId" type="string" required>
      Unique identifier of the transaction that this transaction is referencing, which is the transactionId of the bet.
    </ParamField>

    <ParamField body="sessionId" type="string" required>
      Unique identifier for the game session.
    </ParamField>

    <ParamField body="roundId" type="string" required>
      A unique identifier representing the game round. For transactions without an associated roundId, this field may contain an empty string.
    </ParamField>

    <ParamField body="playerId" type="string" required>
      Unique identifier for the player.
    </ParamField>

    <ParamField body="gameId" type="string" required>
      Unique identifier for the game.
    </ParamField>

    <ParamField body="currency" type="string" required>
      Player's current session currency code.
    </ParamField>

    <ParamField body="amount" type="number" required>
      The payout amount won by the player.

      <Note>
        To maintain precision and avoid floating-point errors, the bet field is processed as an integer value by multiplying the actual amount by `100000`.

        For example, a bet of `12.34567` will be represented as `1234567` in the API.
      </Note>
    </ParamField>

    <ParamField body="isWin" type="boolean" required>
      Indicates whether the player won the bet.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="status" type="string" required>
  Code indicates status of the request weather it is succeed or failed. We have listed error codes <a href="/introduction#error-codes">here</a>
</ResponseField>

<ResponseField name="data" type="Data Array">
  <Expandable title="properties">
    <ResponseField name="status" type="string" required example="RS_OK">
      Status of the individual transaction.
    </ResponseField>

    <ResponseField name="transactionId" type="string" required example="dd96bda3-9990-4aed-9679-f451a4b82ac4">
      The unique transaction identifier. An action with same transactionId shouldn’t be processed more than once.
    </ResponseField>

    <ResponseField name="refTransactionId" type="string" required>
      Unique identifier of the transaction that this transaction is referencing, which is the transactionId of the bet.
    </ResponseField>

    <ResponseField name="sessionId" type="string" required example="d404f1da-26a6-44ff-8b0f-559915152be11742537289208">
      Unique identifier for the session.
    </ResponseField>

    <ResponseField name="roundId" type="string" required example="123xaf1a-s7ax-lles-9aws-5hjtjshosqq2be117425">
      Unique identifier for the game round.
    </ResponseField>

    <ResponseField name="playerId" type="string" required example="18865671">
      Unique identifier for the player.
    </ResponseField>

    <ResponseField name="currency" type="string" required example="EUR">
      Player's current session currency code.
    </ResponseField>

    <ResponseField name="balance" type="number" required example="50000000">
      Player's balance after the transaction.

      <Note>
        To maintain precision and avoid floating-point errors, the balance field is processed as an integer value by multiplying the actual amount by `100000`.

        For example, a balance of `12.34567` will be represented as `1234567` in the API.
      </Note>
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash Shell theme={null}
  curl --request POST \
    --url 'https://partner-platform-url/transaction/settlement' \
    --header 'content-type: application/json' \
    --header 'x-api-key: <x-api-key>' \
    --header 'x-signature: <x-signature>' \
    --header 'x-timestamp: <x-timestamp>' \
    --data '{
      "transactions": [
        {
          "transactionId": "dd96bda3-9990-4aed-9679-f451a4b82ac4",
          "refTransactionId": "21848853-1198-4dde-9a21-bb9598398a8c",
          "sessionId": "f1dfc865-584c-4cba-a175-06172b2a41141731504451691",
          "roundId": "817e22b4-b030-468b-964e-62b9a7343050-1753428290674",
          "playerId": "18865671",
          "gameId": "G1720761376617",
          "currency": "EUR",
          "amount": 250000000,
          "isWin": true
        }
      ]
  }'
  ```

  ```javascript NodeJS theme={null}
  const axios = require('axios');

  const url = 'https://partner-platform-url/transaction/settlement';
  const headers = {
      'content-type': 'application/json',
      'x-api-key': '<x-api-key>',
      'x-signature': '<x-signature>',
      'x-timestamp': '<x-timestamp>'
  };
  const data = {
      transactions: [
          {
              transactionId: "dd96bda3-9990-4aed-9679-f451a4b82ac4",
              refTransactionId: "21848853-1198-4dde-9a21-bb9598398a8c",
              sessionId: "f1dfc865-584c-4cba-a175-06172b2a41141731504451691",
              roundId: "817e22b4-b030-468b-964e-62b9a7343050-1753428290674",
              playerId: "18865671",
              gameId: "G1720761376617",
              currency: "EUR",
              amount: 250000000,
              isWin: true
          }
      ]
  };

  axios.post(url, data, { headers })
      .then(response => console.log(response.data))
      .catch(error => console.error(error));

  ```

  ```python Python theme={null}
  import requests

  url = "https://partner-platform-url/transaction/settlement"
  headers = {
      "content-type": "<content-type>",
      "x-api-key": "<x-api-key>",
      "x-signature": "<x-signature>",
      "x-timestamp": "<x-timestamp>"
  }
  data = {
      "transactions": [
          {
              "transactionId": "dd96bda3-9990-4aed-9679-f451a4b82ac4",
              "refTransactionId": "21848853-1198-4dde-9a21-bb9598398a8c",
              "sessionId": "f1dfc865-584c-4cba-a175-06172b2a41141731504451691",
              "roundId": "817e22b4-b030-468b-964e-62b9a7343050-1753428290674",
              "playerId": "18865671",
              "gameId": "G1720761376617",
              "currency": "EUR",
              "amount": 250000000,
              "isWin": True
          }
      ]
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.json())

  ```

  ```php PHP theme={null}
  <?php
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://partner-platform-url/transaction/settlement",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
      "content-type: <content-type>",
      "x-api-key: <x-api-key>",
      "x-signature: <x-signature>",
      "x-timestamp: <x-timestamp>"
    ],
    CURLOPT_POSTFIELDS => json_encode([
      "transactions" => [
        [
          "transactionId" => "dd96bda3-9990-4aed-9679-f451a4b82ac4",
          "refTransactionId" => "21848853-1198-4dde-9a21-bb9598398a8c",
          "sessionId" => "f1dfc865-584c-4cba-a175-06172b2a41141731504451691",
          "roundId" => "817e22b4-b030-468b-964e-62b9a7343050-1753428290674",
          "playerId" => "18865671",
          "gameId" => "G1720761376617",
          "currency" => "EUR",
          "amount" => 250000000,
          "isWin" => true
        ]
      ]
    ]),
  ]);

  $response = curl_exec($curl);
  curl_close($curl);

  echo $response;
  ?>

  ```
</RequestExample>

<ResponseExample>
  ```json SUCCESS theme={null}
  {
      "status": "RS_OK",
      "data": [
          {
              "status": "RS_OK",
              "transactionId": "dd96bda3-9990-4aed-9679-f451a4b82ac4",
              "refTransactionId": "21848853-1198-4dde-9a21-bb9598398a8c",
              "sessionId": "d404f1da-26a6-44ff-8b0f-559915152be11742537289208",
              "roundId": "123xaf1a-s7ax-lles-9aws-5hjtjshosqq2be117425",
              "playerId": "18865671",
              "currency": "EUR",
              "balance": 300000000
          }
      ]
  }
  ```

  ```json FAILURE theme={null}
  {
    "status": "RS_ERROR", // All bets are considered as a lost bets.
    "message": "Oops! Something went wrong. Please refresh the page or try again in a moment"
  }
  ```

  ```json PARTIAL_FAILURE theme={null}
  {
    "status": "RS_OK",
    "data": [
      {
        "status": "RS_OK", // This Transacrion will be process as normal bet would
        "transactionId": "dd96bda3-9990-4aed-9679-f451a4b82ac4",
        "refTransactionId": "21848853-1198-4dde-9a21-bb9598398a8c",
        "sessionId": "d404f1da-26a6-44ff-8b0f-559915152be11742537289208",
        "roundId": "123xaf1a-s7ax-lles-9aws-5hjtjshosqq2be117425",
        "playerId": "18865671",
        "currency": "EUR",
        "balance": 300000000
      },
      {
        "status": "RS_ERROR", // Fail transaction will be treated as lost bets
        "transactionId": "dd96bda3-9990-4aed-9679-f451a4b82ac4",
      }
    ]
  }
  ```
</ResponseExample>
