In addition to the header,webhook-hash when calling back, there's another header with the name,dusupay-signature and this is to help merchants trust that the callbacks originate from the DusuPay servers. Signature verification can be done with the following procedure;
Retrieve the value of the dusupay-signature header.
Form the string payload to be used in signature verification. This is obtained by concatenating values of the callback data in the format that follows
id:internal_reference:transaction_status:callback_url
where callback_url is the full URL as added to your merchant account settings.
The other values are obtained from the callback data. e.g. assume the following is the callback data
and that the callback URL is
https://www.sample-url.com/callback
The string payload would therefore be
226:DUSUPAY405GZM1G5JXGA71IK:COMPLETED:https://www.sample-url.com/callback
Obtain the public key as described here and store it as a file.
Use the public key to verify the signature as described in the example source codes below;
Signature Verification Code Samples
constcrypto=require('crypto');constfs=require('fs');functionisValidSignature() {conststrPayload="226:DUSUPAY405GZM1G5JXGA71IK:COMPLETED:https://www.sample-url.com/callback";constsignature="value-of-dusupay-signature";constpublicKeyFile="path-to-file/dusupay.public.key.pem";constpublicKey=fs.readFileSync(publicKeyFile).toString().replace(/\\n/g,'\n');constverify=crypto.createVerify("SHA512");verify.write(strPayload);verify.end();/*true or false*/returnverify.verify(publicKey, signature,'base64');}