Пример #1
0
        internal string GetPrepay_id(PayDictionary dict, string sign)
        {
            dict.Add("sign", sign);
            string value = SignHelper.BuildQuery(dict, false);
            string text  = SignHelper.BuildXml(dict, false);
            string text2 = "";

            text2 = PayClient.PostData(PayClient.prepay_id_Url, text);
            try
            {
                DataTable dataTable = new DataTable();
                dataTable.TableName = "log";
                dataTable.Columns.Add(new DataColumn("OperTime"));
                dataTable.Columns.Add(new DataColumn("Info"));
                dataTable.Columns.Add(new DataColumn("param"));
                dataTable.Columns.Add(new DataColumn("query"));
                DataRow dataRow = dataTable.NewRow();
                dataRow["OperTime"] = DateTime.Now.ToString();
                dataRow["Info"]     = text2;
                dataRow["param"]    = text;
                dataRow["query"]    = value;
                dataTable.Rows.Add(dataRow);
                dataTable.WriteXml(HttpContext.Current.Request.MapPath("/PrepayID.xml"));
            }
            catch (Exception ex)
            {
                PayClient.writeLog(dict, sign, "", ex.Message + "-PrepayId获取错误");
            }
            return(text2);
        }
Пример #2
0
        internal string GetPrepay_id(PayDictionary dict, string sign)
        {
            dict.Add("sign", sign);
            string text     = SignHelper.BuildQuery(dict, false);
            string postData = SignHelper.BuildXml(dict, false);

            return(PayClient.PostData(PayClient.prepay_id_Url, postData));
        }
Пример #3
0
        internal string GetMWebUrl(PayDictionary dict, string sign, out string prepayId)
        {
            prepayId = "";
            dict.Add("sign", sign);
            string      url         = SignHelper.BuildQuery(dict, false);
            string      text        = SignHelper.BuildXml(dict, false);
            string      text2       = PayClient.PostData(PayClient.prepay_id_Url, text);
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.XmlResolver = null;
            try
            {
                xmlDocument.LoadXml(text2);
            }
            catch (Exception ex)
            {
                WxPayLog.writeLog(dict, "加载xml文件错误:" + text2 + ",错误信息:" + ex.Message, url, text, LogType.GetPrepayID);
                return("");
            }
            try
            {
                if (xmlDocument == null)
                {
                    WxPayLog.writeLog(dict, "加载xml文件错误:" + text2, url, text, LogType.GetPrepayID);
                    return("");
                }
                XmlNode xmlNode  = xmlDocument.SelectSingleNode("xml/return_code");
                XmlNode xmlNode2 = xmlDocument.SelectSingleNode("xml/result_code");
                if (xmlNode == null || xmlNode2 == null)
                {
                    WxPayLog.writeLog(dict, "retrunnode或者resultnode为空:" + text2, url, text, LogType.GetPrepayID);
                    return("");
                }
                XmlNode xmlNode3 = xmlDocument.SelectSingleNode("xml/prepay_id");
                if (xmlNode3 != null)
                {
                    prepayId = xmlNode3.InnerText;
                }
                if (xmlNode.InnerText == "SUCCESS" && xmlNode2.InnerText == "SUCCESS")
                {
                    XmlNode xmlNode4 = xmlDocument.SelectSingleNode("xml/mweb_url");
                    if (xmlNode4 != null)
                    {
                        return(xmlNode4.InnerText);
                    }
                    WxPayLog.writeLog(dict, "获取mweb_url结节为空:" + text2, url, text, LogType.GetPrepayID);
                    return("");
                }
                WxPayLog.writeLog(dict, "返回状态为不成功:" + text2, url, text, LogType.GetPrepayID);
                return("");
            }
            catch (Exception ex)
            {
                WxPayLog.writeLog(dict, "加载xml结点失败:" + text2 + ",错误信息:" + ex.Message, url, text, LogType.GetPrepayID);
                return("");
            }
        }