Search code examples
c#apiintegrationpaytm

How to write code for generating checksum for paytm initiate transaction api


How I should pass the values in this function Paytm.Checksum.generateSignature(paytmParams, PayTmMKey)

I want to hit initiate transaction api after generating checksum. what more values should I add for initiate transaction api.

This is how paytm doc says to implement checksum.

/* initialize an array */
Dictionary<string, string> paytmParams = new Dictionary<string, string>();

/* add parameters in Array */
paytmParams.Add("MID", "YOUR_MID_HERE");
paytmParams.Add("ORDER_ID", "YOUR_ORDER_ID_HERE");

/**
* Generate checksum by parameters we have
* Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys 
*/
String paytmChecksum = Paytm.Checksum.generateSignature(paytmParams, "YOUR_MERCHANT_KEY");
Response.Write("generateSignature Returns: " + paytmChecksum);

Link to it-https://developer.paytm.com/docs/checksum/


Solution

  • This is how we will make json string(json_for_checksum) for Initiate transaction api request and will pass this in generateCheckSumByJson function

    string json_for_checksum = "{"requestType":"Payment","mid":"" + MID + "","orderId":"" + order_id + "","websiteName":"" + Website + "","txnAmount":{"value":"" + Amount + "","currency":"INR"},"userInfo":{"custId":"WE25622"}}";

    string Check = paytm.CheckSum.generateCheckSumByJson(Merchant_key, json_for_checksum);

    Assuming you know your basic parameters in json string and download paytm dll