SHA256 webhook signature from WooCommerce never verifies

后端 未结 6 949
再見小時候
再見小時候 2021-01-02 23:47

I am receiving webhooks from a woocommerce site into a nodejs/express application. I am trying to verify the webhook\'s signature to prove authenticity, yet the hash I compu

6条回答
  •  一向
    一向 (楼主)
    2021-01-03 00:30

    For people using node, this should do the trick.

    var processWebHookSignature = function (secret, body, signature) {
      signatureComputed = crypto.createHmac('SHA256', secret).update(
        new Buffer(JSON.stringify(body), 'utf8')).digest('base64');
    
      return ( signatureComputed === signature ) ? true : false;
    }
    

提交回复
热议问题