在MVC中付款后,我无法捕获来自Paytm付款网关的数据?

时间:2019-07-29 17:24:40

标签: c# .net asp.net-mvc paytm

我正在.NET MVC网站上设置用于付款的付款网关。在我的本地环境中,一切正常,但是当我将其部署在服务器上时,Request.Form.Keys计数变为零。

我做了一个简单的方法,在交易后打印来自paytm的数据,当我在本地运行它时,它会显示所有数据,但是当部署在服务器上时,它将显示0个表单数据。我无法解决我的问题:为什么它在服务器上发生而在本地工作?我尝试计算Request.Form.Keys,但显示为0,但是在本地响应是我想要的。

public ActionResult PaymentTryl(int number)
{
    var ORDERID = Utility.RandomString(10);
    //req.UID = 20;
    //var orderid = PaytmPaymentRequest(req);
    Dictionary<string, string> parameters = new Dictionary<string, string>();
    parameters.Add("MID", WebConfigurationManager.AppSettings["Paytm_MID"].ToString());
    parameters.Add("CHANNEL_ID", WebConfigurationManager.AppSettings["Paytm_CHANNEL_ID"].ToString());
    parameters.Add("INDUSTRY_TYPE_ID", WebConfigurationManager.AppSettings["Paytm_INDUSTRY_TYPE_ID"].ToString());
    parameters.Add("WEBSITE", WebConfigurationManager.AppSettings["Paytm_WEBSITE"].ToString());
    parameters.Add("EMAIL", "Cool17@gmail.com");
    parameters.Add("MOBILE_NO", "9993160027");
    parameters.Add("CUST_ID", "20");
    parameters.Add("ORDER_ID", ORDERID);
    parameters.Add("TXN_AMOUNT", number.ToString());
    parameters.Add("CALLBACK_URL", WebConfigurationManager.AppSettings["WebSiteURL"].ToString() + "/Testing/paymentTestallbackurl"); //This parameter is not mandatory. Use this to pass the callback url dynamically.

    try
    {
        string paytmChecksum = CheckSum.generateCheckSum(WebConfigurationManager.AppSettings["Paytm_MERCHENTKEY"].ToString(), parameters);
        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='" + WebConfigurationManager.AppSettings["Paytm_transactionURL"].ToString() + "' name='f1'>";
        foreach (string key in parameters.Keys)
        {
            outputHTML += "<input type='hidden' name='" + key + "' value='" + parameters[key] + "'>";
        }
        outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + paytmChecksum + "'>";
        outputHTML += "<script type='text/javascript'>";
        outputHTML += "document.f1.submit();";
        outputHTML += "</script>";
        outputHTML += "</form>";
        outputHTML += "</body>";
        outputHTML += "</html>";
        //Response.Write(outputHTML);
        ViewBag.paymentHtml = outputHTML;
    }
    catch (Exception ex)
    {
        Utility.ExceptionLogging.SendErrorToText(ex);
    }
    return View();
}

[AllowCrossSite]
public ActionResult paymentTestallbackurl()
{
    try
    {
        bool VALID_CHECKSUM;
        Dictionary<String, String> paytmParams = new Dictionary<String, String>();
        string paytmChecksum = "";
        //Request.Form.Keys.Count

        foreach (string key in Request.Form.Keys)
        {
            paytmParams.Add(key.Trim(), Request.Form[key].Trim());

            //if (key.Equals("CHECKSUMHASH"))
            //{
            //    paytmChecksum = Request.Form[key];
            //}
            //else
            //{
            //    paytmParams.Add(key.Trim(), Request.Form[key].Trim());
            //}
        }
        //bool isValidChecksum = CheckSum.verifyCheckSum(WebConfigurationManager.AppSettings["Paytm_MERCHENTKEY"].ToString(), paytmParams, paytmChecksum);

        ViewBag.MyDictionary = paytmParams;
        return View(paytmParams);
    }
    catch (Exception ex)
    {
        ExceptionLogging.SendErrorToText(ex);
        throw;
    }
    return View(Request);
}

请求数据的数量必须大于零。

0 个答案:

没有答案