Signature Verification

The section describes how the signature sent in the callback header can be verified. The signature is generated using an RSA Signing. For verification to succeed, the public key is required.

Download the Public Key

Download the EllyPay public key using the following API request and save it on your server.

GET https://sandbox.ellypayapp.com/merchant/download-public-key

Store the key on your server under the name ellypay.public.key.pemor whatever you prefer but maintain the .pemextension. Once the file has been downloaded, there's no need to call this API endpoint again.

Next Steps

  1. Retrieve the value of the ellypay-signature header.

  2. Form the string payload to be used in signature verification. This is obtained by concatenating values of the callback data in the format; id:internal_reference:agent_referenceand these values are obtained from the callback data. As an example, if the following was the callback data;

{
  "id": 24546,
  "amount": 30000,
  "product_code": "YAKA",
  "product_name": "UMEME YAKA",
  "agent_reference": "CSTREFYRWWVRKLG6W1P3",
  "internal_reference": "ELPREFYRWWM8FKMBH1A5A",
  "agent_commission": 700,
  "status": "SUCCESSFUL",
  "description": "Purchase completed successfully for 04250513159",
  "details": {
    "token": "6931 3037 4217 9675 2152",
    "units": 39.4,
    "customer_name": "SSUNA, RICHARD",
    "account_number": "04250513159"
  }
}

The string payload would therefore be 24546:ELPREFYRWWM8FKMBH1A5A:CSTREFYRWWVRKLG6W1P3

3. Use the public key obtained above to verify the signature as described in the sample source codes below;

<?php

public function isValidSignature() {
    $file = "path-to-file/ellypay.public.key.pem";
    $keyContent = file_get_contents($file);
    $publicKey = openssl_get_publickey($keyContent);
    $strPayload = "24546:ELPREFYRWWM8FKMBH1A5A:CSTREFYRWWVRKLG6W1P3";
    $signature = base64_decode("value-of-ellypay-signature");

    /*true or false*/
    return openssl_verify($strPayload, $signature, $publicKey, "sha256") == 1;
}

?>

A valid signature (using the production keys) for the above sample callback is shared below. You can copy and use it to test your signature verification workflow.

k5GlvInM/VHZQs/TM6vnqjpD7OwdhKgPpgEELwNyvkpRDAAP2VCXjDKWIQApDbxyext9vkPbIWRInihxVOYvXb/jasRleCs9Y/KiFo+xikRIbGfbUS4feMlDyLAQjzFwHb72cIrRCYdQyLs/cojmEo99SZXgz7MLMTu+WKryLQFpcsgZZvltxIqcGidFqAhFueooTa1cEXvp/VzkjRnP01TJuqDBb/ZxVERrny1Qe7jnDXBTCS4QhUzvpmJ86rXBaQMFU3kQo8D/lTyChBIWVHZ9z6UoA0bKYfAbdZbl4SDKJr6Cr6l78AxI5DyjTf7E0dZ/lEZPzl4L1ltMQBjwhbGq0SIREBcKARe+1lTZxRCBlDX/r6ivBatHrHF295Q1i23sUllCL3nuA9GdHffvw0lCPS73hCxmtAuKyFOKoF9hC4biSaH6t6S8zizAbcPbaPTFyiAIaabi4Et2ciCelFqFCs/J+d54+fvyalVCpmA7J8U+cSEOhCpTS+Sj/3OYZO0z62vSK3hfmra7T11Oa9ckkSpAfJf51Xf3lK3JRWzNS+wuR70xbznbYeu2Dizqjt4zbrz654L/Kz7OAAtHe4F9mf/FakLK3qZ3znfWauhB5AyTT2RSC00OqU44COGBAT/CLP4m0tedZ8k2TsIp4P0OrB1jydHxkO2gbl2rgnE=

Last updated