I'm trying to verify a webhook sent by stripe in my hapi.js app. I've followed the instructions detailed here:
https://stripe.com/docs/webhooks/signatures
(I've obviously not posted my endpoint secret here :)
<!-- language: lang-js -->
const enpointSecret = ######;
const sig = _.fromPairs(request.headers["stripe-signature"].split(',')
.map(s => s.split('=')));
// produces object eg { t: '1111', v1: '111111..', v0: '...'} etc
const signed_payload = `${sig.t}.${JSON.stringify(request.payload)}`;
const hmac = crypto.createHmac('sha256', endpointSecret)
.update(signed_payload)
.digest('hex');
The generated hmac does NOT match the signature in the header (sig.v1). I can't figure out what I'm doing wrong...
I'm developing locally - and using ngrok, so that i can test my webhooks. Could this be an issue? Thanks