I am started to implement some API to my marketplace. I am using Shoppy.gg for get some cryptopayments. And i have got a problem about the verify their callbacks from my back end.
In their documentation explain to how validate shoppy with php:
$signature = hash_hmac('sha512', file_get_contents('php://input'), 'secret');
$is_valid = hash_equals($signature, $_SERVER['HTTP_X_SHOPPY_SIGNATURE']);
And i am trying to do it with nodejs express module
const signature = req.header('x-shoppy-signature')
const verifySignature = sha512(JSON.stringify(req), shoppyWebhookSecret)
if(signature !== verifySignature) return res.json({status: "error", message: "payment-hash-wrong"})
But in my code, ivgot an exception about Converting circular structure to JSON. Am i understand this documentation wrong ? Shouldnt i create sha512 hash from request by using my secret key ?
Edit:
Also i thought maybe it can be gave url encoded string in php and i do it with javascript as coded following:
var verifySignature = sha512(new URLSearchParams(req.body).toString(), shoppyWebhookSecret)
but doesnt works too.
The documentation:
https://shoppy.dev/#/webhooks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…