question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Razorpay.validateWebhookSignature() is not working for invoice.paid events.

See original GitHub issue

Here is code snippet

    let body = req.body;
    let received_signature = req.get("x-razorpay-signature");
    let secret = "xxxx";

    var success = Razorpay.validateWebhookSignature(
      JSON.stringify(body),
      received_signature,
      secret
    );

Razorpay.validateWebhookSignature() returns true for other webhook events but for events type “invoice.type” it is returning false.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
captn3m0commented, Aug 14, 2019
 JSON.stringify(body),

Please don’t parse the JSON. The HMAC is generated for the exact request body that we send, and a minor difference in how your JSON encoder works v/s ours will result in a different JSON string (and broken signature). This is often the case where your descriptions contain quotes or slashes.

Instead read the raw response body in your framework of choice and pass that instead as the first argument to validateWebhookSignature. Please see your framework documentation on how to do the same.

cc @harman28

0reactions
krishnaowcommented, Apr 17, 2020
let  reqBody = req.body;
let signature = req.headers["x-razorpay-signature"];
let isSignValid = await razorpay.validateWebhookSignature(
                        reqBody,
                        signature,
                        env.webhookSecret
                        );

Here also same issue, Anybody know the solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Razorpay.validateWebhookSignature() is not working for ...
validateWebhookSignature() returns true for other webhook events but for events type "invoice.paid" it is returning false. I am using Razorpay ...
Read more >
Razorpay.validateWebhookSignature() is not working for ...
I am getting "false" for "payment.captured" event with this code. var signature = req.get('X-Razorpay-Signature'); const validate = Razorpay.
Read more >
Validate and Test Webhooks | Razorpay Docs
Validate and test the webhook before you start using them. Understand Idempotency and the importance of the order of Webhook Events.
Read more >
Invoices | Subscribe to Webhooks | Razorpay Docs
Subscribe to various webhook events related to Invoices to receive instant notifications. ... Triggered when a partial payment is made against an invoice....
Read more >
Webhooks | Razorpay Docs
Use webhooks to get notified about events related to the Razorpay payment flow such as orders, payments, settlements, disputes and workflow steps related...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found