General

1. Forming a request to send to the server

Query data

Value Description Type
version API Version int (4)
lang Interface language string (2)
cmd Command string
sid Unique Merchant ID string (10)
data Data object
mktime Date and time in microseconds string
hash Query signature string (32)

All requests are sent by POST method in Content-type: application/json; format and encoded in UTF-8

Actual URL https://api2.mobipay.ua/api/json/json.php

JSON query example

{
  "cmd": "getOTP",
  "version": 1005,
  "sid": "1000000001",
  "mktime": "1487602271287",
  "lang": "ru",
  "data": {
    "return_url": null
  },
  "hash": "72d4a48dc7fe890af8beb00cd440c12d"
}
2. Forming hash to sign the query

To create hash, you must use the HMAC-MD5 encryption algorithm

Create a request in the format JSON, encrypt it with the HMAC-MD5 algorithm using the password

An example of a query before creating its signature

{"cmd":"getOTP","version":1005,"sid":"1000000001","mktime":"1487602271287","lang":"ru","data":{"return_url":null}}

An example of signature generaton in PHP programming language

$passw = 'Z@(K0APS@B~MW1Q';
$json = '{"cmd":"getOTP","version":1005,"sid":"1000000001","mktime":"1487602271287","lang":"ru","data":{"return_url":null}}';
$hash = hash_hmac('md5', $json, $passw);

An example of signature generaton in JavaScript programming language

var passw = 'Z@(K0APS@B~MW1Q';
var json = '{"cmd":"getOTP","version":1005,"sid":"1000000001","mktime":"1487602271287","lang":"ru","data":{"return_url":null}}';
var hash = CryptoJS.HmacMD5(json, passw).toString();
Please note that before the signature is generated, in the JSON query, there is no signature!
If you use the PHP programming language and create JSON using the json_encode function, be sure to use the JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES flag
When sending web links in queries, use the URL-encoding functions of strings (PHP-urlencode; JavaScript-encodeURIComponent)
Library CryptoJS can be downloaded here Link
3. Ready-made API modules