๐Ÿ”Hash String Validation

Essential credentials required to integrate: API Encryption Key

To ensure that the data comes from the RGS-CWS and it is trustworthy, please validate the hashed_result variable that we send to your endpoints inside the body.

Apply hash_hmac('sha256',$picked_fields,$api_encryption_key) to the enumerated values (see $picked_fields below) and then compare your computed HMAC with the value of hashed_result.

If mismatch, it means that the data is insecure and you should reject it.
If it matches, it means that the data source can be trusted.

$picked_fields is a json_string composed of these fields, in the exact same order: command,timestamp,login,internal_session_id,uniqid,type,userid,custom_data,amount(not in getbalance),gameid(not in getbalance),gpid(not in getbalance),currency

Sample code in PHP for hmac signing (make sure to respect the given order):

getbalance Endpoint:

hash_hmac('sha256', json_encode(array(
$data['command'], 
$data['timestamp'], 
$data['login'], 
$data['internal_session_id'], 
$data['uniqid'], 
$data['type'], 
$data['userid'], 
$data['custom_data'],
$data['currency']), 
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), $api_encryption_key);

balance_adj Endpoint

hash_hmac('sha256', json_encode(array(
$data['command'], 
$data['timestamp'], 
$data['login'], 
$data['internal_session_id'], 
$data['uniqid'], 
$data['type'], 
$data['userid'], 
$data['custom_data'], 
$data['amount'],
$data['gameid'],
$data['gpid'],
$data['currency']), //compared to getbalance, we also have the amount field
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), $api_encryption_key);
๐ŸŒServer IP Validation

Additionally, we recommend to validate the IP from which you receive the data and to make sure that it is the RGS-CWS Server IP.

โŒšTimestamp validation

Each request that we send to your API will contain a variable named timestamp in the request.
Each response that we return to your commands will contain a variable named timestamp in the response.

This will have the format of YYYY-mm-dd HH:mm:ss and will be used to inform your server about the time when the output was generated. In the requests we send to your wallet endpoints it is GMT. In the replies to your commands it is written in the time zone configured on the RGS-CWS server, which is not necessarily GMT: ask the CWS support which time zone your server uses. The Get Server Time command returns the server's clock in GMT.

This timestamp response can be used to verify if the RGS-CWS system response was made within a certain time (for example within 30 seconds and that you are not using outdated or very old data).