Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string data = Request["data"];

            string msg    = "";
            bool   result = false;

            try
            {
                SortedDictionary <string, object> dict = new SortedDictionary <string, object>();

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(data);
                XmlNode     xmlNode = xmlDoc.DocumentElement;//获取到根节点<xml>
                XmlNodeList nodes   = xmlNode.ChildNodes;
                foreach (XmlNode xn in nodes)
                {
                    XmlElement xe = (XmlElement)xn;
                    dict[xe.Name] = xe.InnerText;//获取xml的键值对到WxPayData内部的数据中
                }

                if (dict["ResultCode"].ToString() == "SUCCESS")
                {
                    string return_sign = dict["Sign"].ToString();

                    string     ordercode = dict["OrderId"].ToString();
                    Lebi_Order order     = B_Lebi_Order.GetModel("Code=lbsql{'" + ordercode + "'}");
                    if (order == null)
                    {
                        Response.Write("系统错误");
                        Response.End();
                        return;
                    }
                    Lebi_OnlinePay pay = Shop.Bussiness.Money.GetOnlinePay(order, "tonglianPay");
                    if (pay == null)
                    {
                        Response.Write("系统错误");
                        Response.End();
                        return;
                    }
                    string cal_sign = PayHelp.MakeSign(dict, pay.UserKey);
                    //签名正确
                    if (cal_sign == return_sign)
                    {
                        //Loger.WriteEvent(new Exception(data), "签名完成");
                        Order.OnlinePaySuccess("tonglianPay", order.Code);
                        result = true;
                    }
                    else
                    {
                        //Loger.WriteEvent(new Exception(data), "签名失败");
                    }
                }
                else
                {
                    ////Loger.WriteEvent(new Exception(data), "Fail");
                }
            }
            catch (Exception ex)
            {
                result = false;
                msg    = "未知异常";
                //Loger.WriteEvent(ex, "Notify");
            }

            Response.Write(string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", (result ? "SUCCESS" : "FAIL"), msg));
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string baseUrl = "http://自己的域名";
            string merId   = "00000***21";                       //商户号(MerId)
            string appId   = "000000***2";                       //应用ID(AppId)
            string payKey  = "6823fcfe11517******5b8e4c4dc9be9"; //支付Key(PayKey)

            int        order_id = RequestTool.RequestInt("order_id", 0);
            Lebi_Order order    = B_Lebi_Order.GetModel(order_id);

            if (order == null)
            {
                Response.Write("ERROR");
                Response.End();
                return;
            }
            Lebi_Language language = B_Lebi_Language.GetModel(order.Language_id);

            if (order.IsPaid == 1)
            {
                Response.Write(Language.Tag("已付款", language.Code));
                Response.End();
                return;
            }
            order.Site_id_pay = CurrentSite.id;
            order.Language_id = CurrentLanguage.id;
            //SystemLog.Add("订单:" + order.Code + "-" + CurrentSite.id + "--" + CurrentLanguage.id);
            Lebi_OnlinePay pay = Shop.Bussiness.Money.GetOnlinePay(order, "tonglianPay");

            if (pay == null)
            {
                Response.Write("系统错误");
                Response.End();
                return;
            }
            if (pay.FreeFeeRate == 1)
            {
                pay.FeeRate = 0;
            }
            if (pay.FeeRate > 0)
            {
                order.Money_OnlinepayFee = order.Money_Pay * pay.FeeRate / 100;
            }
            if (order.OnlinePay_id != pay.id)
            {
                order.OnlinePay_id   = pay.id;
                order.OnlinePay_Code = pay.Code;
                order.OnlinePay      = pay.Name;
            }
            B_Lebi_Order.Update(order);
            Lebi_Currency currendy = B_Lebi_Currency.GetModel(pay.Currency_id);
            BaseConfig    SYS      = ShopCache.GetBaseConfig();

            Shop.Bussiness.Site site = new Shop.Bussiness.Site();
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //支付类型
            int payment_type = RequestTool.RequestInt("paytype");
            //必填,不能修改
            //服务器异步通知页面路径
            string notify_url = "http://" + RequestTool.GetRequestDomain() + site.WebPath + "/onlinepay/tonglianPay/notify_url.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = "http://" + RequestTool.GetRequestDomain() + site.WebPath + "/onlinepay/tonglianPay/return_url.aspx";

            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/


            merId  = pay.UserName;
            appId  = pay.Appid;
            payKey = pay.UserKey;
            //商户订单号
            string out_trade_no = order.Code;
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = order.Code;
            //必填

            //付款金额
            int total_fee = Convert.ToInt32(order.Money_Pay * currendy.ExchangeRate * (1 + (pay.FeeRate / 100)) * 100);
            //必填

            SortedDictionary <string, object> dict = new SortedDictionary <string, object>();

            dict["MerId"]     = merId;
            dict["AppId"]     = appId;
            dict["NonceStr"]  = PayHelp.GenerateNonceStr();
            dict["OrderId"]   = order.Code;
            dict["TotalFee"]  = total_fee;    //单位分
            dict["PayType"]   = payment_type; //1: 支付宝H5 2:微信H5 3:快捷支付 4:网关支付
            dict["IPVal"]     = GetHostAddress();
            dict["NotifyUrl"] = return_url;
            dict["ReturnUrl"] = notify_url;

            dict["Sign"] = PayHelp.MakeSign(dict, payKey);

            string resultStr = HttpHelp.PostMode("http://www.6q0b15.cn/PaySDK/PayAPI/ReadyPay", "xmlData=" + PayHelp.ToXml(dict));

            SystemLog.Add(resultStr);
            // return resultStr;
            try
            {
                JavaScriptSerializer jss = new JavaScriptSerializer();


                var model = jss.Deserialize <payreturn>(resultStr);
                if (model.status == 1)
                {
                    Response.Redirect(model.url);
                }
                else
                {
                    Response.Write(model.info);
                }
            }
            catch (Exception ex)
            {
                SystemLog.Add(ex.ToString());
            }
        }