RangeError:Paytm网关校验和的密钥长度无效



当我发送GET请求时,我会收到以下代码的内部服务器错误。我正在使用strapi并集成Paytm网关。

这是我启动支付的代码:

paytmParams.body = {
"requestType": "Payment",
"mid": process.env.MID,
"websiteName": "YOUR_WEBSITE_NAME",
"orderId": "ORDERID_98765",
"callbackUrl": "http://localhost:1337/api/orders/posttransaction",
"txnAmount": {
"value": "1.00",
"currency": "INR",
},
"userInfo": {
"custId": "CUST_001",
},
};
/*
* Generate checksum by parameters we have in body
* Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys 
*/
let checksum = await PaytmChecksum.generateSignature(JSON.stringify(paytmParams.body), 
process.env.MKEY);

GitHub Repo:https://github.com/anmol009a/my-shop/tree/master/backend

错误:

RangeError: Invalid key length
at Cipheriv.createCipherBase (node:internal/crypto/cipher:116:19)
at Cipheriv.createCipherWithIV (node:internal/crypto/cipher:135:3)
at new Cipheriv (node:internal/crypto/cipher:243:3)
at Object.createCipheriv (node:crypto:138:10)
at Function.encrypt (backendnode_modulespaytmchecksumPaytmChecksum.js:8:23)
at Function.calculateChecksum (backendnode_modulespaytmchecksumPaytmChecksum.js:90:24)
at Function.generateSignatureByString (backendnode_modulespaytmchecksumPaytmChecksum.js:52:24)
at async Object.exampleAction (backendsrcapiordercontrollerscustom.js:38:20)
at async returnBodyMiddleware (backendnode_modules@strapistrapilibservicesservercompose-endpoint.js:52:18)
at async policiesMiddleware (backendnode_modules@strapistrapilibservicesserverpolicy.js:24:5)

用Paytm提供的密钥替换Paytm MKEY和MID。或者使用ScryptSync函数生成Mkey。

crypto.scryptSync(password, salt, keylen[, options])

最新更新