Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC中的PayUMoney集成和ajax调用_C#_Ajax_Asp.net Mvc_Payment Gateway_Payumoney - Fatal编程技术网

C# MVC中的PayUMoney集成和ajax调用

C# MVC中的PayUMoney集成和ajax调用,c#,ajax,asp.net-mvc,payment-gateway,payumoney,C#,Ajax,Asp.net Mvc,Payment Gateway,Payumoney,点击按钮,我希望用户重定向到payumoney网关,如果支付成功,则将用户数据存储在数据库中,并将用户重定向到成功页面,反之亦然 目前,我正在使用AJAX调用保存数据,并在AJAX成功:函数上重定向用户 AJAX $('#payNowButton').on("click", function () { var total = $('#main_total_s5').html(); console.log("Total : " + total); $.ajax({

点击按钮,我希望用户重定向到payumoney网关,如果支付成功,则将用户数据存储在数据库中,并将用户重定向到成功页面,反之亦然

目前,我正在使用AJAX调用保存数据,并在AJAX成功:函数上重定向用户

AJAX

$('#payNowButton').on("click", function () {

    var total = $('#main_total_s5').html();
    console.log("Total : " + total);
    $.ajax({
        url: '/Home/Demo?total=' + total, //Demo method in Home Controller is for payumoney payment gateway.
        type: "POST",
        data: total,
        async: false,
        success: function (result) {
            window.location.href = result;
            if (result > 0) {
                PlaceOrder(); //after successful payment, it will call this function to save data in database.
                window.location.href = '@Url.Action("Sucess", "Home")';
            }
            else {
                alert("Some error occurred." + result);
            }
        },
        error: function (result) {
            window.location.href = '@Url.Action("Failure", "Home")';
        }
    });
});
控制器

[HttpPost]
    public void Demo(OrderCustom orderCustom)
    {
        string firstName = "";
        string amount = "";
        string productInfo = "";
        string email = "";
        string phone = "";
        string surl;
        string furl;


        RemotePost myremotepost = new RemotePost();
        string key = "";
        string salt = "";

        //posting all the parameters required for integration.

        myremotepost.Url = "https://secure.payu.in/_payment";
        myremotepost.Add("key", "");
        string txnid = Generatetxnid();
        myremotepost.Add("txnid", txnid);
        myremotepost.Add("amount", amount);
        myremotepost.Add("productinfo", productInfo);
        myremotepost.Add("firstname", firstName);
        myremotepost.Add("phone", phone);
        myremotepost.Add("email", email);
        myremotepost.Add("surl", "http://localhost:/Home/Sucess");//Change the success url here depending upon the port number of your local system.
        myremotepost.Add("furl", "http://localhost:/Home/Failure");//Change the failure url here depending upon the port number of your local system.
        myremotepost.Add("service_provider", "payu_paisa");
        string hashString = key + "|" + txnid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt;
        string hash = Generatehash512(hashString);
        myremotepost.Add("hash", hash);
        myremotepost.Post();
    }

    public class RemotePost
    {
        private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();


        public string Url = "";
        public string Method = "post";
        public string FormName = "form1";

        public void Add(string name, string value)
        {
            Inputs.Add(name, value);
        }

        public void Post()
        {
            System.Web.HttpContext.Current.Response.Clear();

            System.Web.HttpContext.Current.Response.Write("<html><head>");

            System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
            System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, Url));
            for (int i = 0; i < Inputs.Keys.Count; i++)
            {
                System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
            }
            System.Web.HttpContext.Current.Response.Write("</form>");
            System.Web.HttpContext.Current.Response.Write("</body></html>");

            System.Web.HttpContext.Current.Response.End();
        }
    }
[HttpPost]
公共void演示(OrderCustom)
{
字符串firstName=“”;
字符串金额=”;
字符串productInfo=“”;
字符串email=“”;
字符串phone=“”;
弦乐;
线卷曲;
RemotePost myremotepost=新的RemotePost();
字符串键=”;
字符串salt=“”;
//发布集成所需的所有参数。
myremotepost.Url=”https://secure.payu.in/_payment";
添加(“键”,“键”);
字符串txnid=Generatetxnid();
添加(“txnid”,txnid);
添加(“金额”,金额);
添加(“productinfo”,productinfo);
myremotepost.Add(“firstname”,firstname);
添加(“电话”,电话);
myremotepost.Add(“电子邮件”,email);
myremotepost.Add(“surl”http://localhost:/Home/Sucess“”;//根据本地系统的端口号更改此处的成功url。
myremotepost.Add(“furl”http://localhost:/Home/Failure“”;//根据本地系统的端口号更改此处的故障url。
myremotepost.Add(“服务提供商”、“付费用户”);
string hashString=key+“|”+txnid+“|”+amount+“|”+productInfo+“|”+firstName+“|”+“|”+email+“| ||||||||||||+盐;
string hash=Generatehash512(hashString);
添加(“散列”,散列);
myremotepost.Post();
}
公共类远程邮政
{
private System.Collections.Specialized.NameValueCollection输入=新系统.Collections.Specialized.NameValueCollection();
公共字符串Url=“”;
公共字符串Method=“post”;
公共字符串FormName=“form1”;
公共void添加(字符串名称、字符串值)
{
输入。添加(名称、值);
}
公共空缺职位()
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Write(“”);
System.Web.HttpContext.Current.Response.Write(string.Format(“,FormName));
System.Web.HttpContext.Current.Response.Write(string.Format(“,FormName,Method,Url));
对于(int i=0;i
当我单击按钮时,它显示此错误:
我昨天也遇到了同样的问题。我所做的是,我删除了myremotepost.Add(“服务提供商”、“payu paisa”)成功了

还要检查URL一次,如果您在测试服务器上执行此操作,则URL将是

“Key”和“SALT”值不能为空,这些值将由payumoney本身共享给您

 string key = "";
 string salt = "";

这是必填字段,最近我正在与帮助台联系,他们要求进行一些定制。然后它会工作

这可以帮助你,你是怎么做到的?我们只能对我们能看到的代码提供帮助。添加了代码和错误图像。。请帮忙。。被困在这里一个多星期了。@Vijay Didamani。。谢谢你的帮助,但我已经通过使用一些重定向解决了这个问题,而且效果很好。@JayPatel如果你找到了解决方案,请将其作为问题的答案添加到你的问题中,并接受它,这将帮助其他用户。@Jay Patel y你能发布答案吗?
myremotepost.Add("service_provider", "payu_paisa");