Exemplo n.º 1
0
        /// <summary>
        /// 代付查询
        /// </summary>
        /// <returns></returns>
        public string SelectSubmit()
        {
            try
            {
                int Entrustid = 0;//出款订单ID
                Dictionary <String, String> paramdic = new Dictionary <String, String>();
                paramdic.Add("merchNo", userId);
                paramdic.Add("orderNo", DateTime.Now.ToString("yyyyMMdd_") + Entrustid);
                paramdic.Add("amount", 100.ToString());
                paramdic.Add("remitDate", DateTime.Now.ToString("yyyy-MM-dd"));

                paramdic = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);

                string sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + "MD5Key";
                paramdic.Add("sign", MD5Encrypt.MD5(sourceStr, false).ToUpper());

                paramdic  = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
                sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}";

                string publicKey   = "RSA代付公钥";// base.GateUserEmail;
                string cipher_data = "";
                publicKey = RSAEncodHelper.RSAPublicKeyJava2DotNet(publicKey);

                byte[] cdatabyte = RSAEncodHelper.RSAPublicKeySignByte(sourceStr, publicKey);
                cipher_data = Convert.ToBase64String(cdatabyte);

                string paramstr = "data=" + System.Web.HttpUtility.UrlEncode(cipher_data) + "&merchNo=" + userId + "&version=" + version;

                //string p = HttpUtil.BuildQuery(paramdic, true);
                string strResult = HttpPost.SendPost("http://127.0.0.1/api/queryRemitResult.action", paramstr, 5000);

                return(strResult);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 入款支付
        /// </summary>
        private string PaySubmit()
        {
            string payurl  = "http://47.94.6.240:9003/api/pay"; //请求地址
            string userId  = "LFP201808250000";                 //商户ID
            string orderNo = dateStr + "test";
            Dictionary <String, String> paramdic = new Dictionary <String, String>();

            paramdic.Add("merchNo", userId);
            paramdic.Add("netwayType", "WX");
            paramdic.Add("randomNo", new Random().Next(1000, 9999).ToString());    //随机号 可以重复
            paramdic.Add("orderNo", orderNo);                                      //订单交易号
            paramdic.Add("amount", "100");                                         //订单金额 单位分
            paramdic.Add("goodsName", "家具配套");                                     //商品名称
            paramdic.Add("notifyUrl", "http://www.xxx.com/api/callback.aspx");     //支付结果异步通知地址
            paramdic.Add("notifyViewUrl", "http://www.xxx.com/api/callback.aspx"); //回显地址
            paramdic = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);

            string sourceStr = "{";

            foreach (KeyValuePair <string, string> v in paramdic)
            {
                sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
            }
            sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + "MD5Key";
            paramdic.Add("sign", MD5Encrypt.MD5(sourceStr, false).ToUpper());

            paramdic  = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
            sourceStr = "{";
            foreach (KeyValuePair <string, string> v in paramdic)
            {
                sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
            }
            sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}";

            string publicKey   = "RSA支付公钥";// base.GateUserEmail;
            string cipher_data = "";

            publicKey = RSAEncodHelper.RSAPublicKeyJava2DotNet(publicKey);

            byte[] cdatabyte = RSAEncodHelper.RSAPublicKeySignByte(sourceStr, publicKey);
            cipher_data = Convert.ToBase64String(cdatabyte);

            string paramstr = "data=" + System.Web.HttpUtility.UrlEncode(cipher_data) + "&merchNo=" + userId + "&version=" + version;

            //string p = HttpUtil.BuildQuery(paramdic, true);
            string strResult = HttpPost.SendPost(payurl, paramstr, 5000);

            //支付返回
            #region 支付返回
            try
            {
                /*
                 * data={“key1":"val1","key2":"val2","sign":"1111111111111"}
                 *  key= AiYLumB03Fingt3R3ULdvFzS
                 *  metaSign={“key1":"val1","key2":"val2"}key,去除 sign 字段
                 *  sign=MD5(metaSign)
                 */
                //strResult="{\"merchNo\":\"XF201806040000\",\"msg\":\"提交成功\",\"orderNo\":\"20180801102543215VCqeRK\",\"qrcodeUrl\":\"https://qr.alipay.com/bax04012imdorbvgrls78018\",\"sign\":\"96DCC7A5140BF58CD02D18D518B770E9\",\"stateCode\":\"00\"}";
                if (string.IsNullOrEmpty(strResult))
                {
                    return("");
                }

                Dictionary <string, string> paramsDic = new Dictionary <string, string>();
                LitJson.JsonData            jd        = JsonMapper.ToObject(strResult);
                if (jd == null)
                {
                    return("");
                }
                if ((string)jd["stateCode"] != "00")
                {
                    return((string)jd["msg"]);
                }
                paramsDic.Add("merchNo", (string)jd["merchNo"]);
                paramsDic.Add("stateCode", (string)jd["stateCode"]);
                paramsDic.Add("msg", (string)jd["msg"]);
                paramsDic.Add("orderNo", (string)jd["orderNo"]);
                paramsDic.Add("qrcodeUrl", (string)jd["qrcodeUrl"]);

                paramsDic = paramsDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
                sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramsDic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + "MD5Key";
                if (MD5Encrypt.MD5(sourceStr, false).ToUpper().Equals((string)jd["sign"]) == false)
                {
                    //Log.WriteTextLog("RuiFuPayInfo", "PayCallBackHandle验签失败:返回原文:" + sourceStr + ";返回密钥:" + (string)jd["sign"] + "", DateTime.Now);
                    return("验签失败!" + strResult);
                }
                return((string)jd["qrcodeUrl"]);
            }
            catch (Exception ex)
            {
                //Log.WriteTextLog("RuiFuPayInfo", "PayCallBackHandle失败::" + ex.Message, DateTime.Now);
                return(ex.Message);
            }
            #endregion
        }
