Closed anasbenyaiche closed 3 years ago
https://github.com/OrahKokos/coinpayments-ipn/issues/8#issuecomment-858495725
Yes it is out of date. Will be doing this soon enough, would really like to re-visit the entire flow and note all possible exceptions.
Thank you for your responsive answer @OrahKokos
I hope I can help with TypeScript Developers I got this and it works perfectly
import crypto from 'crypto';
import qs from 'querystring';
interface Dictionary<T> {
[index: string]: T;
}
export const coinPaymentVerify = (
hmac = ``,
ipnSecret = ``,
payload: Dictionary<
| string
| number
| boolean
| readonly string[]
| readonly number[]
| readonly boolean[]
| null
>,
) => {
if (!hmac || typeof hmac !== `string`) throw new Error('hmac');
if (!ipnSecret || typeof ipnSecret !== `string`) throw new Error('ipnSecret');
if (typeof payload !== `object`) throw new Error('payload');
const paramString = qs.stringify(payload).replace(/%20/g, '+');
const calcHmac = crypto.createHmac('sha512', ipnSecret).update(paramString).digest('hex');
if (hmac !== calcHmac) return false;
return true;
};
Here is my problem, what I went to ask is about is a TypeScript version for this Package, in fact, I'll explain more: I made the config ipn_url and I am testing with Ngrok:
and here is what I got an empty body
my point are :
req.get(`HMAC`)