Пример #1
0
        /// <summary>
        /// 支付宝官方扫码H5通道
        /// </summary>
        /// <param name="apptype">应用类型子id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格(单位元)</param>
        /// <param name="orderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <param name="infoTime">查询接口信息缓存时间</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse IAliPaySmH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse inn = new InnerResponse();

            SelectInterface SeIn = new SelectInterface();

            try
            {
                string ZfbSmH5jkhc = "ZfbSmH5jkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(ZfbSmH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }

                //公共请求参数
                Dictionary <string, string> List = new Dictionary <string, string>();
                List.Add("app_id", SeIn.UserId);                                                                                       //支付宝应用ID
                List.Add("method", "alipay.trade.precreate");                                                                          //接口名称(请求类型)
                List.Add("charset", "utf-8");                                                                                          //请求使用的编码格式
                List.Add("sign_type", "RSA");                                                                                          //商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2
                List.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));                                                   //发送请求的时间
                List.Add("version", "1.0");                                                                                            //调用的接口版本
                List.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址。
                //请求参数
                Dictionary <string, string> Orlist = new Dictionary <string, string>();
                Orlist.Add("out_trade_no", code);             //商户订单号
                Orlist.Add("total_amount", price.ToString()); //订单总金额,单位为元,精确到小数点后两位,
                Orlist.Add("subject", goodsname);             //订单标题
                Orlist.Add("body", goodsname);                //对交易或商品的描述
                string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m";
                Orlist.Add("timeout_express", overtime);      //该笔订单允许的最晚付款时间,逾期将关闭交易。

                string biz_content = JsonHelper.DictJsonstr(Orlist);
                List.Add("biz_content", biz_content);

                string SignStr = UrlStr.AzGetStr(List);
                //签名
                string Sign = RSAFromPkcs8.sign(SignStr, SeIn.UserKey, "utf-8");
                //签名 注释:get请求时必须采用url编码方式(HttpUtility.UrlEncode)
                List.Add("sign", HttpUtility.UrlEncode(Sign));
                //请求地址
                string url    = ConfigurationManager.AppSettings["AliPaySmUrl"].ToString();
                string Urlstr = url + UrlStr.AzGetStr(List);

                HttpWebRequest  request        = (HttpWebRequest)HttpWebRequest.Create(Urlstr); //创建一个请求示例
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();        //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.UTF8);
                string          srcString      = streamReader.ReadToEnd();

                Root root = new Root();
                //对返回参数转换格式
                root = JsonHelper.Deserializes <Root>(srcString);

                if (root != null && root.alipay_trade_precreate_response.code == "10000" && root.alipay_trade_precreate_response.msg == "Success")
                {
                    string qurl      = root.alipay_trade_precreate_response.qr_code + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",1"; //组装二维码地址
                    string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + Encrypt.IndexEncrypt(qurl);       //二维码图片展示地址
                    string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + Encrypt.IndexEncrypt(qurl);          //二维码展示地址
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                            //http提交方式;
                }
                else
                {
                    string error = "支付宝官方扫码支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "支付宝官方扫码支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception ex)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.ToString(), summary: "支付官方宝扫码接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }

            return(inn);
        }
