Paytm Payment Gateway Integration with .Net MVC
In this article, I’m going to write about how to Integrate Paytm Payment Gateway with NET MVC 5
Step 1 – Create Paytm Payment Gateway Sandbox Account
you can simply create paytm business production or sandbox account from this link Click here
This link is for paytm integration documentation where you found a request and response parameters Click here
Step 2 – Create New Project In Visual Studio 2015 or More
Install paytm.dll CLICK HERE FOR DOWNLOAD DLL
Step 3 – Save Merchant Key and Id of Payment Gateway
Create a class in project and past this code
Create a class in Model and past this code
New Model for Payment response
Step 4 – Create view page for User send amount to paytm
Step 5 – Create Home Controller
[HttpPost]
public ActionResult About(WebApplication2.Models.Request r)
{
String callbackUrl = "http://localhost:57380/Home/PaytmResponse";
string marchantkey = Class1.marchantkey;
Dictionary<String, String> paytmParams = new Dictionary<String, String>();
paytmParams.Add("MID", Class1.marchantId);
paytmParams.Add("CHANNEL_ID", "WEB");
paytmParams.Add("WEBSITE", "WEBSTAGING");
paytmParams.Add("CUST_ID", "1");
paytmParams.Add("MOBILE_NO", r.Mobail);
paytmParams.Add("EMAIL", r.Email);
paytmParams.Add("ORDER_ID", "23343ewe34");
paytmParams.Add("INDUSTRY_TYPE_ID", "Retail");
paytmParams.Add("TXN_AMOUNT", r.Amount);
paytmParams.Add("CALLBACK_URL", callbackUrl);
string paytmChecksum = paytm.CheckSum.generateCheckSum(Class1.marchantkey, paytmParams);
string transactionURL = "https://securegw-stage.paytm.in/theia/processTransaction";
try
{
string outputHTML = "<html>";
outputHTML+=("<head>");
outputHTML+=("<title>Merchant Checkout Page</title>");
outputHTML+=("</head>");
outputHTML += ("<body>");
outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
outputHTML += "<form method='post' action='" + transactionURL + "' name='f1'>";
outputHTML += "<table border='1'>";
outputHTML += "<tbody>";
foreach (string key in paytmParams.Keys)
{
outputHTML += "<input type='hidden' name='" + key + "' value='" + paytmParams[key] + "'>'";
}
outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + paytmChecksum + "'>";
outputHTML += "</tbody>";
outputHTML += "</table>";
outputHTML += "<script type='text/javascript'>";
outputHTML += "document.f1.submit();";
outputHTML += "</script>";
outputHTML += "</form>";
outputHTML += "</body>";
outputHTML += "</html>";
ViewBag.list = outputHTML;
return View("PaymentPage");
}
catch (Exception ex)
{
Response.Write("Exception message: " + ex.Message.ToString());
}
return View();
}
fill all the filed and click save button and go to paytm payment page with the parameter.
I think this document helpfully for all. if any issue please comment me for improve my coding.
[HttpPost]
public ActionResult About(WebApplication2.Models.Request r)
{
String callbackUrl = "http://localhost:57380/Home/PaytmResponse";
string marchantkey = Class1.marchantkey;
Dictionary<String, String> paytmParams = new Dictionary<String, String>();
paytmParams.Add("MID", Class1.marchantId);
paytmParams.Add("CHANNEL_ID", "WEB");
paytmParams.Add("WEBSITE", "WEBSTAGING");
paytmParams.Add("CUST_ID", "1");
paytmParams.Add("MOBILE_NO", r.Mobail);
paytmParams.Add("EMAIL", r.Email);
paytmParams.Add("ORDER_ID", "23343ewe34");
paytmParams.Add("INDUSTRY_TYPE_ID", "Retail");
paytmParams.Add("TXN_AMOUNT", r.Amount);
paytmParams.Add("CALLBACK_URL", callbackUrl);
string paytmChecksum = paytm.CheckSum.generateCheckSum(Class1.marchantkey, paytmParams);
string transactionURL = "https://securegw-stage.paytm.in/theia/processTransaction";
try
{
string outputHTML = "<html>";
outputHTML+=("<head>");
outputHTML+=("<title>Merchant Checkout Page</title>");
outputHTML+=("</head>");
outputHTML += ("<body>");
outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
outputHTML += "<form method='post' action='" + transactionURL + "' name='f1'>";
outputHTML += "<table border='1'>";
outputHTML += "<tbody>";
foreach (string key in paytmParams.Keys)
{
outputHTML += "<input type='hidden' name='" + key + "' value='" + paytmParams[key] + "'>'";
}
outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + paytmChecksum + "'>";
outputHTML += "</tbody>";
outputHTML += "</table>";
outputHTML += "<script type='text/javascript'>";
outputHTML += "document.f1.submit();";
outputHTML += "</script>";
outputHTML += "</form>";
outputHTML += "</body>";
outputHTML += "</html>";
ViewBag.list = outputHTML;
return View("PaymentPage");
}
catch (Exception ex)
{
Response.Write("Exception message: " + ex.Message.ToString());
}
return View();
}
Step 6 – Make new view page
Create the view page and show view-bag html form.
Second Preview
------------------------------------
NOTE:-ALL THE PARAMETERS PASS DYNAMIC THROUGH CONTROLLER
I JUST PASS THE VALUE STATIC.I think this document helpfully for all. if any issue please comment me for improve my coding.
thanks
ReplyDeleteit is going to callbackUrl
ReplyDeleteCan you please post solution with source code
ReplyDeleteI have the entire solution. Please share your email id I will send you the zip file
ReplyDeleteplz send me the solution with source code of payment gateway at neeraj.vce@gmail.com...thank you sir
Deleteplz send the source code in rajesh@ebaraha.com
DeleteNeed asp.net c# code.
Please share the complete code of this project
DeletePlease send me the code My emailId : cmsanaullah@gmail.com
ReplyDeleteit is not redirecting to debit card page
ReplyDeleteHello Can you please post the solution. Maulinshah1015@gmal.com
ReplyDeleteHello Rakesh, Can you please share your contact number. Actually I am having some problem with callback URL so i can discuss with you.
ReplyDeleteThis review was so good and cool, I never imaging I would be able to get a post like this that is so important about Paypal. Really, over some years I have had people complaining about Paypal, thank you once more for the update you are great in developing contents and informaton.
ReplyDeletehttps://www.tecteem.com/paypal-login/
please share complete code @ jitu.garhwal2015@gmail.com
ReplyDeleteYour blog has been giving updates recently and i appreciate it. I never would have mentioned but i just wanted to let you know. I hope you accept my comment as others reading your blog would be able to see it too and know that your work is appreciated. Lest i forget to mention, you have good writing skills and i would love to talk to you one on one.
ReplyDeleteI left my contact information here ==> https://tecteem.com/toxicwap-download-free-tv-series-musics-movies-games-videos-toxicwap-com/
Your website is really cool and this is a great inspiring article. White Label Merchant Services
ReplyDeleteThanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. North American Bancard Agent Program
ReplyDelete