HMAC Signature Verification
The section describes how the HMAC signature sent in the callback header OR in the redirect data 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. Qwaap 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.completed",
"payload": {
"id": 34809,
"merchant_reference": "MCTREF5JSPCLU2JHDAAZ",
"internal_reference": "QWAAPWJYJXTAUN65FRF",
"transaction_type": "COLLECTION",
"request_currency": "UGX",
"request_amount": 70000,
"transaction_currency": "UGX",
"transaction_amount": 70000,
"transaction_charge": 2100,
"transaction_account": "256787009959",
"customer_name": "JOHN DOE",
"charge_customer": false,
"total_credit": 67900,
"provider_code": "mtn_ug",
"transaction_status": "COMPLETED",
"status_message": "Transaction Completed Successfully"
}
}Next Steps
Obtain the value of the
hmac-signatureheader (if callback) OR the value of thehmac_signaturequery parameter (if redirect). 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/redirect data in the format;
event:merchant_reference:internal_reference:transaction_type:transaction_statusand these values are obtained from the callback/redirect data. The string payload in this case would therefore betransaction.completed:MCTREF5JSPCLU2JHDAAZ:QWAAPWJYJXTAUN65FRF:COLLECTION:COMPLETEDCreate 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 (on the sandbox environment): SGNKYVKSFLRJKJ9UELH6
Last updated