Example of a signature
Security
Prerequisites
Integer platformId = "50"; //your platform ID
String secret = "your-api-key";
JSONObject body = new JSONObject();
body.put("orderId", "your-transaction-identifier");
body.put("paymentId", 90);
body.put("amount", "100.00");
body.put("platformId", 50); //your platform IDplatformId = 50 # your platform ID
secret = 'your-api-key'
body = {
"orderId": "your-transaction-identifier",
"paymentId": 90,
"amount": "100.00",
"platformId": 50 # your platform ID
}$platformId = 50; //your platform ID
$secret = 'your-api-key';
$body = [
"orderId" => "your-transaction-identifier",
"paymentId" => 90,
"amount" => "100.00",
"platformId" => $platformId //your platform ID
];Step 1 - Create signature.
...
ObjectMapper objectMapper = new ObjectMapper();
String bodyJson = objectMapper.writeValueAsString(body);
String signatureContract = platformId + ";" + bodyJson + ";" + secret;
String signature = generateSignature(signatureContract, secret);
...
// Helper function to generate HMAC-SHA256 signature
private String generateSignature(String signatureContract, String secret) throws NoSuchAlgorithmException, InvalidKeyException {
Mac sha256HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
sha256HMAC.init(secretKey);
byte[] hash = sha256HMAC.doFinal(signatureContract.getBytes(StandardCharsets.UTF_8));
StringBuilder result = new StringBuilder();
for (byte b : hash) {
result.append(String.format("%02x", b));
}
return result.toString();
}
serialized_body = json.dumps(body, separators=(',', ':'), ensure_ascii=False)
signature_contract = f"{platformId};{serialized_body};{secret}"
signature = hmac.new(secret.encode(), signature_contract.encode(), hashlib.sha256).hexdigest()Step 2 - Execution of the Request
Last updated