Webhook not working - Nodejs

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");

  }

});

It’s not being triggered, no error nothing

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.

Here is how i do the cashin

  const res = await axios.post(
    process.env.PAYPACK_BASE_URL +
      "transactions/cashin?Idempotency-Key=" +
      paymentKey,
    {
      amount,
      number,
    },
    {
      headers: {
        Authorization: "Bearer " + paymentToken,
        "Content-Type": "application/json",
        Accept: "application/json",
      },
    }
  );

  return res;

Everything else works fine except for the webhook.

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.
:warning:Note: modes are either production or development and they have to be in lowercase.

Thank you.
However, it is still not working.

const res = await axios.post(
    process.env.PAYPACK_BASE_URL +
      "transactions/cashin?Idempotency-Key=" +
      paymentKey,
    {
      amount,
      number,
    },
    {
      headers: {
        Authorization: "Bearer " + paymentToken,
        "Content-Type": "application/json",
        Accept: "application/json",
        "X-Webhook-Mode": "development"
      },
    }
  );

  return res;

Here is the configuration of the webhook

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?

It was being blocked by cors but its working now.