Пример #2
0
        /// <summary>
        ///小小贝支付宝wap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse XxbZFBWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string XxbZfbWaPH5jkhc = "XxbZfbWaPH5jkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(XxbZfbWaPH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> Palist = new Dictionary <string, string>();

                Palist.Add("merchantID", SeIn.UserId);                                                                                         //小小贝分配的appId
                Palist.Add("waresname", goodsname);                                                                                            //商品名称
                Palist.Add("cporderid", code);                                                                                                 //商户单号
                Palist.Add("price", price.ToString("f2"));                                                                                     //商品价格(单位:元),必填项
                Palist.Add("returnurl", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));            //同步
                Palist.Add("notifyurl", ConfigurationManager.AppSettings["XxbPayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址
                Palist.Add("paytype", "10006");                                                                                                //支付方式
                Palist.Add("ip", ip);                                                                                                          //ip

                //拼装签名
                var sign_prep = JMP.TOOL.UrlStr.AzGetStr(Palist) + "&key=" + SeIn.UserKey;
                //生成签名
                string sign = JMP.TOOL.MD5.md5strGet(sign_prep, true).ToLower();

                string json = "transdata=" + HttpUtility.UrlEncode(JMP.TOOL.JsonHelper.DictJsonstr(Palist)) + "&sign=" + HttpUtility.UrlEncode(sign) + "&signtype=MD5";
                //拼装地址
                string urlstr = ConfigurationManager.AppSettings["XxbZfbPayUrl"].ToString() + json;//请求地址

                //请求
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(urlstr);  //创建一个请求示例
                request.Method = "POST";
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse(); //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.UTF8);
                string          srcString      = streamReader.ReadToEnd();

                //json 转 键值集合
                RootObject obj = new RootObject();
                obj = JMP.TOOL.JsonHelper.Deserializes <RootObject>(srcString);


                if (obj != null && obj.resultCode == "20000")
                {
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = obj.info.payurl;//http提交方式;
                    inn.IsJump    = true;
                }
                else
                {
                    string xxbwxsbxinxi = "小小贝支付宝wap支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + xxbwxsbxinxi, summary: "小小贝支付宝wap支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "小小贝支付宝wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }

            return(inn);
        }
Пример #3
0
        /// <summary>
        /// 南粤app支付安卓调用方式
        /// </summary>
        /// <param name="appid">应用id</param>
        /// <param name="code">订单编号</param>
        /// <param name="price">商品价格</param>
        /// <param name="orderid">订单id</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="apptype">风控配置表id</param>
        /// <returns></returns>
        private InnerResponse NyAppidAz(int appid, string code, decimal price, int orderid, string goodsname, int apptype, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string Nyappid = "Nyappid" + appid;//组装缓存key值

                SeIn = SelectInfo(Nyappid, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> strlist = new Dictionary <string, string>();
                strlist.Add("tradeType", "cs.pay.submit");                                                                                  //交易类型
                strlist.Add("version", "1.3");                                                                                              //版本号
                strlist.Add("mchId", SeIn.UserId);                                                                                          //代理商号
                strlist.Add("channel", "wxApp");                                                                                            //支付渠道wxApp wxPub
                strlist.Add("body", goodsname);                                                                                             //商品描述
                strlist.Add("outTradeNo", code);                                                                                            //商户订单号
                strlist.Add("amount", price.ToString());                                                                                    //交易金额
                                                                                                                                            //strlist.Add("description", JMP.TOOL.Encrypt.IndexEncrypt(code));//自定义信息
                strlist.Add("mobileAppId", SeIn.wxappid);                                                                                   //appid时需要传入
                strlist.Add("notifyUrl", ConfigurationManager.AppSettings["NyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知
                string md5str = JMP.TOOL.UrlStr.AzGetStr(strlist) + "&key=" + SeIn.UserKey;
                string md5    = JMP.TOOL.MD5.md5strGet(md5str, true);
                strlist.Add("sign", md5);                                                          //签名
                string extra = "{\"mobileAppId\":\"" + SeIn.wxappid + "\",\"notifyUrl\":\"" + ConfigurationManager.AppSettings["NyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()) + "\"}";
                strlist.Add("extra", extra);                                                       //扩展字段
                string    postString   = JMP.TOOL.JsonHelper.DictJsonstr(strlist, "extra");        //这里即为传递的参数,可以用工具抓包分析,也可以自己分析,主要是form里面每一个name都要加进来
                byte[]    postData     = Encoding.UTF8.GetBytes(postString);                       //编码,尤其是汉字,事先要看下抓取网页的编码方式
                string    url          = ConfigurationManager.AppSettings["NYPOSTUrl"].ToString(); //地址
                WebClient webClient    = new WebClient();
                byte[]    responseData = webClient.UploadData(url, "POST", postData);              //得到返回字符流
                string    srcString    = Encoding.UTF8.GetString(responseData);                    //解码
                Dictionary <string, object> jsonstr = JMP.TOOL.JsonHelper.DataRowFromJSON(srcString);
                if (jsonstr.ContainsKey("returnCode") && jsonstr["resultCode"].ToString() == "0")
                {
                    string str = "{\"PaymentType\":\"5\",\"SubType\":\"2\"," + jsonstr["payCode"].ToString().Replace("{", "").Replace("}", "").Replace("package", "pkg") + ",\"IsH5\":\"0\"}";
                    //str = "{\"message\":\"成功\",\"result\":100,\"data\":" + str + "}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(str, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    string error = "南粤微信app接口错误信息:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "南粤微信app接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "南粤微信app接口错误信息", channelId: SeIn.PayId);

                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #4
0
        /// <summary>
        /// 中信银行微信wap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse ZxYhWxWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string ZxYhWxWaPH5jkhc = "ZxYhWxWaPH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(ZxYhWxWaPH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();
                Palist.Add("version", "1");                                                                                                 //版本号
                Palist.Add("agent_id", SeIn.UserId);                                                                                        //商户编号
                Palist.Add("agent_bill_id", code);                                                                                          //订单号
                Palist.Add("agent_bill_time", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                     //提交订单时间
                Palist.Add("pay_amt", price.ToString());                                                                                    //支付金额(单位:元)
                Palist.Add("notify_url", ConfigurationManager.AppSettings["HyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址
                Palist.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));        //同步通知地址
                Palist.Add("user_ip", HttpContext.Current.Request.UserHostAddress.Replace('.', '_'));                                       //ip地址
                Palist.Add("pay_type", "30");                                                                                               //支付类型
                Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));                                 //商品名称
                Palist.Add("bank_card_type", "1");                                                                                          //银行类型
                Palist.Add("scene", "h5");
                Palist.Add("remark", SeIn.UserIdZ);                                                                                         //自定义参数
                string meta_option = "{\"s\":\"WAP\",\"n\":\"测试\",\"id\":\"http://www.baidu.com\"}";
                Palist.Add("meta_option", Convert.ToBase64String(System.Text.Encoding.GetEncoding("GBK").GetBytes(meta_option.Trim())));
                string md5sing = "version=" + Palist["version"] + "&agent_id=" + Palist["agent_id"] + "&agent_bill_id=" + Palist["agent_bill_id"] + "&agent_bill_time=" + Palist["agent_bill_time"] + "&pay_type=30&pay_amt=" + Palist["pay_amt"] + "&notify_url=" + Palist["notify_url"] + "&return_url=" + Palist["return_url"] + "&user_ip=" + Palist["user_ip"] + "&bank_card_type=" + Palist["bank_card_type"] + "&remark=" + Palist["remark"] + "&key=" + SeIn.UserKey;
                string md5str  = JMP.TOOL.MD5.md5strGet(md5sing, true).ToLower();
                Palist.Add("sign", md5str);                                              //签名
                string url = ConfigurationManager.AppSettings["ZxYhPostUrl"].ToString(); //请求地址


                string strurl = url + "?" + JMP.TOOL.UrlStr.GetStrNV(Palist);

                inn           = inn.ToResponse(ErrorCode.Code100);
                inn.ExtraData = strurl;//http提交方式;
                inn.IsJump    = true;
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "中信银行微信wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #5
0
        /// <summary>
        /// 威富通微信公众号支付
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            int oid = !string.IsNullOrEmpty(Request["pid"]) ? Convert.ToInt32(Request["pid"].ToString()) : 0;

            if (oid > 0)
            {
                //获取缓存
                try
                {
                    string appid = "";
                    string appms = "";
                    string code  = !string.IsNullOrEmpty(Request["code"]) ? Request["code"] : "";
                    if (!String.IsNullOrEmpty(code))
                    {
                        //第二次
                        JMP.MDL.jmp_order morder = new JMP.BLL.jmp_order().SelectOrderGoodsName(oid, "jmp_order");
                        string            ddjj   = Get_paystr(morder.o_interface_id.ToString());
                        appid = ddjj.ToString().Split(',')[2];
                        appms = ddjj.ToString().Split(',')[3];
                        string         openid   = "";
                        string         URL      = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appms + "&code=" + code + "&grant_type=authorization_code";
                        Encoding       encoding = Encoding.UTF8;
                        HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(URL);
                        request.Timeout = 3000;
                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                        using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                        {
                            string jmpay = reader.ReadToEnd();
                            //解析json对象
                            JavaScriptSerializer        serializer = new JavaScriptSerializer();
                            Dictionary <string, object> json       = (Dictionary <string, object>)serializer.DeserializeObject(jmpay);
                            object value = null;
                            json.TryGetValue("openid", out value);
                            openid = value.ToString();
                        }
                        string str = "";
                        ClientResponseHandler       resHandler = new ClientResponseHandler();
                        PayHttpClient               pay        = new PayHttpClient();
                        RequestHandler              reqHandler = new RequestHandler(null);
                        Dictionary <string, string> cfg        = Utils.Load_CfgInterfaceId(morder.o_interface_id);
                        reqHandler.setGateUrl(cfg["req_url"].ToString());
                        reqHandler.setKey(cfg["key"].ToString());
                        reqHandler.setParameter("out_trade_no", morder.o_code);                                   //我们的订单号
                        reqHandler.setParameter("body", morder.o_goodsname);                                      //商品描述
                        // reqHandler.setParameter("attach", string.IsNullOrEmpty(morder.o_privateinfo) ? "404" : morder.o_privateinfo);//附加信息
                        reqHandler.setParameter("total_fee", (Convert.ToInt32(morder.o_price * 100)).ToString()); //价格
                        reqHandler.setParameter("mch_create_ip", HttpContext.Current.Request.UserHostAddress);    //终端IP
                        reqHandler.setParameter("service", "pay.weixin.jspay");
                        reqHandler.setParameter("mch_id", cfg["mch_id"].ToString());
                        reqHandler.setParameter("version", cfg["version"].ToString());
                        reqHandler.setParameter("notify_url", ConfigurationManager.AppSettings["notifyurl"].ToString().Replace("{0}", morder.o_interface_id.ToString())); //回掉地址
                        reqHandler.setParameter("callback_url", ConfigurationManager.AppSettings["callbackurl"].ToString().Replace("{0}", oid.ToString()));               //同步回掉地址
                        reqHandler.setParameter("sub_openid", openid);                                                                                                    //获取openid
                        reqHandler.setParameter("nonce_str", Utils.random());                                                                                             //随机字符串
                        reqHandler.setParameter("charset", "UTF-8");
                        reqHandler.setParameter("sign_type", "MD5");
                        reqHandler.setParameter("is_raw", "1");//原生JS
                        #region 判断是否需要禁用信用卡
                        //JMP.MDL.jmp_app moapp = new JMP.MDL.jmp_app();
                        //int tid = 0;
                        //string hc = "gzhpdxykjy" + morder.o_app_id;
                        //if (JMP.TOOL.CacheHelper.IsCache(hc))//判读是否存在缓存
                        //{
                        //    moapp = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_app>(hc);//获取缓存
                        //    if (moapp != null)
                        //    {
                        //        tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0;
                        //        if (tid == 0)
                        //        {
                        //            JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app();
                        //            moapp = blapp.SelectId(morder.o_app_id);
                        //            JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存
                        //        }
                        //    }
                        //    else
                        //    {
                        //        JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app();
                        //        moapp = blapp.SelectId(morder.o_app_id);
                        //        tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0;
                        //        JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存
                        //    }
                        //}
                        //else
                        //{
                        //    JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app();
                        //    moapp = blapp.SelectId(morder.o_app_id);
                        //    tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0;
                        //    JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存
                        //}
                        //if (tid == 71)
                        //{
                        //    reqHandler.setParameter("limit_credit_pay", "1");//是否限制信用卡(1:限制,0:不限制)
                        //}
                        #endregion
                        reqHandler.createSign();
                        string datawft = Utils.toXml(reqHandler.getAllParameters());
                        Dictionary <string, string> reqContent = new Dictionary <string, string>();
                        reqContent.Add("url", reqHandler.getGateUrl());
                        reqContent.Add("data", datawft);
                        pay.setReqContent(reqContent);
                        if (pay.call())
                        {
                            resHandler.setContent(pay.getResContent());
                            resHandler.setKey(cfg["key"].ToString());
                            Hashtable param = resHandler.getAllParameters();
                            Dictionary <string, string> dic = JMP.TOOL.UrlStr.hastable(param);
                            string wftmsg = JMP.TOOL.JsonHelper.DictJsonstr(dic);
                            if (resHandler.isTenpaySign())
                            {
                                if (int.Parse(param["status"].ToString()) == 0 && int.Parse(param["result_code"].ToString()) == 0)
                                {
                                    string pay_info = dic["pay_info"];
                                    if (!string.IsNullOrEmpty(pay_info))
                                    {
                                        Dictionary <string, object> List = new Dictionary <string, object>();
                                        List = JMP.TOOL.JsonHelper.DataRowFromJSON(pay_info);
                                        try
                                        {
                                            string chengstr = "<script type=\"text/javascript\">function onBridgeReady(){WeixinJSBridge.invoke( 'getBrandWCPayRequest', {\"appId\": \"" + List["appId"] + "\", \"timeStamp\": \"" + List["timeStamp"] + "\", \"nonceStr\": \"" + List["nonceStr"] + "\",\"package\":\"" + List["package"] + "\",\"signType\": \"MD5\",\"paySign\": \"" + List["paySign"] + "\" },function(res) {if (res.err_msg ==\"get_brand_wcpay_request:ok\") {  window.location.href=\"" + List["callback_url"] + "\" }else{ alert(res.err_msg) } });}if (typeof WeixinJSBridge == \"undefined\"){if (document.addEventListener){document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);}else if (document.attachEvent){document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);} }else{onBridgeReady();}</script> ";
                                            Response.Write(chengstr);
                                        }
                                        catch
                                        {
                                            string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg;
                                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富通公众号接口错误信息2", channelId: oid);
                                            str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                                        }
                                    }
                                    else
                                    {
                                        string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg;
                                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富通公众号接口错误信息4", channelId: oid);
                                        str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                                    }
                                }
                                else
                                {
                                    string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg;
                                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富公众号通接口错误信息3", channelId: oid);
                                    str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                                }
                            }
                            else
                            {
                                str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid, summary: "威富公众号通接口错误信息4", channelId: oid);
                            }
                        }
                        else
                        {
                            str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid, summary: "威富公众号通接口错误信息5", channelId: oid);
                        }
                        Response.Write(str);
                    }
                    else
                    {
                        JMP.MDL.jmp_app mo   = new JMP.MDL.jmp_app();
                        JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app();
                        mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + oid + ")  ").Tables[0]);
                        if (mo != null)
                        {
                            Dictionary <string, string> cfg = Utils.loadCfgWxgzh(mo.a_rid, mo.a_id);
                            JMP.BLL.jmp_order           bll = new JMP.BLL.jmp_order();
                            if (bll.UpdatePay(oid, int.Parse(cfg["pay_id"].ToString())))
                            {
                                string ddjj = Get_paystr(cfg["pay_id"].ToString());
                                appid = ddjj.ToString().Split(',')[2];
                                appms = ddjj.ToString().Split(',')[3];
                                string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + ConfigurationManager.AppSettings["redirecturi"].ToString() + oid + ".html&response_type=code&scope=snsapi_base#wechat_redirect";
                                Response.Redirect(url, false);
                            }
                        }
                        else
                        {
                            string str = "{\"Message\":\"支付接口异常\",\"ErrorCode\":102}";
                            Response.Write(str);
                        }
                    }
                }
                catch (Exception ex)
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.ToString() + "订单表id:" + oid, summary: "威富公众号通接口错误信息", channelId: oid);
                    Response.Write("非法访问!");
                }
            }
            else
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步判断,订单表id:" + oid, summary: "威富公众号通接口错误信息", channelId: oid);
                Response.Write("非法访问!");
            }
        }
