The EllyPay API V2 uses a key pair (API and Secret Keys) for authentication. To make an authenticated request to our API, you need to pass 4 (four) custom headers as described in this section.
Obtain the Keys
The API and Secret keys are shared in the email that's sent to you when your account is approved. These keys should sent as headers with the header names; ApiKey and SecretKey
Please ensure that your keys are stored safely and not shared with the public. In the event your keys are compromised, please contact us immediately for assistance. Please equally note the all requests will be from whitelisted IP(s) only.
Generate Request Signature
The third header is the request signature with the header name; Signature and it is generated by concatenating the API Key and the current timestamp in milliseconds. The concatenation is in the format; timestamp:ApiKey and below is the description of how the signature is generated. The final value sent in the signature header takes the format t=timestamp,s=hmac_hash
<?phpfunctiongenerateSignature() { $apiKey ="EPYPUB-****"; $secretKey ="EPYSEC-****"; $milliseconds =microtime(true)*1000; /*get current timestamp in milliseconds*/ $stringToSign = $milliseconds.":".$apiKey; $hash =hash_hmac('sha256', $stringToSign, $secretKey,false);return"t=".$milliseconds.",s=".$hash;}?>
constcrypto=require('crypto');functiongenerateSignature() {constapiKey="EPYPUB-****";constsecretKey="EPYSEC-****";constcurrentTime=newDate().getTime(); /*get current timestamp in milliseconds*/conststringToSign=`${currentTime.toString()}:${apiKey}`;consthash=crypto.createHmac("sha256", secretKey).update(stringToSign).digest("hex");return`t=${currentTime.toString()},s=${hash}`;}
importjava.security.InvalidKeyException;importjava.security.NoSuchAlgorithmException;importjavax.crypto.Mac;importjavax.crypto.spec.SecretKeySpec;publicstaticStringgenerateSignature() throws NoSuchAlgorithmException, InvalidKeyException {String apiKey ="EPYPUB-****";String secretKey ="EPYSEC-****";// Get the current timestamp in millisecondslong currentTimeMillis =System.currentTimeMillis();String currentTime =Long.toString(currentTimeMillis);String stringToSign = currentTime +":"+ apiKey;// Convert the stringToSign and key to bytesbyte[] messageBytes =stringToSign.getBytes();byte[] keyBytes =secretKey.getBytes();// Create a SecretKeySpec object with the keySecretKeySpec secretKeySpec =newSecretKeySpec(keyBytes,"HmacSHA256");// Create a Mac object with the HmacSHA256 algorithmMac mac =Mac.getInstance("HmacSHA256");// Initialize the Mac object with the SecretKeySpecmac.init(secretKeySpec);// Compute the HMACbyte[] hmac =mac.doFinal(messageBytes);// Convert the HMAC to a hexadecimal stringStringBuilder hexString =newStringBuilder();for (byte b : hmac) {hexString.append(String.format("%02x", b)); }return"t="+ currentTime +",s="+hexString.toString(); }
usingSystem;usingSystem.Security.Cryptography;usingSystem.Text;publicstaticstringGenerateSignature(){conststring apiKey ="EPYPUB-****";conststring secretKey ="EPYSEC-****"; // Get the current timestamp in millisecondslong currentTimeMillis =DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();string currentTime =currentTimeMillis.ToString();string stringToSign =$"{currentTime}:{apiKey}"; // Convert the stringToSign and key to bytesbyte[] messageBytes =Encoding.UTF8.GetBytes(stringToSign);byte[] keyBytes =Encoding.UTF8.GetBytes(secretKey); // Create a SecretKeySpec object with the keyusingvar secretKeySpec =newHMACSHA256(keyBytes); // Compute the HMACbyte[] hmac =secretKeySpec.ComputeHash(messageBytes); // Convert the HMAC to a hexadecimal stringStringBuilder hexString =newStringBuilder();foreach (byte b in hmac) {hexString.AppendFormat("{0:x2}", b); }return$"t={currentTime},s={hexString}";}
For V2 of the API to behave as expected, the fourth mandatory parameter X-API-Version needs to be passed and with the value as 2. When this header is omitted completely, the API will default to the V1 (old) authenticaiton requirements. Please also note that a value greater than 2 will not be accepted unless further improvements allow it so.
Request Headers
For all the API requests on V2, the following headers are required for the requests to succeed. These headers are obtained as described above.