Skip to content

Idempotence

Idempotence

What is Idempotence?

Idempotence is a property of certain operations whereby they can be applied multiple times without changing the result beyond the initial application. In the context of the GPAS API, this means that sending the same request multiple times should have the same effect as sending it once.

Importance in GPAS Integration

All operations with side effects on the wallet platform (bet, win, and reversal) must be idempotent. Sending multiple copies of the same request should have no major impact on the player’s account. The wallet platform must communicate this to GPAS via an “Already transaction” error request, as explained in the Error Response section.

Implementation Guidelines

To ensure idempotence in your implementation:

  1. Use Transaction IDs: Each transaction should have a unique identifier (externalReference) that can be used to detect duplicate requests.

  2. Check for Existing Transactions: Before processing a request, check if a transaction with the same ID has already been processed.

  3. Return Consistent Responses: If a duplicate request is detected, return the same response as was returned for the original request, not an error.

  4. Handle Partial Failures: If a transaction was partially processed when a failure occurred, ensure that retrying the same transaction either completes it or leaves it in its original state.

Example Scenario

  1. GPAS sends a debit request with a specific externalReference.
  2. The OAS processes the request, deducts the amount from the player’s balance, and returns a success response.
  3. Due to a network issue, GPAS does not receive the response and retries the same request.
  4. The OAS detects that a transaction with the same externalReference has already been processed, so it returns the same success response without deducting the amount again.

Error Handling

If a duplicate transaction is detected, the OAS should return an error response with:

  • HTTP Status Code: 400
  • Error Code: 1003
  • Error Type: DUPLICATE_TX_ID
  • Message: “Already transaction”

This informs GPAS that the transaction was already processed and prevents double-processing of the same operation.