Пример #6
0
        /// <summary>
        /// 汇元微信wap支付苹果调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse HyWxWaPIOS(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string HyWxWaPIOSjkhc = "HyWxWaPIOSjkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(HyWxWaPIOSjkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();
                Palist.Add("version", "1");                                             //版本号
                Palist.Add("agent_id", SeIn.UserId);                                    //商户编号
                Palist.Add("agent_bill_id", code);                                      //订单号
                Palist.Add("agent_bill_time", DateTime.Now.ToString("yyyyMMddHHmmss")); //提交订单时间
                Palist.Add("pay_amt", price.ToString());                                //支付金额(单位:元)

                Palist.Add("return_url", "https://www.baidu.com");                      //同步通知地址
                Palist.Add("user_ip", ip.Replace('.', '_'));                            //ip地址
                Palist.Add("pay_type", "30");                                           //支付类型
                Palist.Add("goods_num", "1");                                           //产品数量
                                                                                        //Palist.Add("goods_note", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//支付说明
                                                                                        // Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//商品名称
                                                                                        // Palist.Add("remark", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//自定义参数
                string meta_option = "[{\"s\":\"Android\",\"n\":\"\",\"id\":\"\"},{\"s\":\"IOS\",\"n\":\"测试\",\"id\":\"com.jurtevfdb.rykueryeqrg\"}]";
                string GotoUrlName = ConfigurationManager.AppSettings["GotoUrlName"];   //同步跳转域名
                string RetunUrl    = ConfigurationManager.AppSettings["RetunUrl"];      //异步跳转域名
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    Palist.Add("goods_note", goodsname); //支付说明
                    Palist.Add("goods_name", goodsname); //商品名称
                    Palist.Add("meta_option", meta_option.Trim());
                }
                else
                {
                    Palist.Add("goods_note", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312"))); //支付说明
                    Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312"))); //商品名称
                    Palist.Add("meta_option", Convert.ToBase64String(System.Text.Encoding.GetEncoding("GBK").GetBytes(meta_option.Trim())));
                }

                if (!string.IsNullOrEmpty(SeIn.ReturnUrl))
                {
                    Palist.Add("notify_url", ConfigurationManager.AppSettings["HyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()).Replace(RetunUrl, SeIn.ReturnUrl));//异步通知地址
                }
                else
                {
                    Palist.Add("notify_url", ConfigurationManager.AppSettings["HyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()));//异步通知地址
                }

                //Palist.Add("meta_option", Convert.ToBase64String(System.Text.Encoding.GetEncoding("GBK").GetBytes(meta_option.Trim())));
                string md5sing = "version=" + Palist["version"] + "&agent_id=" + Palist["agent_id"] + "&agent_bill_id=" + Palist["agent_bill_id"] + "&agent_bill_time=" + Palist["agent_bill_time"] + "&pay_type=30&pay_amt=" + Palist["pay_amt"] + "&notify_url=" + Palist["notify_url"] + "&user_ip=" + Palist["user_ip"] + "&key=" + SeIn.UserKey;
                string md5str  = JMP.TOOL.MD5.md5strGet(md5sing, true);
                Palist.Add("sign", md5str);//签名

                //参数
                // string data = JMP.TOOL.UrlStr.GetStrNV(Palist);
                //string url = ConfigurationManager.AppSettings["HywxsdkPOSTUrl"].ToString() + "?" + data;//请求地址
                string data = "";
                string url  = "";
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    data = JMP.TOOL.UrlStr.GetStrNV(Palist) + "&url=" + ConfigurationManager.AppSettings["HywxsdkPOSTUrl"].ToString() + "&jmtype=HY";
                    url  = SeIn.RequestUrl.Contains("http") || SeIn.RequestUrl.Contains("https") ? SeIn.RequestUrl : "http://" + SeIn.RequestUrl;//请求地址
                    url  = url + "/H5/Jump" + "?" + data;
                }
                else
                {
                    data = JMP.TOOL.UrlStr.GetStrNV(Palist);
                    url  = ConfigurationManager.AppSettings["HywxsdkPOSTUrl"].ToString() + "?" + data; //请求地址
                }
                HttpWebRequest  request        = (HttpWebRequest)HttpWebRequest.Create(url);           //创建一个请求示例
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();               //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.GetEncoding("GB2312"));
                string          srcString      = streamReader.ReadToEnd();

                //string url = ConfigurationManager.AppSettings["HywxsdkPOSTUrl"].ToString();//请求地址
                //WebClient webClient = new WebClient();
                //byte[] responseData = webClient.UploadValues(url, "POST", Palist);//得到返回字符流
                //string srcString = Encoding.UTF8.GetString(responseData);//解码

                if (srcString.Contains("token_id"))
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.LoadXml(srcString);
                    string token_id = xmldoc["token_id"].InnerText + "," + SeIn.UserId + "," + code + ",30";
                    string wxpay    = "{\"token_id\":\"" + token_id + "\",\"PaymentType\":\"2\",\"SubType\":\"2\",\"IsH5\":\"0\"}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxpay, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    string error = "汇元微信wap接口错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "汇元微信wap接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "汇元微信wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #7
0
        /// <summary>
        /// 微信官方扫码支付
        /// </summary>
        /// <param name="apptype">应用类型id</param>
        /// <param name="code">订单编号</param>
        /// <param name="price">商品价格</param>
        /// <param name="orderid">订单id</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse WxsmH5(int apptype, string code, decimal price, int orderid, string goodsname, int infoTime, int appid, string ip)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string WxsmH5 = "WxsmH5" + appid;//组装缓存key值

                SeIn = SelectInfo(WxsmH5, apptype, appid, infoTime);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> List = new Dictionary <string, string>();
                List.Add("appid", SeIn.wxappid);                                                                                         //微信appid
                List.Add("mch_id", SeIn.UserId);                                                                                         //商户号
                List.Add("nonce_str", code);                                                                                             //随机字符串
                List.Add("body", goodsname);                                                                                             //商品名称
                List.Add("out_trade_no", code);                                                                                          //商户订单号
                List.Add("total_fee", (Convert.ToInt32(price * 100)).ToString());                                                        //支付金额(单位:分)
                List.Add("spbill_create_ip", ip);                                                                                        //ip地址
                int overtime = int.Parse(ConfigurationManager.AppSettings["overtime"].ToString());
                List.Add("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                         //交易起始时间
                List.Add("time_expire", DateTime.Now.AddSeconds(overtime).ToString("yyyyMMddHHmmss"));                                   //交易结束时间
                List.Add("notify_url", ConfigurationManager.AppSettings["WxTokenUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址
                List.Add("trade_type", "NATIVE");                                                                                        //交易类型 NATIVE 微信扫码 JSAPI公众号
                string signstr = JMP.TOOL.UrlStr.AzGetStr(List) + "&key=" + SeIn.UserKey;
                string md5str  = JMP.TOOL.MD5.md5strGet(signstr, true).ToUpper();
                List.Add("sign", md5str);                                                    //签名
                string PostXmlStr = JMP.TOOL.xmlhelper.ToXml(List);
                string url        = ConfigurationManager.AppSettings["WxPayUrl"].ToString(); // 请求地址
                string Respon     = JMP.TOOL.postxmlhelper.postxml(url, PostXmlStr);
                Dictionary <string, object> dictionary = JMP.TOOL.xmlhelper.FromXml(Respon);
                if (dictionary.Count > 0 && dictionary["return_code"].ToString() == "SUCCESS" && dictionary.ContainsKey("code_url"))
                {
                    //string qcode = dictionary["code_url"].ToString();
                    string qurl      = dictionary["code_url"].ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",2";               //组装二维码地址
                    string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl); //二维码图片展示地址
                    string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl);    //二维码展示地址
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                               //http提交方式;
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "微信官方扫码接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #8
0
        /// <summary>
        /// 汇元QQwap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse HyQQWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string HyQQWaPH5jkhc = "HyQQWaPH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(HyQQWaPH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }

                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();

                Palist.Add("version", "1");                                             //当前接口版本号1
                Palist.Add("pay_type", "31");                                           //支付类型31,(数据类型:int)
                Palist.Add("agent_id", SeIn.UserId);                                    //商户编号
                Palist.Add("agent_bill_id", code);                                      //商户系统内部的订单号(要保证唯一)。长度最长50字符
                Palist.Add("pay_amt", price.ToString());                                //单位:元
                Palist.Add("user_ip", ip.Replace(".", "_"));                            //IP
                Palist.Add("agent_bill_time", DateTime.Now.ToString("yyyyMMddHHmmss")); //提交单据的时间
                string GotoUrlName = ConfigurationManager.AppSettings["GotoUrlName"];   //同步跳转域名
                string RetunUrl    = ConfigurationManager.AppSettings["RetunUrl"];      //异步跳转域名
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    Palist.Add("goods_name", goodsname);//商品名称
                }
                else
                {
                    Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//支付说明
                }

                if (!string.IsNullOrEmpty(SeIn.ReturnUrl))
                {
                    Palist.Add("notify_url", ConfigurationManager.AppSettings["HyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()).Replace(RetunUrl, SeIn.ReturnUrl));//异步通知地址
                }
                else
                {
                    Palist.Add("notify_url", ConfigurationManager.AppSettings["HyNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()));//异步通知地址
                }

                if (!string.IsNullOrEmpty(SeIn.GotoURL))
                {
                    Palist.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()).Replace(GotoUrlName, SeIn.GotoURL));//同步通知地址
                }
                else
                {
                    Palist.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));//同步通知地址
                }

                Palist.Add("timestamp", JMP.TOOL.WeekDateTime.GetMiliss);//时间戳13位
                Palist.Add("is_phone", "0");
                string md5sing = "version=" + Palist["version"] + "&agent_id=" + Palist["agent_id"] + "&agent_bill_id=" + Palist["agent_bill_id"] + "&agent_bill_time=" + Palist["agent_bill_time"] + "&pay_type=" + Palist["pay_type"] + "&pay_amt=" + Palist["pay_amt"] + "&notify_url=" + Palist["notify_url"] + "&return_url=" + Palist["return_url"] + "&user_ip=" + Palist["user_ip"] + "&key=" + SeIn.UserKey + "&timestamp=" + Palist["timestamp"];
                string md5str  = JMP.TOOL.MD5.md5strGet(md5sing, true);
                Palist.Add("sign", md5str);//签名
                UpdateOrdes uporder = new UpdateOrdes();
                if (!uporder.OrdeUpdateInfo(orderid, SeIn.PayId, code))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                //参数
                string data = "";
                string url  = "";
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    data = JMP.TOOL.UrlStr.GetStrNV(Palist) + "&url=" + ConfigurationManager.AppSettings["HyPOSTUrl"].ToString() + "&jmtype=HY";
                    // url = "http://192.168.1.54:52682/H5/Jump" + "?" + data;//请求地址
                    url = SeIn.RequestUrl.Contains("http") || SeIn.RequestUrl.Contains("https") ? SeIn.RequestUrl : "http://" + SeIn.RequestUrl;//请求地址
                    url = url + "/H5/Jump" + "?" + data;
                }
                else
                {
                    data = JMP.TOOL.UrlStr.GetStrNV(Palist);
                    url  = ConfigurationManager.AppSettings["HyPOSTUrl"].ToString() + "?" + data; //请求地址
                }
                HttpWebRequest  request        = (HttpWebRequest)HttpWebRequest.Create(url);      //创建一个请求示例
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();          //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.GetEncoding("GB2312"));
                string          srcString      = streamReader.ReadToEnd();

                if (!string.IsNullOrEmpty(srcString))
                {
                    //判断是否有返回支付连接
                    string QQPay = JMP.TOOL.Regular.IshiQQPay(srcString);
                    if (!string.IsNullOrEmpty(QQPay))
                    {
                        string QQPayUrl = JMP.TOOL.Regular.IshiQQPayUrl(QQPay);
                        if (!string.IsNullOrEmpty(QQPayUrl))
                        {
                            inn           = inn.ToResponse(ErrorCode.Code100);
                            inn.ExtraData = QQPayUrl.Replace("value=", "").Replace("\"", "").Replace("amp;", "").Trim();//http提交方式;
                            inn.IsJump    = true;
                        }
                        else
                        {
                            string error = "汇元QQWap支付正则表达式匹配URL错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "汇元QQWap支付接口错误信息", channelId: SeIn.PayId);
                            inn = inn.ToResponse(ErrorCode.Code104);
                        }
                    }
                    else
                    {
                        string error = "汇元QQWap支付正则表达式匹配支付地址是否存在错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "汇元QQWap支付接口错误信息", channelId: SeIn.PayId);
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    string error = "汇元QQWap支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "汇元QQWap支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "汇元QQwap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #9
0
        /// <summary>
        /// 途贝支付宝扫码支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse TbZfbSmH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string TbZfbSmH5jkhc = "TbZfbSmH5jkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(TbZfbSmH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> list = new Dictionary <string, string>();
                list.Add("mch_id", SeIn.UserId);                                                                                             //商户编号
                list.Add("nonce_str", code);                                                                                                 //随机字符串
                list.Add("body", goodsname);                                                                                                 //备注
                list.Add("out_trade_no", code);                                                                                              //订单号
                list.Add("total_fee", (Convert.ToInt32(price * 100)).ToString());                                                            //金额 单位分
                list.Add("spbill_create_ip", ip);                                                                                            //ip
                list.Add("notify_url", ConfigurationManager.AppSettings["TbpayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //通知地址
                list.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));           //页面回调地址
                list.Add("trade_type", "trade.alipay.native");                                                                               //交易类型

                string sign = JMP.TOOL.UrlStr.AzGetStr(list) + "&key=" + SeIn.UserKey;
                string md5  = JMP.TOOL.MD5.md5strGet(sign, true).ToUpper();

                list.Add("sign", md5);                                                      //签名
                string url       = ConfigurationManager.AppSettings["TbPayUrl"].ToString(); //请求地址
                string xml       = JMP.TOOL.xmlhelper.ToXml(list);
                string srcString = JMP.TOOL.postxmlhelper.postxml(url, xml);
                Dictionary <string, object> dict = JMP.TOOL.xmlhelper.FromXml(srcString);

                if (dict["return_code"].ToString() == "SUCCESS" && dict["result_code"].ToString() == "SUCCESS")
                {
                    string qurl      = dict["code_url"].ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",1";                     //组装二维码地址
                    string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl); //二维码图片展示地址
                    string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl);    //二维码展示地址
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                               //http提交方式;
                }
                else
                {
                    string tbzfbzfxx = "途贝支付宝扫码支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + tbzfbzfxx, summary: "途贝支付宝扫码支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "途贝支付宝扫码接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #10
0
        /// <summary>
        /// 现在支付宝wap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse XdZfbWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string XdZfbWaPAz = "XdZfbWaPAz" + appid;//组装缓存key值

                SeIn = SelectUserInfo(XdZfbWaPAz, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();
                Palist.Add("funcode", "WP001");                                                                                            //功能码
                Palist.Add("version", "1.0.0");                                                                                            //接口版本号
                Palist.Add("appId", SeIn.UserId);                                                                                          //商户应用唯一标识
                Palist.Add("mhtOrderNo", code);                                                                                            //商户订单号
                Palist.Add("mhtOrderName", goodsname);                                                                                     //商户商品名称
                Palist.Add("mhtOrderType", "01");                                                                                          //商户交易类型
                Palist.Add("mhtCurrencyType", "156");                                                                                      //商户订单币种类型
                Palist.Add("mhtOrderAmt", (Convert.ToInt32(price * 100)).ToString());                                                      //商户订单交易金额(单位:分)
                Palist.Add("mhtOrderDetail", goodsname);                                                                                   //商户订单详情
                Palist.Add("mhtOrderStartTime", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                  //下单时间
                Palist.Add("notifyUrl", ConfigurationManager.AppSettings["XdNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知
                Palist.Add("frontNotifyUrl", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));   //同步通知
                Palist.Add("mhtCharset", "UTF-8");                                                                                         //编码格式
                Palist.Add("deviceType", "0601");                                                                                          //设备类型
                Palist.Add("payChannelType", "12");                                                                                        //支付类型 银联:11 支付宝:12 微信:13
                Palist.Add("outputType", "1");                                                                                             //输出格式
                Palist.Add("mhtSignType", "MD5");                                                                                          //签名方式
                Palist.Add("mhtOrderTimeOut", ConfigurationManager.AppSettings["overtime"].ToString());                                    //商户订单超时时间
                string signstr = JMP.TOOL.UrlStr.GetStrAzNv(Palist) + "&" + JMP.TOOL.MD5.md5strGet(SeIn.UserKey, true).ToLower();
                string sign    = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower();
                Palist.Add("mhtSignature", sign);                                                  //签名
                string    url          = ConfigurationManager.AppSettings["XdPostUrl"].ToString(); //请求地址
                WebClient webClient    = new WebClient();
                byte[]    responseData = webClient.UploadValues(url, "POST", Palist);              //得到返回字符流
                string    srcString    = Encoding.UTF8.GetString(responseData);                    //解码
                string    json         = srcString.Replace("=", "\":\"").Replace("&", "\",\"");
                json = "{\"" + json + "\"}";
                Dictionary <string, object> dic = JMP.TOOL.JsonHelper.DataRowFromJSON(json);
                if (dic["responseCode"].ToString() == "A001" && json.Contains("tn"))
                {
                    string strurl = HttpUtility.UrlDecode(dic["tn"].ToString());
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = strurl;//http提交方式;
                    inn.IsJump    = true;
                }
                else
                {
                    string responseMsg = HttpUtility.UrlDecode(dic["responseMsg"].ToString());
                    string mesage      = "现在支付请求失败,错误代码:" + srcString + ",错误信息:" + json + "转换后的错误提示码:" + responseMsg + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + mesage, summary: "现在支付宝wap接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "现在支付宝wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #11
0
        /// <summary>
        /// 公众号转微信wap支付接口H5模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse gzhwaph5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes, int paymode)
        {
            InnerResponse   respon = new InnerResponse();
            InnerResponse   inn    = new InnerResponse();
            SelectInterface SeIn   = new SelectInterface();

            try
            {
                //查询应用是否开通微信公众号支付
                var payType = new PayWxGzh();
                var payc    = payType.LoadChannel(paymode, apptype, infoTimes, appid);
                if (string.IsNullOrEmpty(payc.PassName))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();

                string hckey = "wxgzhzwap" + appid;
                SeIn = SelectUserInfo(hckey, apptype, appid, infoTimes);
                JmPayParameter.JsonStr jsonStr = new JsonStr();
                PayBankModels          modes   = jsonStr.ParameterEntity(code, goodsname, price, "4", apptype, paymode);
                //h5模式
                respon = jsonStr.H5JsonStr(modes, ip);
                if (respon.ErrorCode == 100)
                {
                    Palist.Add("key", SeIn.UserKey);                                                             //key
                    Palist.Add("f", "json");                                                                     //API返回的格式支持json和js
                    Palist.Add("url", respon.ExtraData.ToString());                                              //要跳转的链接,先要经过urlencode编码
                    Palist.Add("b", "other");                                                                    //浏览器 默认other 表示其他浏览器,  baidu则表示手机百度,androd_chrome表示android chrome浏览器
                    string    urlstr                = ConfigurationManager.AppSettings["gzhzwapUrl"].ToString(); //公众号转wap请求地址
                    WebClient webClient             = new WebClient();
                    byte[]    responseData          = webClient.UploadValues(urlstr, "POST", Palist);            //得到返回字符流
                    string    srcString             = Encoding.UTF8.GetString(responseData);                     //解码
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic = JMP.TOOL.JsonHelper.DataRowFromJSON(srcString);
                    if (dic["status"].ToString() == "ok")
                    {
                        inn = inn.ToResponse(ErrorCode.Code100);
                        string ticket_url = dic["ticket_url"].ToString();
                        if (paymode == 3)
                        {
                            inn.ExtraData = ticket_url;
                            inn.IsJump    = true;
                        }
                        else
                        {
                            string json = "{\"data\":\"" + ticket_url + "\",\"PaymentType\":\"2\",\"SubType\":\"6\",\"IsH5\":\"1\"}";
                            inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(json, ConfigurationManager.AppSettings["encryption"].ToString());
                        }
                    }
                    else
                    {
                        inn = inn.ToResponse(ErrorCode.Code104);
                        //转换微信链接失败
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + srcString, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId);
                    }
                    return(inn);
                }
                else
                {
                    return(respon);
                }
            }
            catch (Exception ex)
            {
                inn = inn.ToResponse(ErrorCode.Code104);
                //转换微信链接失败
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId);
                return(inn);
            }
        }
Пример #12
0
        /// <summary>
        /// 南粤微信扫码支付
        /// </summary>
        /// <param name="apptype">应用类型id</param>
        /// <param name="code">订单编号</param>
        /// <param name="price">商品价格</param>
        /// <param name="orderid">订单id</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse NywxsmH5(int apptype, string code, decimal price, int orderid, string goodsname, int infoTime, int appid)
        {
            InnerResponse inn    = new InnerResponse();
            int           pay_id = 0;//支付渠道id

            try
            {
                string userid  = ""; //南粤公众号商户id
                string userkey = ""; //南粤公众号key

                decimal minmun  = 0;
                decimal maximum = 0;
                string  Nywxgzh = "Nywxgzh" + appid;//组装缓存key值
                #region 南粤微信扫码支付账号信息
                try
                {
                    DataTable             dt  = new DataTable();
                    JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface();
                    if (JMP.TOOL.CacheHelper.IsCache(Nywxgzh))
                    {
                        dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(Nywxgzh);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            int      row   = new Random().Next(0, dt.Rows.Count);
                            string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                            userid  = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的南粤微信扫码id
                            userkey = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的南粤微信扫码key
                            pay_id  = int.Parse(dt.Rows[row]["l_id"].ToString());
                            minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额
                            maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额
                        }
                        else
                        {
                            dt = bll.SelectPay("nywxsm", apptype, appid);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                int      row   = new Random().Next(0, dt.Rows.Count);
                                string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                                userid  = paypz[0].Replace("\r", "").Replace("\n", "").Trim();            //获取南粤公众号id
                                userkey = paypz[1].Replace("\r", "").Replace("\n", "").Trim();            //获取南粤公众号key
                                pay_id  = int.Parse(dt.Rows[row]["l_id"].ToString());
                                minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString());            //单笔最小支付金额
                                maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString());            //单笔最大支付金额
                                JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, Nywxgzh, infoTime); //存入缓存
                            }
                            else
                            {
                                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "南粤微信扫码接口错误", channelId: pay_id);
                                inn = inn.ToResponse(ErrorCode.Code106);
                                return(inn);
                            }
                        }
                    }
                    else
                    {
                        dt = bll.SelectPay("nywxsm", apptype, appid);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            int      row   = new Random().Next(0, dt.Rows.Count);
                            string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                            userid  = paypz[0].Replace("\r", "").Replace("\n", "").Trim();            //获取南粤公众号id
                            userkey = paypz[1].Replace("\r", "").Replace("\n", "").Trim();            //获取南粤公众号key
                            pay_id  = int.Parse(dt.Rows[row]["l_id"].ToString());
                            minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString());            //单笔最小支付金额
                            maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString());            //单笔最大支付金额
                            JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, Nywxgzh, infoTime); //存入缓存
                        }
                        else
                        {
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据库未查询到相关信息!", summary: "南粤微信扫码接口错误", channelId: pay_id);
                            inn = inn.ToResponse(ErrorCode.Code106);
                            return(inn);
                        }
                    }
                }
                catch (Exception e)
                {
                    string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "南粤微信扫码支付接口错误应用类型ID:" + apptype, channelId: pay_id);
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                #endregion
                if (!UpdateOrde.OrdeUpdateInfo(orderid, pay_id))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> strlist = new Dictionary <string, string>();
                strlist.Add("tradeType", "cs.pay.submit");                                                                              //交易类型
                strlist.Add("version", "1.3");                                                                                          //版本号
                strlist.Add("mchId", userid);                                                                                           //代理商号
                strlist.Add("channel", "wxPubQR");                                                                                      //支付渠道
                strlist.Add("body", goodsname);                                                                                         //商品描述
                strlist.Add("outTradeNo", code);                                                                                        //商户订单号
                strlist.Add("amount", price.ToString());                                                                                //交易金额
                                                                                                                                        //strlist.Add("description", JMP.TOOL.DESEncrypt.Encrypt(code));//自定义信息
                strlist.Add("notifyUrl", ConfigurationManager.AppSettings["NyNotifyUrl"].ToString().Replace("{0}", pay_id.ToString())); //异步通知
                strlist.Add("callbackUrl", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));  //同步通知
                string md5str = JMP.TOOL.UrlStr.AzGetStr(strlist) + "&key=" + userkey;
                string md5    = JMP.TOOL.MD5.md5strGet(md5str, true);
                strlist.Add("sign", md5);//签名
                string extra = "";
                //if (tid == 71)//判断应用类型是否需要禁用信用卡
                //{
                //    extra = "{\"callbackUrl\":\"" + ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", oid.ToString()) + "\",\"notifyUrl\":\"" + ConfigurationManager.AppSettings["NyNotifyUrl"].ToString().Replace("{0}", pay_id.ToString()) + "\",\"notifyUrl\":\"no_credit\"}";
                //}
                //else
                //{
                extra = "{\"callbackUrl\":\"" + ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()) + "\",\"notifyUrl\":\"" + ConfigurationManager.AppSettings["NyNotifyUrl"].ToString().Replace("{0}", pay_id.ToString()) + "\"}";
                // }
                strlist.Add("extra", extra);                                                       //扩展字段
                string    postString   = JMP.TOOL.JsonHelper.DictJsonstr(strlist, "extra");        //这里即为传递的参数,可以用工具抓包分析,也可以自己分析,主要是form里面每一个name都要加进来
                byte[]    postData     = Encoding.UTF8.GetBytes(postString);                       //编码,尤其是汉字,事先要看下抓取网页的编码方式
                string    url          = ConfigurationManager.AppSettings["NYPOSTUrl"].ToString(); //请求地址
                WebClient webClient    = new WebClient();
                byte[]    responseData = webClient.UploadData(url, "POST", postData);              //得到返回字符流
                string    srcString    = Encoding.UTF8.GetString(responseData);                    //解码
                Dictionary <string, object> jsonstr = JMP.TOOL.JsonHelper.DataRowFromJSON(srcString);
                if (jsonstr.ContainsKey("returnCode") && jsonstr["resultCode"].ToString() == "0")
                {
                    string qurl      = jsonstr["codeUrl"].ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",2";                   //组装二维码地址
                    string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl); //二维码图片展示地址
                    string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl);    //二维码展示地址
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                               //http提交方式;
                }
                else
                {
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "南粤微信扫码接口错误信息", channelId: pay_id);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #13
0
        /// <summary>
        /// 掌趣微信wap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse ZqWxWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string ZqWxWaPH5jkhc = "ZqWxWaPH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(ZqWxWaPH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }

                Dictionary <string, string> Palist = new Dictionary <string, string>();

                Palist.Add("merchantNo", SeIn.UserId);                                                                                               //商户编号
                Palist.Add("merchantOrderno", code);                                                                                                 //商户订单号
                Palist.Add("requestAmount", price.ToString());                                                                                       //订单金额(元)
                Palist.Add("noticeSysaddress", ConfigurationManager.AppSettings["ZqPayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址
                Palist.Add("noticeWebaddress", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));           //页面通知地址
                Palist.Add("memberNo", code);                                                                                                        //用户id
                Palist.Add("memberGoods", goodsname);                                                                                                //商品名称
                Palist.Add("payType", "WXWAP");                                                                                                      //支付类型
                //组装签名字符串
                string sign = Palist["merchantNo"].ToString() + Palist["merchantOrderno"].ToString() + Palist["requestAmount"].ToString() + Palist["noticeSysaddress"].ToString() + Palist["noticeWebaddress"].ToString() + Palist["memberNo"].ToString() + Palist["memberGoods"].ToString() + Palist["payType"].ToString();
                //签名
                string signstr = JMP.TOOL.Digest.HmacSign(sign, SeIn.UserKey);

                Palist.Add("hmac", signstr);//签名

                string urlstr = JMP.TOOL.UrlStr.AzGetStr(Palist);
                string url    = ConfigurationManager.AppSettings["ZqWxWapPayUrl"].ToString() + urlstr;//请求地址
                //发起请求
                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                string          jmpay    = "";
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                {
                    jmpay = reader.ReadToEnd();
                }
                Dictionary <string, object> dict = JMP.TOOL.JsonHelper.DataRowFromJSON(jmpay);
                if (dict["code"].ToString() == "000")
                {
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = dict["payUrl"].ToString();//http提交方式;
                    inn.IsJump    = true;
                }
                else
                {
                    string ErrorMessage = "掌趣微信wap支付错误代码:" + jmpay + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ErrorMessage, summary: "掌趣微信wap支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "掌趣微信wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #14
0
 /// <summary>
 /// 微信公众号第二次跳转
 /// </summary>
 /// <param name="Oid">订单id</param>
 /// <param name="Code">微信回传的Code编码</param>
 private void TwoJump(int Oid, string Code)
 {
     try
     {
         String            AppId        = "";
         String            AppSecret    = "";
         String            UserId       = "";
         String            UserKey      = "";
         JMP.MDL.jmp_order morder       = new JMP.BLL.jmp_order().SelectOrderGoodsName(Oid, "jmp_order");
         WeChatOpenId      weChatOpenId = new WeChatOpenId();
         String            PayStr       = weChatOpenId.GetPayStr(morder.o_interface_id.ToString(), "WxGfGZH");
         UserId    = PayStr.ToString().Split(',')[0]; //商户号
         UserKey   = PayStr.ToString().Split(',')[1]; //api秘钥
         AppId     = PayStr.ToString().Split(',')[2]; //微信appid
         AppSecret = PayStr.ToString().Split(',')[3]; //微信app秘钥
         string openid = weChatOpenId.SelectOpendi(AppId, AppSecret, Code);
         if (!string.IsNullOrEmpty(openid))
         {
             Dictionary <string, string> List = new Dictionary <string, string>();
             List.Add("appid", AppId);                                                                                                           //微信appid
             List.Add("mch_id", UserId);                                                                                                         //商户号
             List.Add("nonce_str", morder.o_code);                                                                                               //随机字符串
             List.Add("body", morder.o_goodsname);                                                                                               //商品名称
             List.Add("out_trade_no", morder.o_code);                                                                                            //商户订单号
             List.Add("total_fee", (Convert.ToInt32(morder.o_price * 100)).ToString());                                                          //支付金额(单位:分)
             List.Add("spbill_create_ip", HttpContext.Current.Request.UserHostAddress);                                                          //ip地址
             int overtime = int.Parse(ConfigurationManager.AppSettings["overtime"].ToString());
             List.Add("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                                    //交易起始时间
             List.Add("time_expire", DateTime.Now.AddSeconds(overtime).ToString("yyyyMMddHHmmss"));                                              //交易结束时间
             List.Add("notify_url", ConfigurationManager.AppSettings["WxTokenUrl"].ToString().Replace("{0}", morder.o_interface_id.ToString())); //异步通知地址
             List.Add("trade_type", "JSAPI");                                                                                                    //交易类型 NATIVE 微信扫码 JSAPI公众号
             List.Add("openid", openid);                                                                                                         //微信openid
             string signstr = JMP.TOOL.UrlStr.AzGetStr(List) + "&key=" + UserKey;
             string md5str  = JMP.TOOL.MD5.md5strGet(signstr, true).ToUpper();
             List.Add("sign", md5str);                                                    //签名
             string PostXmlStr = JMP.TOOL.xmlhelper.ToXml(List);
             string url        = ConfigurationManager.AppSettings["WxPayUrl"].ToString(); // 请求地址
             string Respon     = JMP.TOOL.postxmlhelper.postxml(url, PostXmlStr);
             Dictionary <string, object> dictionary = JMP.TOOL.xmlhelper.FromXml(Respon);
             if (dictionary.Count > 0 && dictionary["return_code"].ToString() == "SUCCESS" && dictionary["return_msg"].ToString() == "OK")
             {
                 CallJsApid(Oid, dictionary, UserKey, morder.o_showaddress);
             }
             else
             {
                 string wftzfsbxin = "微信官方公众号支付失败信息,错误信息:" + Respon;
                 PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "微信官方公众号第二次跳转接口错误信息", channelId: Oid);
                 String str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}";
                 Response.Write(str);
             }
         }
         else
         {
             Response.Write("非法访问!");
         }
     }
     catch (Exception ex)
     {
         PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号支付接口错误信息", channelId: Oid);
         Response.Write("非法访问!");
     }
 }
Пример #15
0
        /// <summary>
        /// 微派微信wap支付h5调用模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse WpWxWaPH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

            try
            {
                string WpWxWaPH5jkhc = "WpWxWaPH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(WpWxWaPH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> Palist = new Dictionary <string, string>();

                Palist.Add("appId", SeIn.UserId);                                                                                              //微派分配的appId
                Palist.Add("body", goodsname);                                                                                                 //商品名称
                Palist.Add("callback_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));         //支付成功后跳转的商户页面(用户看到的页面)
                Palist.Add("return_url", ConfigurationManager.AppSettings["WppayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //通知地址
                Palist.Add("channel_id", "default");                                                                                           //渠道编号
                Palist.Add("out_trade_no", code);                                                                                              //商户单号
                Palist.Add("total_fee", price.ToString());                                                                                     //商品价格(单位:元),必填项
                Palist.Add("version", "2.0");                                                                                                  //版本号,默认填写2.0即可,必填项
                Palist.Add("type", "wap");
                Palist.Add("callback", "WP.cbs.r0.f");
                Palist.Add("cpparam", code);
                //拼装签名
                var sign_prep = "app_id=" + Palist["appId"] + "&body=" + Palist["body"] + "&callback_url=" + Palist["callback_url"] + "&channel_id="
                                + Palist["channel_id"] + "&out_trade_no=" + Palist["out_trade_no"] + "&total_fee=" + Palist["total_fee"] + "&version=" + Palist["version"] + SeIn.UserKey;

                Palist.Add("sign", JMP.TOOL.MD5.md5strGet(sign_prep, true).ToUpper());

                string json   = JMP.TOOL.JsonHelper.DictJsonstr(Palist);
                string urlstr = ConfigurationManager.AppSettings["WpWxPayUrl"].ToString() + json; //请求地址

                HttpWebRequest  request        = (HttpWebRequest)HttpWebRequest.Create(urlstr);   //创建一个请求示例
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();          //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.UTF8);
                string          srcString      = streamReader.ReadToEnd();

                //截取中间的json格式字符串
                try
                {
                    string strjon = srcString.Replace("WP.cbs.r0.f(", " ").Trim();
                    strjon = strjon.Substring(0, strjon.Length - 1);
                    Dictionary <string, object> dict = JMP.TOOL.JsonHelper.DataRowFromJSON(strjon);
                    if (dict["resultCode"].ToString() == "success")
                    {
                        inn           = inn.ToResponse(ErrorCode.Code100);
                        inn.ExtraData = dict["url"].ToString();//http提交方式;
                        inn.IsJump    = true;
                    }
                    else
                    {
                        string wpwxsbxinxi = "微派微信wap支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wpwxsbxinxi, summary: "微派微信wap支付接口错误信息", channelId: SeIn.PayId);
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                catch
                {
                    string wpwxsbxinxi = "微派微信wap截取字符串出错,返回的字符串信息:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wpwxsbxinxi, summary: "微派微信wap支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "微派微信wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #16
0
        /// <summary>
        /// 威富通支付宝扫码支付
        /// </summary>
        /// <param name="tid">应用类型id</param>
        /// <param name="code">订单号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额(单位:元)</param>
        /// <param name="orderid">订单id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse WftZfbSm(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid)
        {
            InnerResponse inn = new InnerResponse();
            Dictionary <string, string> cfg = new Dictionary <string, string>();

            try
            {
                ClientResponseHandler resHandler = new ClientResponseHandler();
                PayHttpClient         pay        = new PayHttpClient();
                RequestHandler        reqHandler = new RequestHandler(null);
                cfg = Utils.loadCfgZfbSm(apptype, appid);

                if (cfg == null || string.IsNullOrEmpty(cfg["mch_id"]) || string.IsNullOrEmpty(cfg["pay_id"]) || string.IsNullOrEmpty(cfg["key"]))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, int.Parse(cfg["pay_id"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, decimal.Parse(cfg["minmun"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, decimal.Parse(cfg["maximum"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                //初始化数据
                reqHandler.setGateUrl(cfg["req_url"].ToString());
                reqHandler.setKey(cfg["key"].ToString());
                reqHandler.setParameter("out_trade_no", code);                                   //我们的订单号
                reqHandler.setParameter("body", goodsname);                                      //商品描述
                reqHandler.setParameter("total_fee", (Convert.ToInt32(price * 100)).ToString()); //价格(已传入的为准,无就从数据库读取)
                reqHandler.setParameter("mch_create_ip", ip);                                    //终端IP
                reqHandler.setParameter("service", "pay.alipay.native");                         //支付类型
                reqHandler.setParameter("mch_id", cfg["mch_id"].ToString());
                reqHandler.setParameter("version", cfg["version"].ToString());
                reqHandler.setParameter("notify_url", ConfigurationManager.AppSettings["WftTokenUrl"].ToString().Replace("{0}", cfg["pay_id"].ToString()));//回掉地址
                reqHandler.setParameter("nonce_str", Utils.random());
                reqHandler.setParameter("charset", "UTF-8");
                reqHandler.setParameter("sign_type", "MD5");
                reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                 //订单生成时间
                reqHandler.setParameter("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss")); //订单超时时间
                reqHandler.createSign();
                string datawft = Utils.toXml(reqHandler.getAllParameters());
                Dictionary <string, string> reqContent = new Dictionary <string, string>();
                reqContent.Add("url", reqHandler.getGateUrl());
                reqContent.Add("data", datawft);
                pay.setReqContent(reqContent);
                if (pay.call())
                {
                    resHandler.setContent(pay.getResContent());
                    resHandler.setKey(cfg["key"].ToString());
                    Hashtable param = resHandler.getAllParameters();
                    if (resHandler.isTenpaySign())
                    {
                        if (int.Parse(param["status"].ToString()) == 0 && int.Parse(param["result_code"].ToString()) == 0)
                        {
                            string qurl      = param["code_url"].ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",1";                    //组装二维码地址
                            string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl); //二维码图片展示地址
                            string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + JMP.TOOL.Encrypt.IndexEncrypt(qurl);    //二维码展示地址
                            inn           = inn.ToResponse(ErrorCode.Code100);
                            inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                               //http提交方式;
                        }
                        else
                        {
                            string wftzfsbxin = "威富通支付失败信息,错误代码:" + param["err_code"] + ",错误信息:" + param["err_msg"] + ",商户号:" + cfg["mch_id"].ToString();
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wftzfsbxin, summary: "威富通支付宝扫码接口错误信息", channelId: int.Parse(cfg["pay_id"]));
                            inn = inn.ToResponse(ErrorCode.Code104);
                        }
                    }
                    else
                    {
                        string mesage = "威富通支付失败信息,错误代码:" + resHandler.getContent() + ",错误信息:" + resHandler.getDebugInfo() + ",商户号:" + cfg["mch_id"].ToString();
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + mesage, summary: "威富通支付宝扫码接口错误信息", channelId: int.Parse(cfg["pay_id"]));
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步验证错误", summary: "威富通支付宝扫码接口错误信息", channelId: int.Parse(cfg["pay_id"]));
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "威富通支付宝扫码接口错误信息", channelId: int.Parse(cfg["pay_id"]));
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #17
0
        /// <summary>
        /// 威富通支付通道安卓调用方式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格</param>
        ///<param name="ooderid">订单表id</param>
        ///<param name="ip">ip地址</param>
        ///<param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse PayWftAz(int apptype, string code, string goodsname, decimal price, int oderid, string ip, int appid)
        {
            InnerResponse inn = new InnerResponse();
            Dictionary <string, string> cfg = new Dictionary <string, string>();

            try
            {
                ClientResponseHandler resHandler = new ClientResponseHandler();
                PayHttpClient         pay        = new PayHttpClient();
                RequestHandler        reqHandler = new RequestHandler(null);
                cfg = Utils.loadCfg(apptype, appid);

                if (cfg == null || string.IsNullOrEmpty(cfg["mch_id"]) || string.IsNullOrEmpty(cfg["pay_id"]) || string.IsNullOrEmpty(cfg["key"]))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(oderid, int.Parse(cfg["pay_id"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, decimal.Parse(cfg["minmun"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, decimal.Parse(cfg["maximum"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                //初始化数据
                reqHandler.setGateUrl(cfg["req_url"].ToString());
                reqHandler.setKey(cfg["key"].ToString());
                reqHandler.setParameter("out_trade_no", code);                                   //我们的订单号
                reqHandler.setParameter("body", goodsname);                                      //商品描述
                                                                                                 //reqHandler.setParameter("attach", privateinfo);//附加信息
                reqHandler.setParameter("total_fee", (Convert.ToInt32(price * 100)).ToString()); //价格(已传入的为准,无就从数据库读取)
                reqHandler.setParameter("mch_create_ip", ip);                                    //终端IP
                reqHandler.setParameter("service", "unified.trade.pay");
                reqHandler.setParameter("mch_id", cfg["mch_id"].ToString());
                reqHandler.setParameter("version", cfg["version"].ToString());
                reqHandler.setParameter("notify_url", ConfigurationManager.AppSettings["WftTokenUrl"].ToString().Replace("{0}", cfg["pay_id"].ToString()));//回掉地址
                reqHandler.setParameter("nonce_str", Utils.random());
                reqHandler.setParameter("charset", "UTF-8");
                reqHandler.setParameter("sign_type", "MD5");
                reqHandler.setParameter("device_info", "AND_WAP");
                reqHandler.setParameter("mch_app_name", "测试");
                reqHandler.setParameter("mch_app_id", "http://www.baidu.com");
                reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                 //订单生成时间
                reqHandler.setParameter("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss")); //订单超时时间
                reqHandler.createSign();
                string datawft = Utils.toXml(reqHandler.getAllParameters());
                Dictionary <string, string> reqContent = new Dictionary <string, string>();
                reqContent.Add("url", reqHandler.getGateUrl());
                reqContent.Add("data", datawft);
                pay.setReqContent(reqContent);
                if (pay.call())
                {
                    resHandler.setContent(pay.getResContent());
                    resHandler.setKey(cfg["key"].ToString());
                    Hashtable param = resHandler.getAllParameters();
                    if (resHandler.isTenpaySign())
                    {
                        if (int.Parse(param["status"].ToString()) == 0)
                        {
                            string wxpay = "{\"token_id\":\"" + param["token_id"].ToString() + "\", \"services\":\"pay.weixin.wappay\", \"sign\":\"" + param["sign"] + "\",\"status\":\"0\", \"charset\":\"UTF-8\", \"version\":\"2.0\", \"sign_type\":\"MD5\",\"PaymentType\":\"2\",\"SubType\":\"1\",\"IsH5\":\"0\"}";
                            // str = "{\"message\":\"成功\",\"result\":100,\"data\":" + wxpay + "}";
                            inn           = inn.ToResponse(ErrorCode.Code100);
                            inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxpay, ConfigurationManager.AppSettings["encryption"].ToString());
                        }
                        else
                        {
                            string wftzfsbxin = "威富通支付失败信息,错误代码:" + param["err_code"] + ",错误信息:" + param["err_msg"] + ",商户号:" + cfg["mch_id"].ToString();
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wftzfsbxin, summary: "威富通微信wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                            inn = inn.ToResponse(ErrorCode.Code104);
                        }
                    }
                    else
                    {
                        string mesage = "威富通支付失败信息,错误代码:" + resHandler.getContent() + ",错误信息:" + resHandler.getDebugInfo() + ",商户号:" + cfg["mch_id"].ToString();
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + mesage, summary: "威富通微信wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步验证错误", summary: "威富通微信wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "威富通微信wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Пример #18
0
        /// <summary>
        /// 优乐微信wap支付接口H5模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse YLh5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse inn = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();
            try
            {
                string YLh5 = "YLh5" + appid;//组装缓存key值

                SeIn = SelectUserInfo(YLh5, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return inn;
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return inn;
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return inn;
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return inn;
                }
                Dictionary<string, string> list = new Dictionary<string, string>();
                list.Add("mch_id", SeIn.UserId);//商户号
                list.Add("nonce_str", code);//随机字符串
                list.Add("body", goodsname);//商品描述
                list.Add("detail", "app_name=" + goodsname + "&bundle_id=com.tencent.wzryIOS");//商品详情
                list.Add("out_trade_no", code);//商户订单号
                list.Add("total_fee", (Convert.ToInt32(price * 100)).ToString());//总金额(单位分)
                list.Add("spbill_create_ip", ip); //终端 IP
                list.Add("notify_url", ConfigurationManager.AppSettings["YlWxWapNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()));//通知地址
                list.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));//页面回调地址
                list.Add("trade_type", "trade.weixin.h5pay");//交易类型
                string attach = JMP.TOOL.MD5.md5strGet(SeIn.UserId + code + SeIn.UserKey, true).ToUpper();
                list.Add("attach", attach);//附加信息
                string sign = JMP.TOOL.UrlStr.AzGetStr(list) + "&key=" + SeIn.UserKey;
                string md5 = JMP.TOOL.MD5.md5strGet(sign, true).ToUpper();
                list.Add("sign", md5);//签名
                string url = ConfigurationManager.AppSettings["YlWxWapPostUrl"].ToString();//请求地址
                string xml = JMP.TOOL.xmlhelper.ToXml(list);
                string srcString = JMP.TOOL.postxmlhelper.postxml(url, xml);
                Dictionary<string, object> dict = JMP.TOOL.xmlhelper.FromXml(srcString);

                if (dict["return_code"].ToString() == "SUCCESS" && dict["result_code"].ToString() == "SUCCESS")
                {
                    inn = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = dict["prepay_url"].ToString();//http提交方式;
                    inn.IsJump = true;
                }
                else
                {
                    string error = "优乐微信wap支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "优乐微信wap支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {

                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "优乐微信wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }

            return inn;
        }
Пример #19
0
        /// <summary>
        /// 获取汇元网账号信息
        /// </summary>
        /// <param name="cache">缓存key</param>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes)
        {
            SelectInterface SeIn = new SelectInterface();

            try
            {
                DataTable             dt  = new DataTable();
                JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface();
                if (JMP.TOOL.CacheHelper.IsCache(cache))
                {
                    dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        int      row   = new Random().Next(0, dt.Rows.Count);
                        string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                        SeIn.UserId     = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的汇元微信wap支付账号
                        SeIn.UserKey    = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的汇元微信wap支付key
                        SeIn.PayId      = int.Parse(dt.Rows[row]["l_id"].ToString());
                        SeIn.minmun     = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额
                        SeIn.maximum    = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额
                        SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null;
                        SeIn.GotoURL    = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null;
                        SeIn.ReturnUrl  = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null;
                    }
                    else
                    {
                        dt = bll.SelectPay("HYWX", apptype, appid);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            int      row   = new Random().Next(0, dt.Rows.Count);
                            string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                            SeIn.UserId     = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元微信wap支付账号
                            SeIn.UserKey    = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元微信wap支付key
                            SeIn.PayId      = int.Parse(dt.Rows[row]["l_id"].ToString());
                            SeIn.minmun     = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额
                            SeIn.maximum    = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额
                            SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null;
                            SeIn.GotoURL    = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null;
                            SeIn.ReturnUrl  = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null;
                            JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes);//存入缓存
                        }
                        else
                        {
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "汇元微信wap支付支付接口错误", channelId: SeIn.PayId);
                        }
                    }
                }
                else
                {
                    dt = bll.SelectPay("HYWX", apptype, appid);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        int      row   = new Random().Next(0, dt.Rows.Count);
                        string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                        SeIn.UserId     = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元微信wap支付账号
                        SeIn.UserKey    = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元微信wap支付key
                        SeIn.PayId      = int.Parse(dt.Rows[row]["l_id"].ToString());
                        SeIn.minmun     = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额
                        SeIn.maximum    = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额
                        SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null;
                        SeIn.GotoURL    = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null;
                        SeIn.ReturnUrl  = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null;
                        JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes);//存入缓存
                    }
                    else
                    {
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据库未查询到相关信息!", summary: "汇元微信wap支付支付接口错误", channelId: SeIn.PayId);
                    }
                }
            }
            catch (Exception e)
            {
                string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "汇元微信wap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId);
            }
            return(SeIn);
        }
Пример #20
0
        /// <summary>
        /// 查询微信官方扫码支付账户信息
        /// </summary>
        /// <param name="cache">缓存值</param>
        /// <param name="appid">应用id</param>
        /// <param name="apptype">风控配置表id</param>
        /// <returns></returns>
        private SelectInterface SelectInfo(string cache, int appid, int apptype, int infoTimes)
        {
            SelectInterface SeIn = new SelectInterface();

            try
            {
                DataTable             dt  = new DataTable();
                JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface();
                if (JMP.TOOL.CacheHelper.IsCache(cache))
                {
                    dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        int      row   = new Random().Next(0, dt.Rows.Count);
                        string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                        SeIn.UserId  = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取微信商户号
                        SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid
                        SeIn.UserKey = paypz[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥
                        SeIn.PayId   = int.Parse(dt.Rows[row]["l_id"].ToString());          //获取支付通道id
                        SeIn.minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额
                        SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额
                    }
                    else
                    {
                        dt = bll.SelectPay("WXGFGZH", appid, apptype);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            int      row   = new Random().Next(0, dt.Rows.Count);
                            string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                            SeIn.UserId  = paypz[0].Replace("\r", "").Replace("\n", "").Trim();      //获取微信商户号
                            SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim();      //获取微信appid
                            SeIn.UserKey = paypz[2].Replace("\r", "").Replace("\n", "").Trim();      //获取微信秘钥
                            SeIn.PayId   = int.Parse(dt.Rows[row]["l_id"].ToString());               //获取支付通道id
                            SeIn.minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString());      //单笔最小支付金额
                            SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString());      //单笔最大支付金额
                            JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存
                        }
                        else
                        {
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "微信官方扫码支付接口错误", channelId: SeIn.PayId);
                        }
                    }
                }
                else
                {
                    dt = bll.SelectPay("WXGFGZH", appid, apptype);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        int      row   = new Random().Next(0, dt.Rows.Count);
                        string[] paypz = dt.Rows[row]["l_str"].ToString().Split(',');
                        SeIn.UserId  = paypz[0].Replace("\r", "").Replace("\n", "").Trim();      //获取微信商户号
                        SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim();      //获取微信appid
                        SeIn.UserKey = paypz[2].Replace("\r", "").Replace("\n", "").Trim();      //获取微信秘钥
                        SeIn.PayId   = int.Parse(dt.Rows[row]["l_id"].ToString());               //获取支付通道id
                        SeIn.minmun  = decimal.Parse(dt.Rows[row]["l_minimum"].ToString());      //单笔最小支付金额
                        SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString());      //单笔最大支付金额
                        JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存
                    }
                    else
                    {
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",直接从数据库未查询到相关信息!", summary: "微信官方扫码支付接口错误", channelId: SeIn.PayId);
                    }
                }
            }
            catch (Exception e)
            {
                string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();            //报错信息
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "微信官方扫码支付接口错误应用ID:" + appid, channelId: SeIn.PayId); //写入报错日志
            }
            return(SeIn);
        }