Check your signature
**GET**
https://api.okepay.info/v1.0/SignatureCheck
PHPPythonJavaC#
<?php
// $instanceName is a part of the url where you access your okepay installation.
// https://{$instanceName}.okepay.com
$instanceName = 'INSTANCE_NAME';
// $secret is the okepay secret for the communication between the applications
// if you think someone got your secret, just regenerate it in the okepay administration
$secret = 'INSTANCE_API_SECRET';
$okepay = new \Okepay\Okepay($instanceName, $secret);
$signatureCheck = new \Okepay\Models\Request\SignatureCheck();
try {
$response = $okepay->getOne($signatureCheck);
die('Signature correct');
} catch (\Okepay\OkepayException $e) {
print $e->getMessage();
die('Signature wrong');
}
import urllib.request
import hmac
import hashlib
import base64
import sys
post_data = {}
data = urllib.parse.urlencode(post_data).encode('UTF-8')
dig = hmac.new(b'INSTANCE_API_SECRET', msg=data, digestmod=hashlib.sha256).digest()
post_data['ApiSignature'] = base64.b64encode(dig).decode()
post_data['instance'] = 'INSTANCE_NAME'
data = urllib.parse.urlencode(post_data)
try:
result = urllib.request.urlopen('https://api.okepay.info/v1.0/SignatureCheck/?' + data)
sys.exit("Signature correct")
except Exception as exc:
print(exc, file=sys.stderr)
sys.exit("Signature wrong")
// imports
import java.net.URLEncoder;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
// method content
String key = "INSTANCE_API_SECRET";
String data = "data1=value1&data2=value2";
data = URLEncoder.encode(data);
try {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
sha256_HMAC.init(secret_key);
String hash = Base64.getEncoder().encodeToString(sha256_HMAC.doFinal(data.getBytes("UTF-8")));
System.out.print(hash);
} catch (Exception e) {
}
# head
using System.Text;
using System.Security.Cryptography;
# function
string key = "API-SECRET";
string message = "data1=value1&data2=value2";
byte[] keyByte = new UTF8Encoding().GetBytes(key);
byte[] messageBytes = new UTF8Encoding().GetBytes(message);
byte[] hashmessage = new HMACSHA256(keyByte).ComputeHash(messageBytes);
var signature = Convert.ToBase64String(hashmessage);
QUERY PARAMS | |
---|---|
instance string |
REQUIRED Your OkePay instance name |
This endpoint can be used to verify the INSTANCE_API_SECRET to be correct. In case it is not correct, you get an error status.
Next to read:
Errors
Errors