Exemple #1
0
        public static string createPaySign(List <QueryParameter> parameters)
        {
            string        query   = QueryParameter.NormalizeRequestParameters(parameters);
            StringBuilder enValue = new StringBuilder();

            enValue.Append(query);
            enValue.Append("&key=" + WeChatUtilities.getConfigValue(WeChatUtilities.PAYAPI_KEY));
            string sign = CommonUtilities.encrypt_MD5(enValue.ToString()).ToUpper();

            return(sign);
        }
Exemple #2
0
        /// <summary>
        /// 生成针对微信JS接口的签名(SHA1)
        /// </summary>
        /// <param name="noncestr">随机字符串</param>
        /// <param name="jsapi_ticket">调用微信JS接口的临时票据</param>
        /// <param name="timestamp">请求的时间戳</param>
        /// <param name="url">当前网页URL</param>
        /// <returns>生成的SHA1签名</returns>
        public string generateWxJsApiSignature(string noncestr, string jsapi_ticket, string timestamp, string url)
        {
            List <QueryParameter> parameters = new List <QueryParameter>();

            parameters.Add(new QueryParameter("jsapi_ticket", jsapi_ticket));
            parameters.Add(new QueryParameter("noncestr", noncestr));
            parameters.Add(new QueryParameter("timestamp", timestamp));
            parameters.Add(new QueryParameter("url", url));
            string query = QueryParameter.NormalizeRequestParameters(parameters);

            return(CommonUtilities.encrypt_SHA1(query));
        }
Exemple #3
0
        public string KDT_GetTrade(DateTime st, DateTime et, string keyword)
        {
            List <QueryParameter> parameter = new List <QueryParameter>();

            // 系统级参数
            parameter.Add(new QueryParameter("method", "kdt.trades.sold.get"));
            parameter.Add(new QueryParameter("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            parameter.Add(new QueryParameter("v", "1.0"));
            parameter.Add(new QueryParameter("format", "json"));
            parameter.Add(new QueryParameter("app_id", appid));
            parameter.Add(new QueryParameter("sign_method", "md5"));
            // 应用及参数
            //parameter.Add(new QueryParameter("keyword", keyword));
            parameter.Add(new QueryParameter("status", "TRADE_BUYER_SIGNED"));
            parameter.Add(new QueryParameter("fields", "status,receiver_mobile"));
            parameter.Add(new QueryParameter("start_created", st.ToString("yyyy-MM-dd")));
            parameter.Add(new QueryParameter("end_created", et.ToString("yyyy-MM-dd")));
            parameter.Add(new QueryParameter("page_size", "50000"));
            //parameter.Add(new QueryParameter("buyer_nick", ToUnicodeString("许亦安")));
            string sign    = SignMD5(QueryParameter.NormalizeKDTParameters(parameter));
            string url     = "https://open.koudaitong.com/api/entry?sign=" + sign + "&" + QueryParameter.NormalizeRequestParameters(parameter);
            var    request = WebRequest.Create(url) as HttpWebRequest;

            request.Method = "GET";
            WebResponse response = request.GetResponse();
            string      result   = "";

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                result = reader.ReadToEnd();
            }
            return(result);
        }
Exemple #4
0
        public string KDT_GetRegion(int level, int?parentid)
        {
            List <QueryParameter> parameter = new List <QueryParameter>();

            parameter.Add(new QueryParameter("method", "kdt.regions.get"));
            parameter.Add(new QueryParameter("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            parameter.Add(new QueryParameter("v", "1.0"));
            parameter.Add(new QueryParameter("format", "json"));
            parameter.Add(new QueryParameter("app_id", appid));
            if (parentid != null)
            {
                parameter.Add(new QueryParameter("parent_id", parentid.ToString()));
            }
            parameter.Add(new QueryParameter("level", level.ToString()));
            parameter.Add(new QueryParameter("sign_method", "md5"));
            string sign    = SignMD5(QueryParameter.NormalizeKDTParameters(parameter));
            string url     = "https://open.koudaitong.com/api/entry?sign=" + sign + "&" + QueryParameter.NormalizeRequestParameters(parameter);
            var    request = WebRequest.Create(url) as HttpWebRequest;

            request.Method = "GET";
            WebResponse response = request.GetResponse();
            string      result   = "";

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                result = reader.ReadToEnd();
            }
            return(result);
        }