Beispiel #1
0
        public override Model.Result CustomsQuery(int orderId)
        {
            string service                  = "alipay.overseas.acquire.customs.query";
            string partner                  = customsConfig.partner;
            string _input_charset           = "UTF-8";
            string sign_type                = "MD5";
            string sign                     = "";
            string out_request_nos          = "So00000060";
            string _sign                    = "";
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("_input_charset", _input_charset);
            dic.Add("out_request_nos", out_request_nos);
            dic.Add("partner", partner);
            dic.Add("service", service);
            // dic.Add("sign_type", sign_type);

            foreach (string key in dic.Keys)
            {
                if (!string.IsNullOrEmpty(sign))
                {
                    sign += "&";
                }
                sign += key + "=" + dic[key];
            }
            string param = sign;

            param += "&sign_type=" + sign_type;
            Hyt.Model.Common.PayConfig modelConfig = Hyt.BLL.Config.Config.Instance.GetPayConfig();
            sign += modelConfig.AliPaykey;
            //Game.Utils.FileManager.WriteFile(Hyt.Util.WebUtil.GetMapPath("/AliAcquireCustoms011.txt"), sign);
            if (sign_type == "MD5")
            {
                StringBuilder sb  = new StringBuilder(32);
                MD5           md5 = new MD5CryptoServiceProvider();
                byte[]        t   = md5.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(sign));
                for (int i = 0; i < t.Length; i++)
                {
                    sb.Append(t[i].ToString("x").PadLeft(2, '0'));
                }
                sign = sb.ToString();
            }
            //Game.Utils.FileManager.WriteFile(Hyt.Util.WebUtil.GetMapPath("/AliAcquireCustoms012.txt"), sign);
            _sign = sign;
            string url = "https://mapi.alipay.com/gateway.do?" + param + "&sign=" + sign;
            string xml = Hyt.Util.MyHttp.GetResponse(url);

            return(new Result()
            {
                Message = xml, Status = true
            });
        }
Beispiel #2
0
        /// <summary>
        /// 生成支付宝报关签名
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        /// <remarks>2016-06-06 杨云奕 添加</remarks>
        public static void CreateAlipayCustomsSign(AlipayCustomsMdl mdl)
        {
            string sign = "";
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("_input_charset", mdl._input_charset);
            dic.Add("amount", mdl.amount.ToString());
            dic.Add("customs_place", mdl.customs_place);
            dic.Add("merchant_customs_code", mdl.merchant_customs_code);
            dic.Add("merchant_customs_name", mdl.merchant_customs_name);
            dic.Add("out_request_no", mdl.out_request_no);
            dic.Add("partner", mdl.partner);
            dic.Add("service", mdl.service);
            dic.Add("trade_no", mdl.trade_no);
            foreach (string key in dic.Keys)
            {
                if (!string.IsNullOrEmpty(sign))
                {
                    sign += "&";
                }
                sign += key + "=" + dic[key];
            }
            Hyt.Model.Common.PayConfig modelConfig = Hyt.BLL.Config.Config.Instance.GetPayConfig();
            sign += modelConfig.AliPaykey;
            //Game.Utils.FileManager.WriteFile(Hyt.Util.WebUtil.GetMapPath("/AliAcquireCustoms011.txt"), sign);
            if (mdl.sign_type == "MD5")
            {
                StringBuilder sb  = new StringBuilder(32);
                MD5           md5 = new MD5CryptoServiceProvider();
                byte[]        t   = md5.ComputeHash(Encoding.GetEncoding(mdl._input_charset).GetBytes(sign));
                for (int i = 0; i < t.Length; i++)
                {
                    sb.Append(t[i].ToString("x").PadLeft(2, '0'));
                }
                sign = sb.ToString();
            }
            //Game.Utils.FileManager.WriteFile(Hyt.Util.WebUtil.GetMapPath("/AliAcquireCustoms012.txt"), sign);
            mdl.sign = sign;
        }