Thursday, November 15, 2018

Paytm Payment Gateway in .Net MVC



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

Create a anther 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();

        }

Step 6 – Make new view page 

Create the view page and show view-bag html form.





@Html.Raw(ViewBag.list)



First Preview
------------------------------------

 fill all the filed and click save button and go to paytm payment page with the parameter.


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.

16 comments:

  1. Can you please post solution with source code

    ReplyDelete
  2. I have the entire solution. Please share your email id I will send you the zip file

    ReplyDelete
    Replies
    1. plz send me the solution with source code of payment gateway at neeraj.vce@gmail.com...thank you sir

      Delete
    2. plz send the source code in rajesh@ebaraha.com
      Need asp.net c# code.

      Delete
    3. Please share the complete code of this project

      Delete
  3. Please send me the code My emailId : cmsanaullah@gmail.com

    ReplyDelete
  4. it is not redirecting to debit card page

    ReplyDelete
  5. Hello Can you please post the solution. Maulinshah1015@gmal.com

    ReplyDelete
  6. Hello Rakesh, Can you please share your contact number. Actually I am having some problem with callback URL so i can discuss with you.

    ReplyDelete
  7. This 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.
    https://www.tecteem.com/paypal-login/

    ReplyDelete
  8. please share complete code @ jitu.garhwal2015@gmail.com

    ReplyDelete
  9. Your 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.
    I left my contact information here ==> https://tecteem.com/toxicwap-download-free-tv-series-musics-movies-games-videos-toxicwap-com/

    ReplyDelete
  10. Your website is really cool and this is a great inspiring article. White Label Merchant Services

    ReplyDelete
  11. Thanks 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

1.How to sum two table value in sql? Ans:- SELECT ( SELECT SUM ( London ) FROM CASH ) + ( SELECT SUM ( London ) FROM CHEQUE ) a...