Beispiel #1
0
        /// <summary>
        /// 威富通QQ钱包wap支付
        /// </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 static InnerResponse WftQQH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid)
        {
            // string str = "";
            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.loadCfgQQ(apptype, appid);
                UpdateOrdes order = new UpdateOrdes();
                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 (!order.OrdeUpdateInfo(orderid, int.Parse(cfg["pay_id"].ToString()), code))
                {
                    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.tenpay.native");                         //支付类型
                reqHandler.setParameter("mch_id", cfg["mch_id"].ToString());
                reqHandler.setParameter("version", cfg["version"].ToString());
                string notify_url = ConfigurationManager.AppSettings["WftTokenUrl"].ToString().Replace("{0}", cfg["pay_id"].ToString());
                reqHandler.setParameter("notify_url", notify_url);//回掉地址
                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)
                        {
                            inn           = inn.ToResponse(ErrorCode.Code100);
                            inn.ExtraData = param["code_url"];//http提交方式;
                            inn.IsJump    = true;
                        }
                        else
                        {
                            string wftzfsbxin = "威富通支付失败信息,错误代码:" + param["err_code"] + ",错误信息:" + param["err_msg"] + ",商户号:" + cfg["mch_id"].ToString();
                            PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wftzfsbxin, summary: "威富通QQ钱包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: "威富通QQ钱包Wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步验证错误", summary: "威富通QQ钱包Wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "威富通QQ钱包Wap接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Beispiel #2
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);
        }