Skip to main content

Game server payments handler

You'll need to implement payments handler (payment script) on game server and give the link on it to our managers.

You can use for quick start our Payment Handler PHP Sample.

URL: https://example.com/payments

Method: POST

We pass parameters to the payment handler of game by POST method

Parameters

NameTypeDescription
signstringSign of request. It can be implemented like described to below - sign calculating example
item_idintegerInternal billing Item id
item_namestringItem name in store (for example com.vendor.awesome_item)
transaction_idintegerBilling transaction id
timestampintegerTime stamp of request
pricenumberPrice
amountintegerAmount of game currency for change on user game balance
user_idintegerUser Id of player
server_idintegerServer Id where user plays
test_paymentintegerThis parameter indicate when it's a test payment (1/0)

Responses

200

All responses from the payment handler must be in JSON format and encoded in UTF-8; It's necessary that in the HTTP header response was specified content type and encoding; (for example: header('Content-type', 'application/json; charset=utf-8');) Payment handler must response array with data in required format with this fields.

status - success or error

transaction_id - Transaction id in game server

error_message - If an error occurred you'll need to inform us about it reason"

// success
{
"status" : "success",
"transaction_id": 12345
}

// error
{
"status" : "error",
"error_message" : "details"
}
caution

To send additional parameters to your payment handler, please use Mobile SDK method purchaseProduct().

caution

Please, check every transaction_id from request for existense in your systems with your payment handler. If it already exists you'll need to response to us with it state (successfully purchased - successful response, otherwise try to complete it - error with details)

Sign calculating example

$privateKey = 'Secret key from our managers';
$signature = '';
$params = $_POST;
unset($params['sign']);
ksort($params);
foreach ($params as $k => $v) {
$signature .= $k . '=' . $v;
}
$signature = hash('md5', $signature . $privateKey);
if ($_POST['sign'] == $signature) {
$result = [
'status' => 'error',
'error_message' => 'Signature is incorrect.',
];
exit(json_encode($result));
}

// Other code that charge payment to game and gives response

$result = [
'status' => 'success',
'transaction_id' => 1234567, // your internal transaction id
];
echo json_encode($result);