Exemplo n.º 3
0
        //入款支付查询
        private string PaySelect()
        {
            try
            {
                string orderSelectUrl = "http://127.0.0.1/api/queryPayResult";
                string netwayType     = "ZFB";
                string userId         = "HFB201808250000";
                Dictionary <String, String> paramdic = new Dictionary <String, String>();
                paramdic.Add("merchNo", userId);
                paramdic.Add("netwayType", netwayType);
                paramdic.Add("orderNo", dateStr + "test"); //订单交易号
                paramdic.Add("amount", "100");             //订单金额
                paramdic.Add("goodsName", "家具配套");         //商品名称
                paramdic.Add("payDate", DateTime.Now.ToString("yyyy-MM-dd"));
                paramdic = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);

                string sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + "MD5Key";
                paramdic.Add("sign", MD5Encrypt.MD5(sourceStr, false).ToUpper());

                paramdic  = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
                sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}";

                string publicKey   = "RSA支付公钥";// base.GateUserEmail;
                string cipher_data = "";
                publicKey = RSAEncodHelper.RSAPublicKeyJava2DotNet(publicKey);

                byte[] cdatabyte = RSAEncodHelper.RSAPublicKeySignByte(sourceStr, publicKey);
                cipher_data = Convert.ToBase64String(cdatabyte);

                string paramstr = "data=" + System.Web.HttpUtility.UrlEncode(cipher_data) + "&merchNo=" + userId + "&version=" + version;

                //string p = HttpUtil.BuildQuery(paramdic, true);
                string strResult = HttpPost.SendPost(orderSelectUrl, paramstr, 5000);


                #region 查询返回
                LitJson.JsonData jd = JsonMapper.ToObject(strResult);
                if (jd == null)
                {
                    return("");
                }
                if ((string)jd["stateCode"] != "00")
                {
                    return(string.Format("查询失败,状态:{0},消息:{1}", (string)jd["stateCode"], (string)jd["msg"]));
                }

                Dictionary <string, string> paramsDic = new Dictionary <string, string>();
                paramsDic.Add("merchNo", (string)jd["merchNo"]);
                paramsDic.Add("msg", (string)jd["msg"]);
                paramsDic.Add("stateCode", (string)jd["stateCode"]);
                paramsDic.Add("orderNo", (string)jd["orderNo"]);
                paramsDic.Add("payStateCode", (string)jd["payStateCode"]);

                paramsDic = paramsDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
                sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramsDic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + userId;
                if (MD5Encrypt.MD5(sourceStr, false).ToUpper().Equals((string)jd["sign"]) == false)
                {
                    return("验签失败!");
                }
                return(string.Format("订单状态:{0}(00:支付成功;06:初始,50:网络异常,04:其他错误,03:签名错误,01:失败,99:未支付,05:未知),消息:{1}", (string)jd["payStateCode"], ReturnStatusByCode((string)jd["payStateCode"])));

                #endregion
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 代付
        /// </summary>
        /// <returns></returns>
        public string DFSubmit()
        {
            try
            {
                string Entrustid      = "自己代付出款对应id";
                string m_bankcode     = "";
                string EntrusBankName = "自己项目对应银行编号";
                for (var i = 0; i < bankcodeArray.GetLength(0); i++)
                {
                    if (EntrusBankName.Contains(bankcodeArray[i, 1]))
                    {
                        m_bankcode = bankcodeArray[i, 0];
                        break;
                    }
                }

                if (m_bankcode == "")
                {
                    return("银行不支持");
                }

                Dictionary <String, String> paramdic = new Dictionary <String, String>();
                paramdic.Add("merchNo", userId);
                paramdic.Add("orderNo", DateTime.Now.ToString("yyyyMMdd_") + Entrustid);
                paramdic.Add("amount", "100");
                paramdic.Add("bankCode", m_bankcode);
                paramdic.Add("bankAccountName", "张三");                     //开户名
                paramdic.Add("bankAccountNo", "00000000000000");           //银行卡号
                paramdic.Add("notifyUrl", "http://127.0.0.1/callBackUrl"); // 回调地址
                //排序
                paramdic = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);

                string sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                //{"key":"value"}md5key
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}" + "MD5Key";

                paramdic.Add("sign", MD5Encrypt.MD5(sourceStr, false).ToUpper());

                paramdic  = paramdic.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
                sourceStr = "{";
                foreach (KeyValuePair <string, string> v in paramdic)
                {
                    sourceStr += string.Format("\"{0}\":\"{1}\",", v.Key, v.Value);
                }
                //{"key":"value"..."sign":""}
                sourceStr = sourceStr.Substring(0, sourceStr.Length - 1) + "}";
                //Log.WriteTextLog("RuiFuDaiFuInfo", "代付提交md5加密后:" + sourceStr, DateTime.Now);
                string publicKey   = "加密私钥";// base.GateUserEmail;
                string cipher_data = "";
                publicKey = RSAEncodHelper.RSAPublicKeyJava2DotNet(publicKey);

                byte[] cdatabyte = RSAEncodHelper.RSAPublicKeySignByte(sourceStr, publicKey);
                cipher_data = Convert.ToBase64String(cdatabyte);

                string paramstr = "data=" + System.Web.HttpUtility.UrlEncode(cipher_data) + "&merchNo=" + userId + "&version=" + version;
                //Log.WriteTextLog("RuiFuDaiFuInfo", "请求参数:" + paramstr, DateTime.Now);
                //string p = HttpUtil.BuildQuery(paramdic, true);
                string d         = paramstr;
                string strResult = HttpPost.SendPost("http://47.94.6.240:9003/api/remit", paramstr, 5000);


                return(strResult);
            }
            catch (Exception ex)
            {
                //Log.WriteTextLog("RuiFuDaiFuInfo", "DFSubmit()==>" + ex.Message, DateTime.Now);
                return(ex.Message);
            }
        }