I can’t seem to get the webhook to work.
I’m not using the SDK, I have followed the documentation and also tried to troubleshoot it using the steps provided in the documentation but still not working.
Here are my codes
router.post("/webhook", async (req, res) => {
//Extract X-Paypack-Signature headers from the request
const requestHash = req.get("X-Paypack-Signature");
//secret which you can find on your registered webhook
const secret = process.env.PAYPACK_WEBHOOK_SIGN_KEY;
//Create a hash based on the parsed body
const hash = crypto
.createHmac("sha256", secret)
.update(typeof req.rawBody === "undefined" ? "" : req.rawBody)
.digest("base64");
// Compare the created hash with the value of the X-Paypack-Signature headers
if (hash === requestHash || req.method != "HEAD") {
//Do your work here!
console.log("Webhook is originating from Paypack");
} else {
console.log("Signature is invalid, rejected");
}
});
You’re right this is the right implementation of receiving and verifying webhooks from our system. Can you also provide a simple implementation of requesting or sending funds(cashin or cashout) so that I can verify that the function is also correct.
When initiating a transaction you need to pass a header that tells our systems what environment you are using. the header is X-Webhook-Mode and it correspond to the mode of the webhook on the dashboard.
Note: modes are either production or development and they have to be in lowercase.
The webhooks are being sent to that endpoint as I can see in our systems, I am not sure why you’re not receiving them. Can you try using https://webhook.site/ and confirm that they are not arriving?