diff --git a/dist/doc/payments/webhooks/verifying-transaction.js b/dist/doc/payments/webhooks/verifying-transaction.js index 7daaaa4..5365098 100644 --- a/dist/doc/payments/webhooks/verifying-transaction.js +++ b/dist/doc/payments/webhooks/verifying-transaction.js @@ -1,9 +1,15 @@ const js = `const crypto = require('crypto'); const secret = process.env.SECRET_KEY; // Using Express +app.use(express.json({ + verify: (req, res, buf) => { + req.rawBody = buf; + } +})); + app.post("/my/webhook/url", function(req, res) { //validate event - const hash = crypto.createHmac('sha512', secret).update(JSON.stringify(req.body)).digest('hex'); + const hash = crypto.createHmac('sha512', secret).update(req.rawBody).digest('hex'); if (hash == req.headers['x-paystack-signature']) { // Retrieve the request's body const event = req.body; diff --git a/src/doc/payments/webhooks/verifying-transaction/index.js b/src/doc/payments/webhooks/verifying-transaction/index.js index 7079724..ac16476 100644 --- a/src/doc/payments/webhooks/verifying-transaction/index.js +++ b/src/doc/payments/webhooks/verifying-transaction/index.js @@ -1,9 +1,15 @@ const crypto = require('crypto'); const secret = process.env.SECRET_KEY; // Using Express +app.use(express.json({ + verify: (req, res, buf) => { + req.rawBody = buf; + } +})); + app.post("/my/webhook/url", function(req, res) { //validate event - const hash = crypto.createHmac('sha512', secret).update(JSON.stringify(req.body)).digest('hex'); + const hash = crypto.createHmac('sha512', secret).update(req.rawBody).digest('hex'); if (hash == req.headers['x-paystack-signature']) { // Retrieve the request's body const event = req.body;