const string ZhifuBaoUrl = "http://Gate.ekepay.com/paybank.aspx"; //支付宝

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request.QueryString["tok"]))
                {
                    Response.End();
                    return;
                }
                //构建支付链接
                //根据订单唯一id获取订单信息
                IRecordTempService recordService = IoC.Resolve <IRecordTempService>();
                var item = recordService.GetAll().Where(c => c.Guid == Request.QueryString["tok"]).FirstOrDefault();
                if (null == item)
                {
                    Response.End();
                    return;
                }
                if (item.IsCompled || !item.IsEnable)
                {
                    Response.Write("请勿重复提交订单!");
                    return;
                }

                Eka365pay(item.MY18FY, "http://" + Request.Url.Host + ":" + Request.Url.Port + "/views/pay/yiyoufu/pay/Receive.aspx", item);
                //流程工作完成后调用Eka365pay方法,参数为:(String 订单号,String 返回地址--这里默认为:http://"+Request.Url.Host+":"+Request.Url.Port+"/Eka365pay/"+"Receive.aspx)
                //实例:Eka365pay("012345674980123456", "http://" + Request.Url.Host + ":" + Request.Url.Port + "/Eka365pay/" + "Receive.aspx");
            }
        }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (string.IsNullOrEmpty(Request.QueryString["orderid"]))
         {
             Response.End();
             return;
         }
         //构建支付链接
         //根据订单唯一id获取订单信息
         IRecordTempService recordService = IoC.Resolve <IRecordTempService>();
         var item = recordService.GetAll().Where(c => c.Guid == Request.QueryString["orderid"]).FirstOrDefault();
         if (null == item || item.IsCompled)
         {
             Alert("不存或已完成订单,请不要重复提交!");
             return;
         }
         //根据相关参数构建
         OpenUrl = BuilderMoBaoUrl(item);
     }
 }
