Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dist/doc/payments/webhooks/verifying-transaction.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/doc/payments/webhooks/verifying-transaction/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down