Example #1
0
        /// <summary>
        /// 获取带参数的请求URL
        /// </summary>
        /// <returns></returns>
        public virtual string getRequestURL()
        {
            this.createSign();

            StringBuilder sb    = new StringBuilder();
            ArrayList     akeys = new ArrayList(parameters.Keys);

            akeys.Sort();
            foreach (string k in akeys)
            {
                string v = (string)parameters[k];
                if (null != v && "key".CompareTo(k) != 0 && "spbill_create_ip".CompareTo(k) != 0)
                {
                    sb.Append(k + "=" + TenpayCoreHelper.UrlEncode(v, getCharset()) + "&");
                }
                else if ("spbill_create_ip".CompareTo(k) == 0)
                {
                    sb.Append(k + "=" + v.Replace(".", "%2E") + "&");
                }
            }

            //去掉最后一个&
            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }

            return(this.getGateUrl() + "?" + sb.ToString());
        }
Example #2
0
        public override void setContent(string content)
        {
            this.content = content;

            Regex r = new Regex("window.location.href[ \t]*=[ \t]*[\'\"]([^\'\"]*)[\'\"]", RegexOptions.IgnoreCase);
            Match m = r.Match(content);

            if (m.Success)
            {
                string url = m.Groups[1].ToString();

                char[] seps1 = new char[] { '?' };
                char[] seps2 = new char[] { '&' };
                char[] seps3 = new char[] { '=' };

                string[] urls = url.Split(seps1);
                if (urls != null && urls.Length >= 2)
                {
                    string[] paras = urls[1].Split(seps2);
                    foreach (string para in paras)
                    {
                        string[] kav = para.Split(seps3);
                        if (kav.Length == 2)
                        {
                            this.setParameter(kav[0], TenpayCoreHelper.UrlDecode(kav[1], this.getCharset()));
                        }
                    }
                }
                else
                {
                    this.setParameter("pay_result", "99");
                    this.setParameter("pay_info", "返回包格式错误,请检查协议是否改变!");
                }
            }
            else
            {
                this.setParameter("pay_result", "99");
                this.setParameter("pay_info", "返回包格式错误,请检查协议是否改变!");
            }
        }