예제 #3
0
        private async Task LoadTempRecords()
        {
            var records = await _recordTempService.GetAll();

            PublishList = new BindingList <Record>(records);
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {

         


            if (string.IsNullOrEmpty(Request.QueryString["tok"]))
            {
                Response.End();
                return;
            }
            //构建支付链接
            //根据订单唯一id获取订单信息
            IRecordTempService recordService = IoC.Resolve<IRecordTempService>();
            var item = recordService.GetAll().Where(c => c.Guid == Request.QueryString["tok"]).FirstOrDefault();
            if (null == item)
            {

                Response.End();
                return;
            }
            if (item.IsCompled || !item.IsEnable)
            {
                Response.Write("请勿重复提交订单!");
                return;
            }
            var userAmt = Math.Round(item.TradeAmt, 2).ToString();
            showProce = userAmt;
            if (userAmt.IndexOf(".") < 0)
                userAmt = userAmt + ".00";

            if (!IsPostBack)
            {
                
                try
                {
                    /////////////////////////////////接收表单提交参数////////////////////////////////////
                    ////////////////////////To receive the parameter form HTML form//////////////////////
                    
                    string interface_version = "V3.0";//Request.Form["interface_version"].ToString().Trim();
                    string service_type = "wxpay";//Request.Form["service_type"].ToString().Trim();
                    string sign_type = "RSA-S";//Request.Form["sign_type"].ToString().Trim();
                    string merchant_code = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Merchant_code;// Request.Form["merchant_code"].ToString().Trim();
                    string order_no = item.MY18FY;//Request.Form["order_no"].ToString().Trim();
                    string order_time = item.OccDate.ToString("yyyy-MM-dd HH:mm:ss"); //Request.Form["order_time"].ToString().Trim();
                    string order_amount = userAmt;// Request.Form["order_amount"].ToString().Trim();
                    string product_name = "乐诚网在线充值";//Request.Form["product_name"].ToString().Trim();
                    string product_code = "mhpro";//Request.Form["product_code"].ToString().Trim();
                    string product_num = "1";// Request.Form["product_num"].ToString().Trim();
                    string product_desc = "";//Request.Form["product_desc"].ToString().Trim();
                    string extra_return_param = "";// Request.Form["extra_return_param"].ToString().Trim();
                    string extend_param = "";//Request.Form["extend_param"].ToString().Trim();
                    string notify_url = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Notify_url;//Request.Form["notify_url"].ToString().Trim();

                    ////////////////组装签名参数//////////////////
                    string signStr = "";

                    if (extend_param != "")
                    {
                        signStr = signStr + "extend_param=" + extend_param + "&";
                    }
                    if (extra_return_param != "")
                    {
                        signStr = signStr + "extra_return_param=" + extra_return_param + "&";
                    }
                    if (interface_version != "")
                    {
                        signStr = signStr + "interface_version=" + interface_version + "&";
                    }
                    if (merchant_code != "")
                    {
                        signStr = signStr + "merchant_code=" + merchant_code + "&";
                    }
                    if (notify_url != "")
                    {
                        signStr = signStr + "notify_url=" + notify_url + "&";
                    }
                    if (order_amount != "")
                    {
                        signStr = signStr + "order_amount=" + order_amount + "&";
                    }
                    if (order_no != "")
                    {
                        signStr = signStr + "order_no=" + order_no + "&";
                    }
                    if (order_time != "")
                    {
                        signStr = signStr + "order_time=" + order_time + "&";
                    }
                    if (product_code != "")
                    {
                        signStr = signStr + "product_code=" + product_code + "&";
                    }
                    if (product_desc != "")
                    {
                        signStr = signStr + "product_desc=" + product_desc + "&";
                    }
                    if (product_name != "")
                    {
                        signStr = signStr + "product_name=" + product_name + "&";
                    }
                    if (product_num != "")
                    {
                        signStr = signStr + "product_num=" + product_num + "&";
                    }
                    if (service_type != "")
                    {
                        signStr = signStr + "service_type=" + service_type;
                    }

                    if (sign_type == "RSA-S")//RSA-S签名方法
                    {
                        //商家私钥
                        string merPriKey = ZhiFuPayConfig.Merchant_private_key;//"MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALf/+xHa1fDTCsLYPJLHy80aWq3djuV1T34sEsjp7UpLmV9zmOVMYXsoFNKQIcEzei4QdaqnVknzmIl7n1oXmAgHaSUF3qHjCttscDZcTWyrbXKSNr8arHv8hGJrfNB/Ea/+oSTIY7H5cAtWg6VmoPCHvqjafW8/UP60PdqYewrtAgMBAAECgYEAofXhsyK0RKoPg9jA4NabLuuuu/IU8ScklMQIuO8oHsiStXFUOSnVeImcYofaHmzIdDmqyU9IZgnUz9eQOcYg3BotUdUPcGgoqAqDVtmftqjmldP6F6urFpXBazqBrrfJVIgLyNw4PGK6/EmdQxBEtqqgXppRv/ZVZzZPkwObEuECQQDenAam9eAuJYveHtAthkusutsVG5E3gJiXhRhoAqiSQC9mXLTgaWV7zJyA5zYPMvh6IviX/7H+Bqp14lT9wctFAkEA05ljSYShWTCFThtJxJ2d8zq6xCjBgETAdhiH85O/VrdKpwITV/6psByUKp42IdqMJwOaBgnnct8iDK/TAJLniQJABdo+RodyVGRCUB2pRXkhZjInbl+iKr5jxKAIKzveqLGtTViknL3IoD+Z4b2yayXg6H0g4gYj7NTKCH1h1KYSrQJBALbgbcg/YbeU0NF1kibk1ns9+ebJFpvGT9SBVRZ2TjsjBNkcWR2HEp8LxB6lSEGwActCOJ8Zdjh4kpQGbcWkMYkCQAXBTFiyyImO+sfCccVuDSsWS+9jrc5KadHGIvhfoRjIj2VuUKzJ+mXbmXuXnOYmsAefjnMCI6gGtaqkzl527tw=";
                                                                               //私钥转换成C#专用私钥
                        merPriKey = testOrder.wechart.HttpHelp.RSAPrivateKeyJava2DotNet(merPriKey);
                        //签名
                        string signData = testOrder.wechart.HttpHelp.RSASign(signStr, merPriKey);
                        //将signData进行UrlEncode编码
                        signData = HttpUtility.UrlEncode(signData);
                        //组装字符串
                        string para = signStr + "&sign_type=" + sign_type + "&sign=" + signData;
                        //将字符串发送到Dinpay网关
                        string _xml = testOrder.wechart.HttpHelp.HttpPost("https://api.dinpay.com/gateway/api/weixin", para);

                        //将同步返回的xml中的参数提取出来
                        var el = XElement.Load(new StringReader(_xml));
                        //将XML中的参数逐个提取出来
                        var qrcode1 = el.XPathSelectElement("/response/trade/qrcode");
                        var resp_code1 = el.XPathSelectElement("/response/resp_code");
                        var resp_desc1 = el.XPathSelectElement("/response/resp_desc");
                        var dinpaysign1 = el.XPathSelectElement("/response/sign");
                        if (qrcode1 == null)
                        {
                            //Response.Write("状态:" + _xml + "<br/>");
                            Response.End();
                        }
                        //去掉首尾的标签并转换成string
                        string qrcode = Regex.Match(qrcode1.ToString(), "(?<=>).*?(?=<)").Value;   //二维码链接
                        string resp_code = Regex.Match(resp_code1.ToString(), "(?<=>).*?(?=<)").Value;
                        string resp_desc = Regex.Match(resp_desc1.ToString(), "(?<=>).*?(?=<)").Value;
                        string dinpaysign = Regex.Match(dinpaysign1.ToString(), "(?<=>).*?(?=<)").Value;
                        string signsrc = "qrcode=" + qrcode + "&resp_code=" + resp_code + "&resp_desc=" + resp_desc;
                        //使用智付公钥对返回的数据验签

                        try
                        {
                            //将智付公钥转换成C#专用格式
                            dinpayPubKey = testOrder.wechart.HttpHelp.RSAPublicKeyJava2DotNet(dinpayPubKey);
                        }
                        catch (Exception ex)
                        {
                          //  Response.Write(ex.Message);
                        }
                        //验签
                        bool validateResult = testOrder.wechart.HttpHelp.ValidateRsaSign(signsrc, dinpayPubKey, dinpaysign);

                        if (validateResult == false)
                        {
                            Response.Write("失败");
                            Response.End();
                        }
                        //验签成功后将支付链接生成二维码
                        My.Utility.QRCodeHandler qr = new My.Utility.QRCodeHandler();
                        string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/Views/pay/zhifu/wechart/qrcode/";  //文件目录   
                        string qrString = qrcode;                                                            //二维码字符串  
                        string logoFilePath = path + "my.png";//商家Logo文件 
                        fileName = "myCode" + Guid.NewGuid().ToString() + ".jpg";
                        string filePath = path + fileName;                                             //二维码文件名  
                        qr.CreateQRCode(qrcode, "Byte", 6, 6, "H", filePath, true, logoFilePath);       //生成二维码
                        //Response.Write(qrcode+"<br/>");
                        //Response.Write("结果:" + signsrc + "<br/>");
                       // Response.Write("验签结果:" + validateResult + "<br/>");
                        //Response.End();

                    }
                    else  //RSA签名方法
                    {
                        RSAWithHardware rsa = new RSAWithHardware();
                        string merPubKeyDir = "D:/1111110166.pfx";   //证书路径
                        string password = "******";                //证书密码
                        RSAWithHardware rsaWithH = new RSAWithHardware();
                        rsaWithH.Init(merPubKeyDir, password, "D:/dinpayRSAKeyVersion");//初始化(version路径需跟证书一致,证书会自动生成version)
                        string signData = rsaWithH.Sign(signStr);    //签名
                        signData = HttpUtility.UrlEncode(signData);  //将signData进行UrlEncode编码

                        //组装字符串
                        string para = signStr + "&sign_type=" + sign_type + "&sign=" + signData;
                        //将字符串发送到Dinpay网关
                        string _xml = testOrder.wechart.HttpHelp.HttpPost("https://api.dinpay.com/gateway/api/weixin", para);

                        //将同步返回的xml中的参数提取出来
                        var el = XElement.Load(new StringReader(_xml));
                        //将XML中的参数逐个提取出来
                        var qrcode1 = el.XPathSelectElement("/response/trade/qrcode");
                        var resp_code1 = el.XPathSelectElement("/response/resp_code");
                        var resp_desc1 = el.XPathSelectElement("/response/resp_desc");
                        var dinpaysign1 = el.XPathSelectElement("/response/sign");
                        if (qrcode1 == null)
                        {
                            Response.Write("错误:" + _xml + "<br/>");
                            Response.End();
                        }
                        //去掉首尾的标签并转换成string
                        string qrcode = Regex.Match(qrcode1.ToString(), "(?<=>).*?(?=<)").Value;   //二维码链接
                        string resp_code = Regex.Match(resp_code1.ToString(), "(?<=>).*?(?=<)").Value;
                        string resp_desc = Regex.Match(resp_desc1.ToString(), "(?<=>).*?(?=<)").Value;
                        string dinpaysign = Regex.Match(dinpaysign1.ToString(), "(?<=>).*?(?=<)").Value;

                        //组装验签字符串
                        string signsrc = "qrcode=" + qrcode + "&resp_code=" + resp_code + "&resp_desc=" + resp_desc;
                        //RSA验签
                        bool result = rsaWithH.VerifySign("1111110166", signsrc, dinpaysign);
                        if (result == false)
                        {
                            Response.Write("验签失败");
                            Response.End();
                        }
                        //验签成功后将支付链接生成二维码
                        //My.Utility.QRCodeHandler qr = new My.Utility.QRCodeHandler();
                        //string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/Views/pay/zhifu/wechart/qrcode/";  //文件目录  
                        //string qrString = qrcode;                                                             //二维码字符串  
                        //string logoFilePath = path + "my.jpg";                                               //商家Logo路径  
                        //string filePath = path + "myCode.jpg";                                              //二维码文件名  
                        //qr.CreateQRCode(qrString, "Byte", 6, 6, "H", filePath, true, logoFilePath);        //生成二维码

                        //Response.Write("结果:" + signsrc + "<br/>");
                        //Response.Write("验签结果:" + result + "<br/>");
                        //Response.End();
                    }
                }
                finally
                {
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request.QueryString["tok"]))
                {
                    Response.End();
                    return;
                }
                //构建支付链接
                //根据订单唯一id获取订单信息
                IRecordTempService recordService = IoC.Resolve <IRecordTempService>();
                var item = recordService.GetAll().Where(c => c.Guid == Request.QueryString["tok"]).FirstOrDefault();
                if (null == item)
                {
                    Response.End();
                    return;
                }
                if (item.IsCompled || !item.IsEnable)
                {
                    Response.Write("请勿重复提交订单!");
                    return;
                }
                var userAmt = Math.Round(item.TradeAmt, 2).ToString();
                if (userAmt.IndexOf(".") < 0)
                {
                    userAmt = userAmt + ".00";
                }


                try
                {
                    /////////////////////////////////接收表单提交参数//////////////////////////////////////
                    ////////////////////////To receive the parameter form HTML form//////////////////////

                    string input_charset1      = "UTF-8";                                                    //Request.Form["input_charset"].ToString().Trim();
                    string interface_version1  = "V3.0";                                                     // Request.Form["interface_version"].ToString().Trim();
                    string merchant_code1      = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Merchant_code; //Request.Form["merchant_code"].ToString().Trim();
                    string notify_url1         = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Notify_url;    //Request.Form["notify_url"].ToString().Trim();
                    string order_amount1       = userAmt;                                                    //Request.Form["order_amount"].ToString().Trim();
                    string order_no1           = item.MY18FY;                                                //Request.Form["order_no"].ToString().Trim();
                    string order_time1         = item.OccDate.ToString("yyyy-MM-dd HH:mm:ss");               //Request.Form["order_time"].ToString().Trim();
                    string sign_type1          = "RSA-S";                                                    //Request.Form["sign_type"].ToString().Trim();
                    string product_code1       = "mhpro";                                                    //Request.Form["product_code"].ToString().Trim();
                    string product_desc1       = "";                                                         //Request.Form["product_desc"].ToString().Trim();
                    string product_name1       = "美亚娱乐在线充值";                                                 //Request.Form["product_name"].ToString().Trim();
                    string product_num1        = "1";                                                        //Request.Form["product_num"].ToString().Trim();
                    string return_url1         = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Return_url;    //Request.Form["return_url"].ToString().Trim();
                    string service_type1       = "direct_pay";                                               //Request.Form["service_type"].ToString().Trim();
                    string show_url1           = "";                                                         //Request.Form["show_url"].ToString().Trim();
                    string extend_param1       = "";                                                         //Request.Form["extend_param"].ToString().Trim();
                    string extra_return_param1 = "";                                                         //Request.Form["extra_return_param"].ToString().Trim();
                    string bank_code1          = item.MY18PT;                                                //Request.Form["bank_code"].ToString().Trim();
                    string client_ip1          = Utils.GetIp();                                              //Request.Form["client_ip"].ToString().Trim();
                    string redo_flag1          = "";                                                         // Request.Form["redo_flag"].ToString().Trim();
                    string pay_type1           = "";                                                         //Request.Form["pay_type"].ToString().Trim();

                    ////////////////组装签名参数//////////////////

                    string signSrc = "";

                    //组织订单信息
                    if (bank_code1 != "")
                    {
                        signSrc = signSrc + "bank_code=" + bank_code1 + "&";
                    }
                    if (client_ip1 != "")
                    {
                        signSrc = signSrc + "client_ip=" + client_ip1 + "&";
                    }
                    if (extend_param1 != "")
                    {
                        signSrc = signSrc + "extend_param=" + extend_param1 + "&";
                    }
                    if (extra_return_param1 != "")
                    {
                        signSrc = signSrc + "extra_return_param=" + extra_return_param1 + "&";
                    }
                    if (input_charset1 != "")
                    {
                        signSrc = signSrc + "input_charset=" + input_charset1 + "&";
                    }
                    if (interface_version1 != "")
                    {
                        signSrc = signSrc + "interface_version=" + interface_version1 + "&";
                    }
                    if (merchant_code1 != "")
                    {
                        signSrc = signSrc + "merchant_code=" + merchant_code1 + "&";
                    }
                    if (notify_url1 != "")
                    {
                        signSrc = signSrc + "notify_url=" + notify_url1 + "&";
                    }
                    if (order_amount1 != "")
                    {
                        signSrc = signSrc + "order_amount=" + order_amount1 + "&";
                    }
                    if (order_no1 != "")
                    {
                        signSrc = signSrc + "order_no=" + order_no1 + "&";
                    }
                    if (order_time1 != "")
                    {
                        signSrc = signSrc + "order_time=" + order_time1 + "&";
                    }
                    if (pay_type1 != "")
                    {
                        signSrc = signSrc + "pay_type=" + pay_type1 + "&";
                    }
                    if (product_code1 != "")
                    {
                        signSrc = signSrc + "product_code=" + product_code1 + "&";
                    }
                    if (product_desc1 != "")
                    {
                        signSrc = signSrc + "product_desc=" + product_desc1 + "&";
                    }
                    if (product_name1 != "")
                    {
                        signSrc = signSrc + "product_name=" + product_name1 + "&";
                    }
                    if (product_num1 != "")
                    {
                        signSrc = signSrc + "product_num=" + product_num1 + "&";
                    }
                    if (redo_flag1 != "")
                    {
                        signSrc = signSrc + "redo_flag=" + redo_flag1 + "&";
                    }
                    if (return_url1 != "")
                    {
                        signSrc = signSrc + "return_url=" + return_url1 + "&";
                    }
                    if (service_type1 != "")
                    {
                        signSrc = signSrc + "service_type=" + service_type1;
                    }
                    if (show_url1 != "")
                    {
                        signSrc = signSrc + "&show_url=" + show_url1;
                    }

                    if (sign_type1 == "RSA-S")//RSA-S签名方法
                    {
                        /**  merchant_private_key,商户私钥,商户按照《密钥对获取工具说明》操作并获取商户私钥。获取商户私钥的同时,也要
                         *  获取商户公钥(merchant_public_key)并且将商户公钥上传到智付商家后台"公钥管理"(如何获取和上传请看《密钥对获取工具说明》),
                         *  不上传商户公钥会导致调试的时候报错“签名错误”。
                         */

                        //demo提供的merchant_private_key是测试商户号1111110166的商户私钥,请自行获取商户私钥并且替换。

                        string merchant_private_key = Ytg.ServerWeb.Views.pay.zhifu.ZhiFuPayConfig.Merchant_private_key;// "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALf/+xHa1fDTCsLYPJLHy80aWq3djuV1T34sEsjp7UpLmV9zmOVMYXsoFNKQIcEzei4QdaqnVknzmIl7n1oXmAgHaSUF3qHjCttscDZcTWyrbXKSNr8arHv8hGJrfNB/Ea/+oSTIY7H5cAtWg6VmoPCHvqjafW8/UP60PdqYewrtAgMBAAECgYEAofXhsyK0RKoPg9jA4NabLuuuu/IU8ScklMQIuO8oHsiStXFUOSnVeImcYofaHmzIdDmqyU9IZgnUz9eQOcYg3BotUdUPcGgoqAqDVtmftqjmldP6F6urFpXBazqBrrfJVIgLyNw4PGK6/EmdQxBEtqqgXppRv/ZVZzZPkwObEuECQQDenAam9eAuJYveHtAthkusutsVG5E3gJiXhRhoAqiSQC9mXLTgaWV7zJyA5zYPMvh6IviX/7H+Bqp14lT9wctFAkEA05ljSYShWTCFThtJxJ2d8zq6xCjBgETAdhiH85O/VrdKpwITV/6psByUKp42IdqMJwOaBgnnct8iDK/TAJLniQJABdo+RodyVGRCUB2pRXkhZjInbl+iKr5jxKAIKzveqLGtTViknL3IoD+Z4b2yayXg6H0g4gYj7NTKCH1h1KYSrQJBALbgbcg/YbeU0NF1kibk1ns9+ebJFpvGT9SBVRZ2TjsjBNkcWR2HEp8LxB6lSEGwActCOJ8Zdjh4kpQGbcWkMYkCQAXBTFiyyImO+sfCccVuDSsWS+9jrc5KadHGIvhfoRjIj2VuUKzJ+mXbmXuXnOYmsAefjnMCI6gGtaqkzl527tw=";
                        //私钥转换成C#专用私钥
                        merchant_private_key = testOrder.HttpHelp.RSAPrivateKeyJava2DotNet(merchant_private_key);
                        //签名
                        string signData = testOrder.HttpHelp.RSASign(signSrc, merchant_private_key);
                        sign.Value = signData;
                    }
                    else  //RSA签名方法
                    {
                        RSAWithHardware rsa          = new RSAWithHardware();
                        string          merPubKeyDir = "D:/1111110166.pfx";              //证书路径
                        string          password     = "******";                       //证书密码
                        RSAWithHardware rsaWithH     = new RSAWithHardware();
                        rsaWithH.Init(merPubKeyDir, password, "D:/dinpayRSAKeyVersion"); //初始化
                        string signData = rsaWithH.Sign(signSrc);                        //签名
                        sign.Value = signData;
                    }


                    merchant_code.Value      = merchant_code1;
                    bank_code.Value          = bank_code1;
                    order_no.Value           = order_no1;
                    order_amount.Value       = order_amount1;
                    service_type.Value       = service_type1;
                    input_charset.Value      = input_charset1;
                    notify_url.Value         = notify_url1;
                    interface_version.Value  = interface_version1;
                    sign_type.Value          = sign_type1;
                    order_time.Value         = order_time1;
                    product_name.Value       = product_name1;
                    client_ip.Value          = client_ip1;
                    extend_param.Value       = extend_param1;
                    extra_return_param.Value = extra_return_param1;
                    product_code.Value       = product_code1;
                    product_desc.Value       = product_desc1;
                    product_num.Value        = product_num1;
                    return_url.Value         = return_url1;
                    show_url.Value           = show_url1;
                    redo_flag.Value          = redo_flag1;
                    pay_type.Value           = pay_type1;
                }
                finally
                {
                }
            }
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String key = ConfigurationManager.AppSettings["ekakey"]; //配置文件密钥
            //返回参数
            String orderid    = Request["orderid"];                  //返回订单号
            String opstate    = Request["opstate"];                  //返回处理结果
            String ovalue     = Request["ovalue"];                   //返回实际充值金额
            String sign       = Request["sign"];                     //返回签名
            String ekaorderID = Request["sysorderid"];               //亿卡录入时产生流水号。
            String ekatime    = Request["systime"];                  //亿卡处理时间。
            String attach     = Request["attach"];                   //上行附加信息
            String msg        = Request["msg"];                      //亿卡返回订单处理消息
            //http://pay.cccwsm.cn/views/pay/yiyoufu/pay/Receive.aspx?orderid=R9C97BCE0F74C7467&opstate=0&ovalue=1&sysorderid=1604012306249990415&systime=2016-04-01+23%3a06%3a38&attach=&msg=&

            String param = String.Format("orderid={0}&opstate={1}&ovalue={2}{3}", orderid, opstate, ovalue, key);//组织参数

            //比对签名是否有效
            if (sign.Equals(FormsAuthentication.HashPasswordForStoringInConfigFile(param, "MD5").ToLower()))
            {
                //执行操作方法
                if (opstate.Equals("0") || opstate.Equals("-3"))
                {
                    //操作流程成功的情况
                    //
                    //构建支付链接
                    Ytg.Scheduler.Comm.LogManager.Info(orderid + "  " + opstate);
                    //根据订单唯一id获取订单信息
                    IRecordTempService recordService = IoC.Resolve <IRecordTempService>();
                    var item = recordService.GetAll().Where(x => x.MY18FY == orderid && x.IsCompled == false && x.IsEnable).FirstOrDefault();
                    if (null == item)
                    {
                        Response.Write("请不要重复提交订单!");
                        return;
                    }
                    decimal dmTradeAmt;
                    if (!decimal.TryParse(ovalue, out dmTradeAmt))
                    {
                        Response.Write("非法请求!");
                        return;
                    }
                    if (item.TradeAmt != dmTradeAmt)
                    {
                        Response.Write("非法请求!");
                    }
                    //处理订单
                    item.IsCompled = true;
                    item.MY18oid   = ekaorderID;
                    item.MY18M     = ovalue;
                    item.MY18DT    = ekatime;
                    //增加用户余额,处理充值逻辑
                    if (ManagerCallBackLogic(item))
                    {
                        recordService.Save();//保存
                        //逻辑处理完成,跳转
                        // Response.Redirect("notify.aspx", true);     // 回写‘SUCCESS’方式一: 重定向到一个专门用于处理回写‘SUCCESS’的页面,这样可以保证输出内容中只有'SUCCESS'这个字符串。
                        Response.Write("恭喜您,充值成功!");
                        //插入充值成功消息
                        try
                        {
                            IMessageService messageService = IoC.Resolve <IMessageService>();
                            messageService.Create(new Message()
                            {
                                FormUserId     = -1,
                                MessageType    = 8,
                                OccDate        = DateTime.Now,
                                Status         = 0,
                                Title          = "充值成功提示",
                                MessageContent = string.Format("您通过在线充值{0}元已经成功到账!", item.TradeAmt),
                                ToUserId       = item.UserId
                            });
                            messageService.Save();
                        }
                        catch (Exception ex)
                        {
                        }
                        //插入系统消息表
                    }
                    else
                    {
                        // AppendLog("充值失败:请求参数:" + srcString);
                        Response.Write("充值失败,请联系在线客服确认是否充值成功!");
                    }
                }
                else if (opstate.Equals("-1"))
                {
                    //卡号密码错误
                    Response.Write("卡号密码错误!");
                }
                else if (opstate.Equals("-2"))
                {
                    //卡实际面值和提交时面值不符,卡内实际面值未使用
                    Response.Write("卡实际面值和提交时面值不符,卡内实际面值未使用!");
                }
                else if (opstate.Equals("-4"))
                {
                    //卡在提交之前已经被使用
                    Response.Write("卡在提交之前已经被使用!");
                }
                else if (opstate.Equals("-5"))
                {
                    //失败,原因请查看msg
                }
            }
            else
            {
                //签名无效
                Response.Write("非法请求!");
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request.QueryString["tok"]))
                {
                    Response.End();
                    return;
                }
                //构建支付链接
                //根据订单唯一id获取订单信息
                IRecordTempService recordService = IoC.Resolve<IRecordTempService>();
                var item = recordService.GetAll().Where(c => c.Guid == Request.QueryString["tok"]).FirstOrDefault();
                if (null == item )
                {
                    Response.End();
                    return;
                }
                if (item.IsCompled || !item.IsEnable)
                {
                    Response.Write("请勿重复提交订单!");
                    return;
                }

                var userAmt = Math.Round(item.TradeAmt, 2).ToString();
                if (userAmt.IndexOf(".") < 0)
                    userAmt = userAmt + ".00";
                // 组织数据和签名
                Dictionary<string, string> payData = new Dictionary<string, string>();
                payData.Add("apiName", MobaopayConfig.Mobaopay_apiname_pay);
                payData.Add("apiVersion", MobaopayConfig.Mobaopay_api_version);
                payData.Add("platformID", MobaopayConfig.Platform_id);
                payData.Add("merchNo", MobaopayConfig.Merchant_acc);
                payData.Add("orderNo", item.MY18FY);
                payData.Add("tradeDate", item.OccDate.ToString("yyyyMMdd"));
                payData.Add("amt", userAmt);//string.Format("{0:N}", item.TradeAmt));
                payData.Add("merchUrl", MobaopayConfig.Merchant_notify_url);
                payData.Add("merchParam", "");//Request.Form["merchParam"]
                payData.Add("tradeSummary", "PayBill");//item.MY18FY
                /**
                 * bankCode为空,提交表单后浏览器在新窗口显示摩宝支付收银台页面,在这里可以通过账户余额支付或者选择银行支付;
                 * bankCode不为空,取值只能是接口文档中列举的银行代码,提交表单后浏览器将在新窗口直接打开选中银行的支付页面。
                 * 无论选择上面两种方式中的哪一种,支付成功后收到的通知都是同一接口。
                 */
                payData.Add("bankCode", item.MY18PT);

                string requestStr = MobaopayMerchant.Instance.generatePayRequest(payData);  // 组织签名源数据
                payData.Add("signMsg", MobaopaySignUtil.Instance.sign(requestStr));         // 生成签名数据

                // 生成表单并自动提交到支付网关。
                StringBuilder sbHtml = new StringBuilder();
                sbHtml.Append("<form id='mobaopaysubmit' name='mobaopaysubmit' action='" + MobaopayConfig.Mobaopay_gateway + "?' method='post'>");
                foreach (KeyValuePair<string, string> temp in payData)
                {
                    sbHtml.Append("<input type='hidden' name='" + temp.Key + "' value='" + temp.Value + "'/>");
                }
                sbHtml.Append("</form>");
                sbHtml.Append("<script>document.forms['mobaopaysubmit'].submit();</script>");
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.Write(sbHtml.ToString());
            }
        }