title: Paytm Payment Integration In Web sites using ASP.Net MVC 5
body: <p>I am trying to implement PAYTM payment integration method in my ASP.NET MVC project. I am applying paytm payment integration in my websites but I get a result like</p>
  
  <p><a href="https://i.stack.imgur.com/pZPJT.png" rel="nofollow noreferrer">Result after payment code run error showing</a></p>
  
  <p>I have one controller:</p>
  
  <pre><code>public class PaytmController : Controller
  {
          // GET: Paytm
          public ActionResult Index()
          {
              return View();
          }
  
          [HttpPost]
          public ActionResult CreatePayment(RequestData requestData)
          {
              String merchantKey = Key.merchantKey;
  
              Dictionary&lt;string, string&gt; parameters = new Dictionary&lt;string, string&gt;();
              parameters.Add("MID", Key.merchantId);
              parameters.Add("CHANNEL_ID", "WEB");
              parameters.Add("INDUSTRY_TYPE_ID", "Retail");
              parameters.Add("WEBSITE", "WEBSTAGING");
              parameters.Add("EMAIL", requestData.email);
              parameters.Add("MOBILE_NO", requestData.mobileNumber);
              parameters.Add("CUST_ID", "1");
              parameters.Add("ORDER_ID", "ORDER8");
              parameters.Add("TXN_AMOUNT", requestData.amount);
              parameters.Add("CALLBACK_URL", "http://localhost:60308/Paytm/paytmResponse"); //This parameter is not mandatory. Use this to pass the callback url dynamically.
  
              string checksum = paytm.CheckSum.generateCheckSum(merchantKey, parameters);
  
              string paytmURL = "https://securegw-stage.paytm.in/theia/processTransaction?orderid=" + parameters.FirstOrDefault(x =&gt; x.Key == "ORDER_ID").Value;
  
              string outputHTML = "&lt;html&gt;";
              outputHTML += "&lt;head&gt;";
              outputHTML += "&lt;title&gt;Merchant Check Out Page&lt;/title&gt;";
              outputHTML += "&lt;/head&gt;";
              outputHTML += "&lt;body&gt;";
              outputHTML += "&lt;center&gt;&lt;h1&gt;Please do not refresh this page...&lt;/h1&gt;&lt;/center&gt;";
              outputHTML += "&lt;form method='post' action='" + paytmURL + "' name='f1'&gt;";
              outputHTML += "&lt;table border='1'&gt;";
              outputHTML += "&lt;tbody&gt;";
  
              foreach (string key in parameters.Keys)
              {
                  outputHTML += "&lt;input type='hidden' name='" + key + "' value='" + parameters[key] + "'&gt;";
              }
  
              outputHTML += "&lt;input type='hidden' name='CHECKSUMHASH' value='" + checksum + "'&gt;";
              outputHTML += "&lt;/tbody&gt;";
              outputHTML += "&lt;/table&gt;";
              outputHTML += "&lt;script type='text/javascript'&gt;";
              outputHTML += "document.f1.submit();";
              outputHTML += "&lt;/script&gt;";
              outputHTML += "&lt;/form&gt;";
              outputHTML += "&lt;/body&gt;";
              outputHTML += "&lt;/html&gt;";
  
              ViewBag.htmlData = outputHTML;
  
              return View("PaymentPage");
          }
  
          [HttpPost]
          public ActionResult paytmResponse(PaytmResponse  response)
          {
              return View("paytmResponse" , response);
          }
  }
  </code></pre>
  
  <p>The index view looks like this:</p>
  
  <pre><code>@model MyHoroscope.ViewModels.RequestData
  @{
      ViewBag.Title = "Index";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  &lt;div align="center"&gt;
      @using (Html.BeginForm("CreatePayment", "Paytm", FormMethod.Post))
      {
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Mobile Number :
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="mobileNumber" value="" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Email :
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="email" value="" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Amount :
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="amount" value="" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;pre&gt;
          &lt;input type="submit" value="Save" /&gt;
          &lt;/pre&gt;
      }    
  &lt;/div&gt;
  </code></pre>
  
  <p>and <code>PaymentPage</code> view is like this:</p>
  
  <pre><code>@{
      Layout = null;
  }
  
  @Html.Raw(ViewBag.htmlData)
  </code></pre>
  
  <p>and I also created a <code>paymentResponse</code> view:</p>
  
  <pre><code>@model MyHoroscope.ViewModels.PaytmResponse
  @{
      ViewBag.Title = "paytmResponse";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;h2&gt;paytmResponse&lt;/h2&gt;
  
  &lt;div align="center"&gt;
      &lt;table border="1" width="50%"&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.MID)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.MID)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.ORDER_ID)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.ORDER_ID)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.TXN_AMOUNT)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.TXN_AMOUNT)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.CURRENCY)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.CURRENCY)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.TXNID)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.TXNID)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.BANKTXNID)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.BANKTXNID)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.STATUS)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.STATUS)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.RESPCODE)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.RESPCODE)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.RESPMSG)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.RESPMSG)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.TXNDATE)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.TXNDATE)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.GATEWAYNAME)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.GATEWAYNAME)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.BANKNAME)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.BANKNAME)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.PAYMENTMODE)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.PAYMENTMODE)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayNameFor(m =&gt; m.CHECKSUMHASH)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(m =&gt; m.CHECKSUMHASH)&lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Why is my code not working?</p>