{
  "openapi": "3.0.3",
  "info": {
    "title": "Offshore Bro wallet callback",
    "version": "1.0.0",
    "description": "Implemented by Offshore Bro at one deployment-configured URL. Separate outbound bearer token. Atomically apply balance - bet_amount + win_amount. Signed reversals are valid. Deduplicate financial payload (excluding transport timestamp) by stable serial_number; conflicts must be rejected. Return latest credit_amount with timestamp on every success AND business rejection. Successful duplicates do not mutate again. Transport failures remain unknown and are retried with the same serial. Preserve receipts and allow payout/refund recovery after sessions close or launches are suspended."
  },
  "security": [
    {
      "walletBearer": []
    }
  ],
  "paths": {
    "/wallet": {
      "post": {
        "operationId": "applyWalletEvent",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "code=0 confirmed success; code=1 confirmed business rejection. Timestamp within 60 seconds of provider clock. Non-200 or malformed responses are uncertain and retryable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "walletBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "WalletEvent": {
        "type": "object",
        "properties": {
          "player_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,80}$"
          },
          "serial_number": {
            "type": "string"
          },
          "game_id": {
            "type": "string"
          },
          "game_round": {
            "type": "string"
          },
          "currency_code": {
            "type": "string",
            "enum": [
              "INR"
            ]
          },
          "bet_amount": {
            "type": "string",
            "pattern": "^-?[0-9]{1,20}(\\.[0-9]{1,6})?$"
          },
          "win_amount": {
            "type": "string",
            "pattern": "^-?[0-9]{1,20}(\\.[0-9]{1,6})?$"
          },
          "timestamp": {
            "type": "string",
            "pattern": "^[0-9]{13}$"
          },
          "data": {
            "description": "Supplier event data, or empty object for in-house events."
          }
        },
        "required": [
          "player_id",
          "serial_number",
          "game_id",
          "game_round",
          "currency_code",
          "bet_amount",
          "win_amount",
          "timestamp",
          "data"
        ],
        "additionalProperties": false
      },
      "WalletResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              0,
              1
            ]
          },
          "msg": {
            "type": "string"
          },
          "credit_amount": {
            "type": "string",
            "pattern": "^[0-9]{1,20}(\\.[0-9]{1,6})?$"
          },
          "timestamp": {
            "type": "string",
            "pattern": "^[0-9]{13}$"
          }
        },
        "required": [
          "code",
          "msg",
          "credit_amount",
          "timestamp"
        ],
        "additionalProperties": false
      }
    }
  }
}
