Signing Requests
All requests must be sent using the POST method.
A request must be signed.
For signing requests with Content-Type: application/json, you need to use the MD5 hash of the request body, encoded in base64, concatenated with your API private key.
The JSON being sent must be sorted in alphabetical order.
For signing requests with a Content-Type different from application/json, you need to encode an empty string in base64 and concatenate it with your API private key.
Each request must include two parameters in the Header:
Parameter
Описание
Merchant
Merchant ID, which you can find in your merchant dashboard under the Integration section
Signature
The signed request body
Example of signing requests with Content-Type: application/json
const md5 = require('md5');
const API_KEY = '6b8dcc0cd0bf4e42986d6b4da7edbfd5';
const data = {
"amount": "30000",
"currency": "UZS",
"order_id": "122251322334",
"payment_type": "HUMOP2P",
"additional_data": "example",
"url_callback": "https://example.com/callback",
"url_success": "https://example.com/url_success",
"url_error": "https://example.com/url_error",
"fingerprint": "f23b9d67-9cee-4096-b9d3-492efbf32471"
};
const getSortedObject = (obj) => {
if (typeof obj !== "object" || Array.isArray(obj) || obj === null) return obj;
const sortedObject = {};
const keys = Object.keys(obj).sort();
keys.forEach(key => sortedObject[key] = getSortedObject(obj[key]));
return sortedObject;
}
const sortedObject = getSortedObject(data);
const json = JSON.stringify(sortedObject).replace(/[']/g, '');
const signature = md5(`${Buffer.from(json).toString('base64')}${API_KEY}`);<?php
$API_KEY = '6b8dcc0cd0bf4e42986d6b4da7edbfd5';
$data = [
"amount" => "30000",
"currency" => "UZS",
"order_id" => "122251322334",
"payment_type" => "HUMOP2P",
"additional_data" => "example",
"url_callback" => "https://example.com/callback",
"url_success" => "https://example.com/url_success",
"url_error" => "https://example.com/url_error",
"fingerprint": "f23b9d67-9cee-4096-b9d3-492efbf32471"
];
function getSortedArray($arr) {
if (!is_array($arr)) return $arr;
ksort($arr);
foreach ($arr as $key => $value) {
$arr[$key] = getSortedArray($value);
}
return $arr;
}
$sortedData = getSortedArray($data);
$json = json_encode($sortedData, JSON_UNESCAPED_SLASHES);
$signature = md5(base64_encode($json) . $API_KEY);
?>package main
import (
"crypto/md5"
"encoding/base64"
"encoding/hex"
"encoding/json"
"sort"
)
const (
API_KEY = "6b8dcc0cd0bf4e42986d6b4da7edbfd5"
)
func getSortedMap(obj map[string]interface{}) map[string]interface{} {
sortedObj := make(map[string]interface{})
keys := make([]string, 0, len(obj))
for key := range obj {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
value := obj[key]
if nestedMap, ok := value.(map[string]interface{}); ok {
sortedObj[key] = getSortedMap(nestedMap)
} else {
sortedObj[key] = value
}
}
return sortedObj
}
func sign(data map[string]interface{}, secret string) string {
sortedData := getSortedMap(data)
jsonData, _ := json.Marshal(sortedData)
jsonStr := string(jsonData)
hash := md5.New()
hash.Write([]byte(base64.StdEncoding.EncodeToString([]byte(jsonStr)) + secret))
signature := hex.EncodeToString(hash.Sum(nil))
return signature
}
func main() {
data := map[string]interface{}{
"amount": "30000",
"currency": "UZS",
"order_id": "122251322334",
"payment_type": "HUMOP2P",
"additional_data": "example",
"url_callback": "https://example.com/callback",
"url_success": "https://example.com/url_success",
"url_error": "https://example.com/url_error",
"fingerprint": "f23b9d67-9cee-4096-b9d3-492efbf32471"
}
signature := sign(data, API_KEY)
_ = signature
}
import json
import hashlib
import base64
API_KEY = '6b8dcc0cd0bf4e42986d6b4da7edbfd5'
data = {
"amount": "30000",
"currency": "UZS",
"order_id": "122251322334",
"payment_type": "HUMOP2P",
"additional_data": "example",
"url_callback": "https://example.com/callback",
"url_success": "https://example.com/url_success",
"url_error": "https://example.com/url_error",
"fingerprint": "f23b9d67-9cee-4096-b9d3-492efbf32471"
}
def get_sorted_dict(obj):
if not isinstance(obj, dict):
return obj
sorted_obj = {}
for key in sorted(obj.keys()):
sorted_obj[key] = get_sorted_dict(obj[key])
return sorted_obj
sorted_data = get_sorted_dict(data)
json_data = json.dumps(sorted_data, separators=(',', ':'))
hash_obj = hashlib.md5()
hash_obj.update(base64.b64encode(json_data.encode()) + API_KEY.encode())
signature = hash_obj.hexdigest()
Last updated