that is var verifyGatewaySignature = function(proposed_signature, webhook_secret, payload_body) { var crypto = require('crypto');
var hash = crypto.createHmac('sha256', webhook_secret).update(payload_body).digest('hex');
return proposed_signature === hash; }
but I could not figure out what exactly is payload_body from documentation therefore getting wrong hash value.
I am having hard time trying to figure out correct argument for the verifyGatewaytSignature function.
I call the function using these argument right now but hash result is different from that is from req.headers[‘x-request-signature-sha-256’].
Right now I use webhook secret and payload_body.body.id to supply createHmac but I could not figure out what exactly is payload_body from documentation.
I call the function with these parameter from api router: if(!dwollaClient.verifyGatewaySignature(req.headers['x-request-signature-sha-256'],'your webhook secret', req))
exports.verifyGatewaySignature=function(proposed_signature,webhook_secret,payload_body) { var crypto = require('crypto'); var hash = crypto.createHmac('sha256',webhook_secret).update(payload_body.body.id).digest('hex') return proposed_signature === hash; }
Are you passing in the raw HTTP request body that Dwolla sends? The webhook payload will be JSON encoded and shouldn’t be re-encoded. You’ll just need to pass in the raw JSON body ‘payload_body’, and not just the id ‘payload_body.body.id’.
This does not answer the question. Could you please explain exactly what the payload_body variable is supposed to be? is it req.body? Is it an element inside body? is it from some other header? ???
Hi @Adam_Braus1 – the webhook payload body is JSON-encoded and shouldn’t need be manipulated or decoded. I’d be intrigued to know if stringifying it worked for you. Let me know!