Reference Websites For Developers
Basically, there is Three process involving in a payment gateway. Rising Payment Request To Payment Gateway, Making Payment, Receive Payment Response. Like all payment gateways paytm also follows the above three processes for payment.
Once you leave your contact details with paytm and complete paytm simple documentation requirements, then the Staging credentials will be shared with you. Now We can start integrating the paytm in our system in sandbox environment with the staging details.
Paytm Supports mobile integration as well as web integration. in the case of mobile integration Paytm provides Android and iOS SDKs for integrating Paytm Wallet with apps. and in the case of web integration Paytm will provide some development kits , plug-in for integration. in the sense for integrating with cms systems we can use plug-in and for popular development platforms it will provide certain development kits.
How to Code
1. Make Request
Make request involves two processes .generating an array with essentials details as a key-value pair. and generate a checksum with this array and the merchant key.then rise the request to the server.
array must include the following parameters: MID(provided by paytm), CHANNEL_ID(provided by paytm), INDUSTRY_TYPE_ID(provided by paytm), WEBSITE(provided by paytm), EMAIL(Pass customer email), MOBILE(pass customer mobile number), CUST_ID(Pass a unique customer id), ORDER_ID(generate an unique order identification key and pass), TXN_AMOUNT(pass amount to pay), CALLBACK_URL(the url path to obtain response)
Example C# code
· Add paytm dll and reference
· For Generating CheckSum, use the following code snippet. Note: Replace all the values with the respective values provided by Paytm at the time of registration.
String merchantKey = “merchantKey value” ;
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("MID", "mid value");
parameters.Add("CHANNEL_ID", "channel id value");
parameters.Add("INDUSTRY_TYPE_ID","industry value");
parameters.Add("WEBSITE", "website value");
parameters.Add("EMAIL", "email value");
parameters.Add("MOBILE_NO", "mobile value");
parameters.Add("CUST_ID", "cust id");
parameters.Add("ORDER_ID", "order id");
parameters.Add("TXN_AMOUNT","amount");
parameters.Add("CALLBACK_URL","url"); //This parameter is not mandatory. Use this to pass the callback url dynamically.
string checksum = CheckSum.generateCheckSum(merchantKey, parameters);
· Define the Staging server Url here. Replace this with the Production server Url once you move to the production setup.
string paytmURL = "https://pguat.paytm.com/oltp-web/processTransaction?orderid=" + orderid;
· Use the following code snippet to make a form post. This will redirect the request to PG.
string outputHTML = "<html>";
outputHTML += "<head>";
outputHTML += "<title>Merchant Check Out Page</title>";
outputHTML += "</head>";
outputHTML += "<body>";
outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
outputHTML += "<form method='post' action='" + paytmURL + "' name='f1'>";
outputHTML += "<table border='1'>";
outputHTML += "<tbody>";
foreach (string key in parameters.Keys)
{
outputHTML += "<input type='hidden' name='" + key + "' value='" + parameters[key] + "'>";
}
outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "'>";
outputHTML += "</tbody>";
outputHTML += "</table>";
outputHTML += "<script type='text/javascript'>";
outputHTML += "document.f1.submit();";
outputHTML += "</script>";
outputHTML += "</form>";
outputHTML += "</body>";
outputHTML += "</html>";
Response.Write(outputHTML);
In Case of Mobile Sdks:
Host any checksum generation kit in the following URL on a server and call that URL to generate a checksum.and pass the key-value-pair array to the URL.
2. Obtain Response
Once the payment is completed at paytm servers it will get redirected to the call back URL we had given to paytm with the response data.here we have to verify the checksum we had obtained from paytm.
Example C# Code
· Use the following code snippet to Get the response and verify the checksum hash.
String merchantKey = “merchantKey value” ; // Replace the with the Merchant Key provided by Paytm at the time of registration.
Dictionary<string, string> parameters = new Dictionary<string, string>();
string paytmChecksum = "";
foreach (string key in Request.Form.Keys)
{
parameters.Add(key.Trim(), Request.Form[key].Trim());
}
if (parameters.ContainsKey("CHECKSUMHASH"))
{
paytmChecksum = parameters["CHECKSUMHASH"];
parameters.Remove("CHECKSUMHASH");
}
if (CheckSum.verifyCheckSum(merchantKey, parameters, paytmChecksum))
{
Response.Write("Checksum Matched");
}
else
{
Response.Write("Checksum MisMatch");
}
In Case of Mobile SDKs:
· Host any checksum generation kit in the following URL on a server and call that URL to generate a checksum.and pass the key-value-pair array to the URL.
If the checksum is verified you have to call transaction status API for double checking the transaction status. In order to call transaction status API, you have to generate a new checksum. In the parameter array, it should only contain MID, ORDER_ID.by using this parameter and merchant key you can generate a new checksum.
And call the following api :
and verify its response.
3. How to test
In the staging environment
· In staging environment, no money will be deducted
· In every 10 minutes, the staging wallet will be credited with 10000 rupees
Staging Wallet Credentials:
- Mobile Number – 7777777777
- Password – Paytm12345
- OTP – 489871
- After every 5 minutes, the Wallet balance is topped up to 7,000 Rs.
Staging CC/DC Credentials:
- Card Number -: Any live CC/DC number
- Expiry Date-: Any Future date from the transaction date
- CVV-: Any three digit number
- OTP-: 1234 (To test successful transaction)
Once all these processes is completed complete 3 successful orders and mail those order id’s to paytm…you will get production details.
Useful Links:
Thanks for sharing this great article! That is very interesting I love reading and I am always searching for informative articles like this.
ReplyDeleteStruts Training in Chennai
Struts Training Chennai
Best Struts Training in Chennai
WordPress course
Wordpress Training institute in Chennai
Struts Training in Adyar
struts Training in Anna Nagar
These are just some of the choices available to the online marketer who needs to Accept Payments Online, all have upsides and downsides, however, you have to take a gander at what you need to do and pick a couple of these administrations to begin selling your items online.
ReplyDeleteThank you for the valuable post.
ReplyDeleteYou can visit Website Design in Patna