Skip to main content

Payment handler

Parameters that pass to the payment handler of game (Payment script) by POST method after calling showOrderBox from JavaScript API.

ParametersData typeDescription
client_idstringGame identificator
itemintGame item that user want buy
uidintUser identificator on portal 101XP.com
creditsfloatThe cost of purchased item in currency for example in rubles
transaction_idintBilling transaction identificator
test_paymentintTest payment flag (is present in the request only if the test payments)
sigstringRequest signature

Signature calculation of the payment request:

$params = $_POST;
unset($params['sig']);
ksort($params);
$sig = '';
foreach($params as $k => $v){
$sig .= $k.'='.$v;
}
$sig = md5($sig . $private_key);
if($_POST['sig'] != $sig){
$response = array(
'status' => '0',
'error_msg' => 'Invalid signature'
);
die(json_encode($response));
}
// Other code that charge payment to game and gives response
warning

payment handler must check for each request:

  • Request signature;
  • Existing of game item that user want buy;
  • Equality of prices.

Responses from payment handler:

  • 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');)
  • If payment is successful it's response must look like: {status:1}
  • If an error occurred in payment handler it's response must look like: {status:2,error_msg:'details'}