So here is my problem, I work with Express JS, I am setting up payments with coinPayments, everything work npm coinpayments, however I couldn't get any body with the IPN
router.post(
`/notify`,
(req, res, next) => {
res.send('ok');
console.log('------------------------------ipn--------------------------------------');
console.log('body', req.body);
console.log('------------------------------ipn--------------------------------------');
if (
!req.get(`HMAC`) ||
!req.body.ipn_mode ||
req.body.ipn_mode !== `hmac` ||
MERCHANT_ID !== req.body.merchant
) {
return next(new Error(`Invalid request`));
}
let isValid;
let error;
try {
isValid = verify(req.get(`HMAC`), IPN_SECRET, req.body);
} catch (e) {
error = e;
}
if (error && error) {
return next(error);
}
if (!isValid) {
return next(new Error(`Hmac calculation does not match`));
}
return next();
}
I always get an empty req.body
------------------------------ipn--------------------------------------
body {}
------------------------------ipn--------------------------------------
Invalid request at router.post.txn_id.txn_id
Does anyone have an idea why , and how can I resolve it ?