Open dasgupta002 opened 3 years ago
Most likely you are there is property in your paytm object which is not String. Check your txnAmount property.
Kindly pass the body / paytmParams object to generateSignature Method as a String
So for example, If you're using Node / JS just pass the body object as PaytmChecksum.generateSignature(JOSN.stringify(body), Your_Merchent_KEY)
Hi There,
This is still an in issue in the case there is a nested object. Although JSON.stringify()
solves the checksum generation issue, but the checksum does not match when the request is sent to the API.
function collectRequest(amount) {
const head = {
version,
requestTimeStamp: time,
channelId,
checksum: "",
};
const body = {
paytmMid,
paytmTid,
transactionDateTime: time,
merchantTransactionId: moment().unix().toString(),
transactionAmount: (amount * 100).toString(),
merchantExtendedInfo: {
autoAccept: true,
},
};
var paytmChecksum = PaytmChecksum.generateSignature(
JSON.stringify(body),
merchantKey
);
paytmChecksum
.then(function (result) {
head.checksum = result;
const request = {
head: {
...head,
},
body: {
...body,
},
};
axios
.post(`${url}/request`, request, {
headers: {
"Content-Type": "application/json",
},
})
.then(function (response) {
console.log(response.data.body);
})
.catch(function (error) {
console.log(error);
});
})
.catch(function (error) {
console.log(error);
});
}
collectRequest(100);
The above code produces the following response
{
merchantTransactionId: '1674033160',
paytmMid: 'XXXXXXXXXXX',
paytmTid: 'XXXXXXX',
resultInfo: {
resultStatus: 'FAIL',
resultCode: 'F',
resultMsg: 'Invalid checksum',
resultCodeId: '0330'
}
}