HMAC Signature Verification
The section describes how the hmac signature sent in the callback header can be verified
Obtain the Signing Key
The signing key is an alpha-numeric string generated by our platform during your merchant account creation and it is stored against your account record. This value can be found under your account details in the merchant dashboard. EllyPay uses this value to create the HMAC signature and the same will be used when verifying the signature. It is recommended that it is copied and stored safely together with the security keys.
Below is the sample callback data to be used for the demonstration;
{
"event": "transaction.charges",
"payload": {
"id": 11832,
"merchant_reference": "MCTREFNGKLP5VQCQSBH2",
"internal_reference": "ELPREFA65BGTFR7NGUXM",
"transaction_type": "COLLECTION",
"request_currency": "UGX",
"transaction_amount": 100000,
"transaction_currency": "UGX",
"transaction_charge": 4000,
"transaction_account": "256777000001",
"charge_customer": false,
"total_credit": 96000,
"provider_code": "mtn_momo_ug",
"request_amount": 100000,
"institution_name": "MTN Mobile Money Uganda",
"customer_name": "JOHN DOE",
"transaction_status": "PENDING",
"status_message": "Collection initialized successfully. Confirm charges"
}
}Next Steps
Obtain the value of the
hmac-signatureheader. The value sent in the signature header takes the formatt=timestamp,s=hmac_hashForm the string payload to be used in signature verification. This is obtained by concatenating values of the callback data in the format;
event:merchant_reference:internal_reference:transaction_type:transaction_statusand these values are obtained from the callback data. The string payload in this case would therefore betransaction.charges:MCTREFNGKLP5VQCQSBH2:ELPREFA65BGTFR7NGUXM:COLLECTION:PENDINGCreate the hmac hash of the string payload.
Compare the resulting hash to the value in the hmac-signature header. Equality means the signature is valid.
Below is a sample signature generated using the signing key: SGNKYLSPUJKZBKQH5YVU
Last updated