When I send a GET request I get an Internal server error for the below code. I am using strapi and integrating Paytm gateway.
This is my code to initiate payment:
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
Error:
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 (backend\node_modules\paytmchecksum\PaytmChecksum.js:8:23)
at Function.calculateChecksum (backend\node_modules\paytmchecksum\PaytmChecksum.js:90:24)
at Function.generateSignatureByString (backend\node_modules\paytmchecksum\PaytmChecksum.js:52:24)
at async Object.exampleAction (backend\src\api\order\controllers\custom.js:38:20)
at async returnBodyMiddleware (backend\node_modules\@strapi\strapi\lib\services\server\compose-endpoint.js:52:18)
at async policiesMiddleware (backend\node_modules\@strapi\strapi\lib\services\server\policy.js:24:5)
Replace Paytm MKEY and MID with keys provided by Paytm. Or use ScryptSync function to generate Mkey.
crypto.scryptSync(password, salt, keylen[, options])