Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whenever the Merchant Key is parsed in the checksum.js in the getStringByParams() function the segement params[key].toLowerCase() function throws a type error. Is there any need of that, seems not needed there. After removing the fragmnet the code snippet runs. Any insights? #4

Open
dasgupta002 opened this issue Jul 29, 2021 · 3 comments

Comments

@dasgupta002
Copy link

paytm_checksum

@shamssahal
Copy link

Most likely you are there is property in your paytm object which is not String. Check your txnAmount property.

@bvsk279
Copy link

bvsk279 commented Nov 11, 2022

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)

@sameerjoshi
Copy link

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'
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants