0

I am trying to integrate the Paytm Payment Gateway using API.

I've added .net 4.5 paytm.dll from their git project into my asp.net API project targeting .net framework 4.7

with this I've created checkup using below code:

String merchantKey = "hNIXDAclG8Li#D5X";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("MID", "aTSCQu39976373303724");
parameters.Add("CHANNEL_ID", "WEB");
parameters.Add("INDUSTRY_TYPE_ID", "Retail");
parameters.Add("WEBSITE", "WEBSTAGING");
parameters.Add("CUST_ID", "CUST_01");
parameters.Add("ORDER_ID", "o_1234");
parameters.Add("TXN_AMOUNT", "100.00");
parameters.Add("CALLBACK_URL", "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=o_1234");
String paytmChecksum = CheckSum.generateCheckSum(merchantKey, parameters);

using generated checksum, I'm trying to create payment like with below API call and JSON object in POSTMAN. https://securegw-stage.paytm.in/link/create

{
    "body": {
        "mid": "aTSCQu39976373303724",
        "linkType": "INVOICE",
        "linkDescription": "Test Payment",
        "linkName": "Test",
        "sendSms": false,
        "sendEmail": false
    },
    "head": {
        "tokenType": "AES",
        "signature": "lQWs6oOwK/hEpmfPN9x5GMLUe5pFpcIKdnIYQeDHT5csnul3H1RMsPfCyOQcTXB9FccSsFTbmi5R6S/BUjWCFFcjWxqgdF+jhSFY9uALLqo="
    }
}

But it response with the below error

{
    "head": {
        "version": "v2",
        "timestamp": "06/06/2020 17:56:31",
        "channelId": null,
        "signature": null,
        "tokenType": null,
        "clientId": null
    },
    "body": {
        "resultInfo": {
            "resultStatus": "FAILED",
            "resultCode": "5028",
            "resultMessage": "Checksum provided is invalid."
        }
    }
}

Can anybody have solution to this problem? Thank you in advance. Pardon me for bad grammar.

paytm.CheckSum have below methods only CheckSum methods

harsh92
  • 23
  • 7
  • Where is the checksum in the Postman Request? You calculated in code but I do not see if in the asp message. – jdweng Jun 06 '20 at 12:57
  • @jdweng paytmChecksum string variable contains the checksum which was created from web API and then used in postman call in son body. – harsh92 Jun 06 '20 at 12:59
  • @jdweng Signature in json object is the checksum. – harsh92 Jun 06 '20 at 12:59
  • 1
    A signature is not a checksum. Signature is a security check. A checksum is different. You need both the Signature and Checksum. – jdweng Jun 06 '20 at 13:01
  • @jdweng Can you show me how to use signature and checksum in json? – harsh92 Jun 06 '20 at 13:03
  • @jdweng this Document show checksup as signature: https://developer.paytm.com/docs/initiate-transaction-api/?ref=payments – harsh92 Jun 06 '20 at 13:06
  • Looks like the signature in this case is the checksum. But you have create the signature on the entire BODY not just the key. See : https://developer.paytm.com/docs/checksum/ – jdweng Jun 06 '20 at 13:10
  • I tried using two parameter as shows in document. but same result ```Dictionary parameters = new Dictionary(); parameters.Add("MID", "aTSCQu39976373303724"); parameters.Add("ORDER_ID", "o_1234");``` – harsh92 Jun 06 '20 at 13:15
  • I see for jason request : paytmChecksum = PaytmChecksum.generateSignature(body, "YOUR_MERCHANT_KEY"); – jdweng Jun 06 '20 at 13:20
  • @jdweng paytm.checksum does not have 'generateSignature' method. it have 'generateCheckSum' method. – harsh92 Jun 06 '20 at 13:31
  • That is for a Form Post Request and you do not have a POST. – jdweng Jun 06 '20 at 14:13
  • @jdweng i didn't understand. please explain – harsh92 Jun 08 '20 at 10:49
  • The link I provided has following : paytmChecksum = PaytmChecksum.generateSignature(body, "YOUR_MERCHANT_KEY"); to add checksum for entire body. Why aren't you using the generatureSignature. – jdweng Jun 08 '20 at 11:05
  • @jdweng because paytm.dll which is provided from their git has no generatureSignature method. it have paytm.CheckSum.generateCheckSum() method only. – harsh92 Jun 08 '20 at 11:10
  • Is this the payment request you are sending (https://developer.paytm.com/docs/show-payment-page/?ref=payments)? There is a link under ChecksumHash to show how to calculate the checksum. You can capture the request using a sniffer like wireshark or fiddler and then compare with the documentation to see what is causing the error. Not sure if the format of request is wrong or the generation of the checksum. – jdweng Jun 08 '20 at 11:28
  • @jdweng no i am using https://developer.paytm.com/docs/create-link-api/?ref=paymentLinks this to create payment link alright start from beginning, Now I've paytmChecksum = PaytmChecksum.generateSignature(body, "YOUR_MERCHANT_KEY"); with this i create checksum from my API project with these two parameters parameters.Add("MID", "aTSCQu39976373303724"); parameters.Add("ORDER_ID", "wredxwercwea"); but result is same( "resultInfo": { "resultStatus": "FAILED", "resultCode": "5028", "resultMessage": "Checksum provided is invalid."}). – harsh92 Jun 08 '20 at 11:40
  • Does vendor have a Net 4.7 version of dll? there are changes in default encryption methods in Net 4.7 and net 4.8 which may be causing issue. You could also try targeting Net 4.5 to see if that fixes issue. – jdweng Jun 08 '20 at 11:52
  • @jdweng i tried with .Net 4.5 and 4.7. but both case have same issue. – harsh92 Jun 09 '20 at 18:27
  • Typically, an API provider will give you a sample record **and it's checksum**, and you use that to validate your code can produce the correct checksum. – Joel Coehoorn Jun 09 '20 at 18:32
  • @JoelCoehoorn yes i know api provider gives sample record. I've created checksum, but at the time of initiate transaction API(use to get transaction token for further payment process) gives response with error says "Checksum provided is invalid." even though I use same parameter everywhere. – harsh92 Jun 11 '20 at 13:47
  • So what you should do is edit the question to use their sample record data, include their checksum in the question, and show how your code produces the same checksum value. – Joel Coehoorn Jun 11 '20 at 13:48

0 Answers0