Payment handler
Parameters that pass to the payment handler of game (Payment script) by POST method after calling showOrderBox from JavaScript API.
Parameters | Data type | Description |
---|---|---|
client_id | string | Game identificator |
item | int | Game item that user want buy |
uid | int | User identificator on portal 101XP.com |
credits | float | The cost of purchased item in currency for example in rubles |
transaction_id | int | Billing transaction identificator |
test_payment | int | Test payment flag (is present in the request only if the test payments) |
sig | string | Request 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'}