Esempio n. 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="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse PfZfbSmH5(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 PfZfbSmH5 = "PfZfbSmH5" + appid;//组装缓存key值

                SeIn = SelectUserInfo(PfZfbSmH5, 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);
                }
                string     xml       = "<?xml version='1.0' encoding='utf-8' ?><ORDER_REQ><BUSI_ID>" + SeIn.UserId + "</BUSI_ID><OPER_ID>oper01</OPER_ID><DEV_ID>dev01</DEV_ID><AMT>" + price + "</AMT><CHANNEL_TYPE>1</CHANNEL_TYPE><PAY_SUBJECT>" + goodsname + "</PAY_SUBJECT ><CHARGE_CODE>" + code + "</CHARGE_CODE><NODIFY_URL>" + ConfigurationManager.AppSettings["pfalpayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()) + "</NODIFY_URL><TIME_EXPIRE>" + ConfigurationManager.AppSettings["overtime"].ToString() + "</TIME_EXPIRE></ORDER_REQ>";
                string     timestamp = JMP.TOOL.WeekDateTime.GetMilis;//时间戳
                string     signstr   = timestamp + SeIn.UserKey + xml.Replace(" ", "");
                string     sign      = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower() + ":" + timestamp;;
                string     url       = ConfigurationManager.AppSettings["pfalpayPostUrl"].ToString() + "?sign=" + sign + "&_type=json&busiCode=" + SeIn.UserId;
                string     json      = JMP.TOOL.postxmlhelper.postxml(url, xml);
                RootObject obj       = new RootObject();
                obj = JMP.TOOL.JsonHelper.Deserializes <RootObject>(json);
                if (obj != null && obj.ORDER_RESP.RESULT.CODE == "SUCCESS" && json.Contains("BAR_CODE"))
                {
                    string qurl      = obj.ORDER_RESP.BAR_CODE + "," + 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
                {
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), SeIn.PayId, summary: "浦发支付宝扫码接口错误信息");
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 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 WwWxWaPH5(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 WwWxWaPH5jkhc = "WwWxWaPH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(WwWxWaPH5jkhc, 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("mch", SeIn.UserId);                                                                                                //商户编号
                Palist.Add("pay_type", "wxhtml");                                                                                              //支付类型
                Palist.Add("money", (Convert.ToInt32(price * 100)).ToString());                                                                //订单的资金总额,单位为 RMB-分。大于或等于100的数字
                Palist.Add("time", JMP.TOOL.WeekDateTime.GetMilis);                                                                            //订单时间,格式:Unix时间戳,精确到秒,请用北京时间,时间误差超过1小时会抛弃此订单
                Palist.Add("order_id", code);                                                                                                  //订单编号
                Palist.Add("notify_url", ConfigurationManager.AppSettings["WwpayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //通知地址
                Palist.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString()));           //页面回调地址

                string sign = Palist["order_id"] + Palist["money"] + Palist["pay_type"] + Palist["time"] + Palist["mch"] + JMP.TOOL.MD5.md5strGet(SeIn.UserKey, true).ToLower();
                Palist.Add("sign", JMP.TOOL.MD5.md5strGet(sign, true).ToLower());     //签名参数,签名结果统一转换为小写字符

                string url = ConfigurationManager.AppSettings["WwPayUrl"].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);
        }
Esempio n. 3
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 PfZfbWaPAz(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 PfZfbWaPAzjkhc = "PfZfbWaPAzjkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(PfZfbWaPAzjkhc, 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);
                }
                string     xml       = "<?xml version='1.0' encoding='utf-8' ?><ORDER_REQ><BUSI_ID>" + SeIn.UserId + "</BUSI_ID><OPER_ID>oper01</OPER_ID><DEV_ID>dev01</DEV_ID><AMT>" + price + "</AMT><CHANNEL_TYPE>1</CHANNEL_TYPE><PAY_SUBJECT>" + goodsname + "</PAY_SUBJECT ><CHARGE_CODE>" + code + "</CHARGE_CODE><NODIFY_URL>" + ConfigurationManager.AppSettings["pfalpayNotifyUrl"].ToString().Replace("{0}", SeIn.PayId.ToString()) + "</NODIFY_URL><TIME_EXPIRE>" + ConfigurationManager.AppSettings["overtime"].ToString() + "</TIME_EXPIRE></ORDER_REQ>";
                string     timestamp = JMP.TOOL.WeekDateTime.GetMilis;//时间戳
                string     signstr   = timestamp + SeIn.UserKey + xml.Replace(" ", "");
                string     sign      = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower() + ":" + timestamp;
                string     url       = ConfigurationManager.AppSettings["pfalpayPostUrl"].ToString() + "?sign=" + sign + "&_type=json&busiCode=" + SeIn.UserId;
                string     json      = JMP.TOOL.postxmlhelper.postxml(url, xml);
                RootObject obj       = new RootObject();
                obj = JMP.TOOL.JsonHelper.Deserializes <RootObject>(json);
                if (obj != null && obj.ORDER_RESP.RESULT.CODE == "SUCCESS" && json.Contains("BAR_CODE"))
                {
                    string Alpay = "{\"PaymentType\":\"1\",\"SubType\":\"3\",\"CHARGE_CODE\":\"" + obj.ORDER_RESP.CHARGE_CODE + "\",\"BUSI_ID\":\"" + SeIn.UserId + "\",\"data\":\"" + obj.ORDER_RESP.BAR_CODE + "\",\"IsH5\":\"1\"}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(Alpay, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "浦发支付宝wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 4
0
File: HyPay.cs Progetto: dmhai/dxpay
        /// <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 HyYlPayH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse   inn           = new InnerResponse();
            string          HyYlPayH5jkhc = "HyYlPayH5jkhc" + appid;//组装缓存key值
            SelectInterface SeIn          = new SelectInterface();

            SeIn = SelectUserInfo(HyYlPayH5jkhc, 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", ip.Replace('.', '_'));                                                                                //ip地址
            Palist.Add("pay_type", "0");                                                                                                //支付类型
            Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));                                 //商品名称
            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=0&pay_amt=" + Palist["pay_amt"] + "&notify_url=" + Palist["notify_url"] + "&return_url=" + Palist["return_url"] + "&user_ip=" + Palist["user_ip"] + "&key=" + SeIn.UserKey;
            string md5str  = JMP.TOOL.MD5.md5strGet(md5sing, true);

            Palist.Add("sign", md5str);                                               //签名
            string url    = ConfigurationManager.AppSettings["HyPOSTUrl"].ToString(); //请求地址
            string strurl = url + "?" + JMP.TOOL.UrlStr.GetStrNV(Palist);

            inn           = inn.ToResponse(ErrorCode.Code100);
            inn.ExtraData = strurl;//http提交方式;
            inn.IsJump    = true;
            return(inn);
        }
Esempio n. 5
0
        /// <summary>
        /// 支付包支付通道H5调用方式
        /// </summary>
        /// <param name="apptype">应用类型id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格</param>
        /// <param name="TableName">订单表表名</param>
        /// <returns></returns>
        private InnerResponse PayZfbH5(int apptype, string code, string goodsname, decimal price, int oderid, string IP, int appid)
        {
            InnerResponse inn = new InnerResponse();

            JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order();
            Config            cfg = new Config(apptype, appid);
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            if (!UpdateOrde.OrdeUpdateInfo(oderid, cfg.pay_id))
            {
                inn = inn.ToResponse(ErrorCode.Code101);
                return(inn);
            }
            if (!JudgeMoney.JudgeMinimum(price, cfg.minmun))
            {
                inn = inn.ToResponse(ErrorCode.Code8990);
                return(inn);
            }
            if (!JudgeMoney.JudgeMaximum(price, cfg.maximum))
            {
                inn = inn.ToResponse(ErrorCode.Code8989);
                return(inn);
            }
            sParaTemp.Add("partner", cfg.partner);
            sParaTemp.Add("seller_id", cfg.seller_id);
            sParaTemp.Add("_input_charset", cfg.input_charset.ToLower());
            sParaTemp.Add("service", "alipay.wap.create.direct.pay.by.user");
            sParaTemp.Add("payment_type", "1");
            sParaTemp.Add("sign_type", "RSA");
            sParaTemp.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", cfg.pay_id.ToString())); //需要封装TokenUrl(异步回调地址)
            sParaTemp.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", oderid.ToString()));      //同步支付成功界面跳转地址
            string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m";

            sParaTemp.Add("it_b_pay", overtime);          //订单超时时间
            sParaTemp.Add("out_trade_no", code);          //我们的订单号
            sParaTemp.Add("subject", goodsname);          //商品名称(根据商品id查询商品名称)
            sParaTemp.Add("total_fee", price.ToString()); //价格(已传入的为准,无就从数据库读取)
            sParaTemp.Add("body", goodsname);             //商品名称(备注)
            sParaTemp.Add("app_pay", "Y");                //吊起app
            string httpurl = new Alipay.Submit(apptype, appid).BuildRequestHttp(sParaTemp);

            inn           = inn.ToResponse(ErrorCode.Code100);
            inn.ExtraData = httpurl;//http提交方式;
            inn.IsJump    = true;
            return(inn);
        }
Esempio n. 6
0
        /// <summary>
        /// 支付宝支付通道安卓调用方式
        /// </summary>
        /// <param name="apptype">应用类型子id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">价格(单位元)</param>
        /// <param name="oderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <returns></returns>
        private InnerResponse PayZfbAz(int apptype, string code, string goodsname, decimal price, int oderid, string ip, int appid)
        {
            InnerResponse inn = new InnerResponse();
            Config        cfg = new Config(apptype, appid);
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order();
            if (!UpdateOrde.OrdeUpdateInfo(oderid, cfg.pay_id))
            {
                inn = inn.ToResponse(ErrorCode.Code101);
                return(inn);
            }
            if (!JudgeMoney.JudgeMinimum(price, cfg.minmun))
            {
                inn = inn.ToResponse(ErrorCode.Code8990);
                return(inn);
            }
            if (!JudgeMoney.JudgeMaximum(price, cfg.maximum))
            {
                inn = inn.ToResponse(ErrorCode.Code8989);
                return(inn);
            }
            sParaTemp.Add("partner", cfg.partner);
            sParaTemp.Add("seller_id", cfg.seller_id);
            sParaTemp.Add("_input_charset", cfg.input_charset.ToLower());
            sParaTemp.Add("service", "mobile.securitypay.pay");
            sParaTemp.Add("payment_type", "1");
            sParaTemp.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", cfg.pay_id.ToString()));//需要封装(接收回传地址)TokenUrl
            string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m";

            sParaTemp.Add("it_b_pay", overtime);          //订单超时时间
            sParaTemp.Add("out_trade_no", code);          //我们的订单号
            sParaTemp.Add("subject", goodsname);          //商品i名称(根据商品id查询商品名称)
            sParaTemp.Add("total_fee", price.ToString()); //价格(已传入的为准,无就从数据库读取)
            sParaTemp.Add("body", goodsname);             //商品名称(备注)
            string str = "{\"data\":\"" + new Alipay.Submit(apptype, appid).BuildRequest1(sParaTemp) + "\",\"PaymentType\":\"1\",\"SubType\":\"1\",\"IsH5\":\"0\"} ";

            inn           = inn.ToResponse(ErrorCode.Code100);
            inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(str, ConfigurationManager.AppSettings["encryption"].ToString());
            return(inn);
        }
Esempio n. 7
0
        /// <summary>
        /// 融梦微信扫支付
        /// </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 RmWxSmH5(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
                string partnerId = ""; //cpid

                decimal minmun   = 0;
                decimal maximum  = 0;
                string  RmWxSmH5 = "RmWxSmH5" + appid;//组装缓存key值
                #region 融梦微信扫码支付账号信息
                try
                {
                    DataTable             dt  = new DataTable();
                    JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface();
                    if (JMP.TOOL.CacheHelper.IsCache(RmWxSmH5))
                    {
                        dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(RmWxSmH5);
                        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
                            partnerId = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的融梦微信扫码cpid
                            userkey   = paypz[2].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("RMWXSM", 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
                                partnerId = paypz[1].Replace("\r", "").Replace("\n", "").Trim();           //获取缓存数据中的融梦微信扫码cpid
                                userkey   = paypz[2].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, RmWxSmH5, infoTime); //存入缓存
                            }
                            else
                            {
                                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "融梦微信扫码接口错误", channelId: pay_id);
                                inn = inn.ToResponse(ErrorCode.Code106);
                                return(inn);
                            }
                        }
                    }
                    else
                    {
                        dt = bll.SelectPay("RMWXSM", 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
                            partnerId = paypz[1].Replace("\r", "").Replace("\n", "").Trim();           //获取缓存数据中的融梦微信扫码cpid
                            userkey   = paypz[2].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, RmWxSmH5, 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> list = new Dictionary <string, string>();
                list.Add("appId", userid);                                       //产品id
                list.Add("partnerId", partnerId);                                //cpid
                list.Add("channelOrderId", code);                                //订单编号
                list.Add("body", goodsname);                                     //商品名称
                list.Add("totalFee", (Convert.ToInt32(price * 100)).ToString()); //金额(单位:分)
                list.Add("payType", "1400");                                     //支付类型
                list.Add("timeStamp", JMP.TOOL.WeekDateTime.GetMilis);           //时间戳
                string signstr = "appId=" + list["appId"] + "&timeStamp=" + list["timeStamp"] + "&totalFee=" + list["totalFee"] + "&key=" + userkey;
                string sign    = JMP.TOOL.MD5.md5strGet(signstr, true).ToUpper();
                list.Add("notifyUrl", ConfigurationManager.AppSettings["rmWxsmNotifyUrl"].ToString().Replace("{0}", pay_id.ToString())); //异步通知地址
                list.Add("sign", sign);                                                                                                  //签名
                string         yrl     = ConfigurationManager.AppSettings["rmWxsmPostUrl"].ToString() + "?" + JMP.TOOL.UrlStr.AzGetStrnotnull(list);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(yrl);
                request.Timeout = 3000;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                string          jmpay    = "";
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                {
                    jmpay = reader.ReadToEnd();
                }

                if (!string.IsNullOrEmpty(jmpay))
                {
                    Dictionary <string, object> jsonstr = JMP.TOOL.JsonHelper.DataRowFromJSON(jmpay);
                    if (jsonstr != null && jsonstr.Count > 0 && jsonstr.ContainsKey("payParam") && jsonstr["return_code"].ToString() == "0")
                    {
                        string exda      = ((Dictionary <string, object>)jsonstr["payParam"])["code_img_url"].ToString();
                        string imageurl  = System.Web.HttpUtility.UrlDecode(exda).Replace("https://pay.swiftpass.cn/pay/qrcode?uuid=", "");
                        string qurl      = imageurl + "," + 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
                    {
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("融梦微信扫码支付出错,获取到的回传参数:" + jmpay, summary: "融梦微信扫码支付接口错误", channelId: pay_id);
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("融梦微信扫码支付出错,获取到的回传参数:" + jmpay, summary: "融梦微信扫码支付接口错误", channelId: pay_id);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "融梦微信扫码接口错误信息", channelId: pay_id);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        /// <summary>
        /// 优乐QQwap支付接口安卓模式
        /// </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 YLAZ(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 YLAZ = "YLAZ" + appid;//组装缓存key值

                SeIn = SelectUserInfo(YLAZ, 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.qqpay.native");                                                                                  //交易类型
                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["result_code"].ToString() == "SUCCESS" && dict["return_code"].ToString() == "SUCCESS")
                {
                    string wxpay = "{\"data\":\"" + dict["code_url"].ToString() + "\",\"PaymentType\":\"8\",\"SubType\":\"4\",\"IsH5\":\"1\"}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxpay, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                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);
        }
Esempio n. 10
0
File: ZfPay.cs Progetto: dmhai/dxpay
        /// <summary>
        /// 智付支付通道H5调用方式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格</param>
        /// <param name="orderid">订单表表名</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse PayZfH5(int apptype, string code, string goodsname, decimal price, int orderid, int appid)
        {
            InnerResponse inn = new InnerResponse();
            Dictionary <string, string> DPcfg = new Dictionary <string, string>();

            try
            {
                Dictionary <string, string> list = new Dictionary <string, string>();
                list.Add("UnionPay", "UnionPay");        //特定表示
                list.Add("tid", apptype.ToString());     //风控配置表id
                list.Add("code", code);                  //订单编号
                list.Add("goodsname", goodsname);        //商品名称
                list.Add("price", price.ToString("f2")); //交易金额
                list.Add("oid", orderid.ToString());     //订单id
                DPcfg = DPConfing.loadCfg(apptype, appid);
                if (!UpdateOrde.OrdeUpdateInfo(orderid, Int32.Parse(DPcfg["pay_id"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, decimal.Parse(DPcfg["minmun"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, decimal.Parse(DPcfg["maximum"].ToString())))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                string tbtzurl = ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", orderid.ToString());
                //调用示例
                var formField = new FormField(
                    DPcfg["partner"].ToString(),                                                                          //商家账号
                    list["code"].ToString(),                                                                              //订单编号
                    list["price"].ToString(),                                                                             //交易金额
                    "direct_pay",                                                                                         //服务类型
                    "UTF-8",                                                                                              //编码格式
                    ConfigurationManager.AppSettings["ZFTokenUrl"].ToString().Replace("{0}", DPcfg["pay_id"].ToString()), //通知地址
                    "RSA-S",                                                                                              //签名方式
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),                                                         //订单时间
                    list["goodsname"].ToString(),                                                                         //商品描述
                    new FormProperty("")                                                                                  //表单属性对象
                    )
                {
                    ReturnUrl = "" + tbtzurl + ""
                };//同步通知地址
                  //商家私钥
                string merchantPrivateKey = DPcfg["dpkey"].ToString();
                //实例化HTML构造器
                var htmlCreator = new HtmlCreator(formField, new PrivateKeySignRsas(merchantPrivateKey));
                //生成表单字符串
                var    htmlForm = htmlCreator.CreateHtmlForm();
                string fromstr  = JMP.TOOL.Encrypt.IndexEncrypt(htmlForm);
                string h5key    = "h5zf" + code;
                string str      = "";
                JMP.TOOL.CacheHelper.CacheObject(h5key, htmlForm, 1);
                str           = JMP.TOOL.Encrypt.IndexEncrypt(h5key);
                str           = ConfigurationManager.AppSettings["PostUrl"].ToString() + "?UnionPay=" + str;
                inn           = inn.ToResponse(ErrorCode.Code100);
                inn.ExtraData = str;//http提交方式;
                inn.IsJump    = true;
            }
            catch (Exception ex)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.ToString(), summary: "智付银联接口错误信息", channelId: Int32.Parse(DPcfg["pay_id"].ToString()));
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 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="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse HyZfbWaPH5(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 HyWxWaPH5jkhc = "HyZfbWaPH5jkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(HyWxWaPH5jkhc, 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("user_ip", HttpContext.Current.Request.UserHostAddress.Replace('.', '_')); //ip地址
                Palist.Add("pay_type", "22");                                                         //支付类型
                Palist.Add("is_phone", "1");                                                          //支付宝wap支付传入1
                                                                                                      // Palist.Add("goods_name", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//商品名称
                string meta_option = "{\"s\":\"WAP\",\"n\":\"测试\",\"id\":\"http://www.baidu.com\"}";
                string GotoUrlName = ConfigurationManager.AppSettings["GotoUrlName"];                 //同步跳转域名
                string RetunUrl    = ConfigurationManager.AppSettings["RetunUrl"];                    //异步跳转域名
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    Palist.Add("goods_name", goodsname);//商品名称
                    Palist.Add("meta_option", meta_option.Trim());
                }
                else
                {
                    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()));//异步通知地址
                }

                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("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=22&pay_amt=" + Palist["pay_amt"] + "&notify_url=" + Palist["notify_url"] + "&return_url=" + Palist["return_url"] + "&user_ip=" + Palist["user_ip"] + "&key=" + SeIn.UserKey;
                string md5str  = JMP.TOOL.MD5.md5strGet(md5sing, true);
                Palist.Add("sign", md5str); //签名
                                            // string url = ConfigurationManager.AppSettings["HyPOSTUrl"].ToString();//请求地址
                string url  = "";           //请求地址
                string data = "";
                // string strurl = url + "?" + JMP.TOOL.UrlStr.GetStrNV(Palist);
                if (!string.IsNullOrEmpty(SeIn.RequestUrl))
                {
                    data = JMP.TOOL.UrlStr.GetStrNV(Palist) + "&url=" + ConfigurationManager.AppSettings["HyPOSTUrl"].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["HyPOSTUrl"].ToString() + "?" + data;//请求地址
                }
                inn           = inn.ToResponse(ErrorCode.Code100);
                inn.ExtraData = url;//http提交方式;
                inn.IsJump    = true;
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "汇元支付宝wap接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }

            return(inn);
        }
Esempio n. 12
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 TbWxWaPIOS(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 TbWxWaPIOSjkhc = "TbWxWaPIOSjkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(TbWxWaPIOSjkhc, 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", "http://www.baidu.com");                                                                              //页面回调地址
                list.Add("trade_type", SeIn.UserPayType);                                                                                    //交易类型

                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")
                {
                    Dictionary <string, string> diclist = new Dictionary <string, string>();

                    diclist.Add("mch_id", dict["mch_id"].ToString());
                    diclist.Add("out_trade_no", code);
                    diclist.Add("nonce_str", code);

                    //签名
                    string cxsign = JMP.TOOL.UrlStr.AzGetStr(diclist) + "&key=" + SeIn.UserKey;
                    string cxmd5  = JMP.TOOL.MD5.md5strGet(cxsign, true).ToUpper();

                    string wxpay = "{\"data\":\"" + dict["prepay_url"].ToString() + "\",\"mch_id\":\"" + dict["mch_id"].ToString() + "\",\"out_trade_no\":\"" + code + "\",\"nonce_str\":\"" + code + "\",\"sign\":\"" + cxmd5 + "\",\"PaymentType\":\"2\",\"SubType\":\"5\",\"IsH5\":\"1\"}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxpay, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    string tbwxzfxx = "途贝微信Wap支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + tbwxzfxx, 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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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 HyZfbWaPIOS(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 = "HyZfbWaPIOSjkhc" + 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", "22");                                           //支付类型
                //Palist.Add("goods_note", HttpUtility.UrlEncode(goodsname, Encoding.GetEncoding("gb2312")));//支付说明
                Palist.Add("goods_num", "1");                                           //产品数量
                                                                                        //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=22&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 + ",22";
                    string wxpay    = "{\"token_id\":\"" + token_id + "\",\"PaymentType\":\"1\",\"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);
        }
Esempio n. 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 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);
        }
Esempio n. 16
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="ip">IP地址</param>
        /// <param name="appid">应用ID</param>
        /// <param name="infoTimes">查询接口信息缓存时间</param>
        /// <returns></returns>
        private InnerResponse TbQQWapH5(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 TbQQWapH5jkhc = "TbQQWapH5jkhc" + appid;//组装缓存key值

                SeIn = SelectUserInfo(TbQQWapH5jkhc, 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.qqpay.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")
                {
                    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);
        }
Esempio n. 17
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 WxServiceSmH5(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 WxServiceSmH5 = "WxServiceSmH5" + appid;//组装缓存key值

                SeIn = SelectInfo(WxServiceSmH5, 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("sub_mch_id", SeIn.UserIdZ);                                                                                    //子商户号
                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);
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
        /// <summary>
        /// 威富通支付宝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 WftZfbH5(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.loadCfgZfb(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)
                        {
                            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: "威富通支付宝扫码接口错误信息", 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: "威富通支付宝扫码接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString()));
                        inn = inn.ToResponse(ErrorCode.Code104);
                    }
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步验证错误", summary: "威富通支付宝接口错误信息", 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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        /// <summary>
        /// 兴业银行appid 安卓调用模式
        /// </summary>
        /// <param name="appid">应用id</param>
        /// <param name="code">订单编号</param>
        /// <param name="price">支付金额</param>
        /// <param name="oid">订单id</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="apptype">风控配置表id</param>
        /// <returns></returns>
        private InnerResponse xyyhappidAz(int appid, string code, decimal price, int orderid, string goodsname, string ip, int apptype, int infoTimes)
        {
            InnerResponse inn = new InnerResponse();
            UserInf       us  = new UserInf();

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

                us = SelectInfo(xyyhappidAz, apptype, appid, infoTimes);
                if (us == null || us.pay_id <= 0 || string.IsNullOrEmpty(us.userid) || string.IsNullOrEmpty(us.userkey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (!UpdateOrde.OrdeUpdateInfo(orderid, us.pay_id))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, us.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, us.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }
                Dictionary <string, string> list = new Dictionary <string, string>();
                list.Add("version", "1.0.4");                                                                                                   //版本号
                list.Add("device_type", "ANDROID");                                                                                             //操作系统
                list.Add("appid", us.userappid);                                                                                                //应用id
                list.Add("mch_id", us.userid);                                                                                                  //商户号
                list.Add("wx_appid", us.wxappid);                                                                                               //微信appid
                                                                                                                                                //string noncestr= Guid.NewGuid().ToString().Replace("-", "");
                list.Add("nonce_str", code);                                                                                                    //随机字符串
                list.Add("body", goodsname);                                                                                                    //商品描述
                list.Add("attach", "`store_appid=" + us.store_appid + "#store_name=" + us.store_name + "#op_user="******"out_trade_no", code);                                                                                                 //订单号
                list.Add("total_fee", (Convert.ToInt32(price * 100)).ToString());                                                               //支付金额(单位:分整数类型)
                list.Add("spbill_create_ip", ip);                                                                                               //ip地址
                                                                                                                                                //list.Add("spbill_create_ip", "14.104.85.212");
                list.Add("notify_url", ConfigurationManager.AppSettings["xyyhappidNotifyUrl"].ToString().Replace("{0}", us.pay_id.ToString())); //异步通知地址
                list.Add("trade_type", "APP");                                                                                                  //交易类型
                list.Add("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                                //交易开始时间
                list.Add("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));                                                //交易失效时间
                string md5    = JMP.TOOL.UrlStr.AzGetStr(list) + "&key=" + us.userkey;
                string md5str = JMP.TOOL.MD5.md5strGet(md5, true);
                list.Add("sign", md5str);//签名
                string xml       = JMP.TOOL.xmlhelper.ToXml(list);
                string url       = ConfigurationManager.AppSettings["xyyhappidPOSTUrl"].ToString();
                string srcString = JMP.TOOL.postxmlhelper.postxml(url, xml);
                Dictionary <string, object> lisjg = JMP.TOOL.xmlhelper.FromXml(srcString);
                if (lisjg.Count > 0 && lisjg["return_code"].ToString() == "SUCCESS")
                {
                    string wxstr = "{\"PaymentType\":\"5\",\"SubType\":\"4\",\"appid\":\"" + lisjg["wx_appid"] + "\",\"partnerid\":\"" + lisjg["req_partnerid"] + "\",\"prepayid\":\"" + lisjg["prepay_id"] + "\",\"pkg\":\"Sign=WXPay\",\"noncestr\":\"" + lisjg["nonce_str"] + "\",\"timestamp\":\"" + lisjg["req_timestamp"] + "\",\"sign\":\"" + lisjg["req_sign"] + "\",\"IsH5\":\"0\"}";
                    // str = "{\"message\":\"成功\",\"result\":100,\"data\":" + wxstr + "}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxstr, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("支付接口异常,返回参数:" + srcString, summary: "兴业银行appid支付接口错误", channelId: us.pay_id);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "兴业银行appid接口错误信息", channelId: us.pay_id);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 26
0
File: WxPay.cs Progetto: dmhai/dxpay
        /// <summary>
        /// 微信支付通道安卓调用方式
        /// </summary>
        /// <param name="appid">应用id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格</param>
        /// <param name="orderid">订单id</param>
        /// <param name="apptype">风控配置表id</param>
        /// <returns></returns>
        private InnerResponse PayWxAz(int appid, string code, string goodsname, decimal price, int orderid, string ip, int apptype, int infoTimes)
        {
            InnerResponse   inn  = new InnerResponse();
            SelectInterface SeIn = new SelectInterface();

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

                SeIn = SelectUserInfo(wxappidzfjk, appid, apptype, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0)
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                if (SeIn.PayId > 0)
                {
                    WxPayConfig       wx  = new WxPayConfig(SeIn.PayId);
                    JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order();
                    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);
                    }
                    WxPayData data = new WxPayData();
                    data.SetValue("body", goodsname);                                                                                             //商品名称
                    data.SetValue("out_trade_no", code);                                                                                          //我们的订单号
                    data.SetValue("total_fee", (Convert.ToInt32(price * 100)).ToString());                                                        //价格
                    data.SetValue("notify_url", ConfigurationManager.AppSettings["WxTokenUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //回调地址
                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                    data.SetValue("trade_type", "APP");
                    WxPayData result    = WxPayApi.UnifiedOrder(data, SeIn.PayId);
                    string    noncestr  = WxPayApi.GenerateNonceStr();
                    string    timestamp = WxPayApi.GenerateTimeStamp();
                    WxPayData data1     = new WxPayData();
                    data1.SetValue("appid", wx.APPID);
                    data1.SetValue("noncestr", noncestr);
                    data1.SetValue("package", "Sign=WXPay");
                    data1.SetValue("partnerid", wx.MCHID);
                    data1.SetValue("prepayid", result.GetValue("prepay_id"));
                    data1.SetValue("timestamp", timestamp);
                    string sign  = data1.MakeSign(SeIn.PayId);
                    string wxstr = "{\"appid\":\"" + result.GetValue("appid") + "\",\"partnerid\":\"" + result.GetValue("mch_id") + "\",\"prepayid\":\"" + result.GetValue("prepay_id") + "\",\"pkg\":\"Sign=WXPay\",\"noncestr\":\"" + noncestr + "\",\"timestamp\":\"" + timestamp + "\",\"sign\":\"" + sign + "\",\"PaymentType\":\"5\",\"SubType\":\"1\",\"IsH5\":\"0\"}";
                    // str = "{\"message\":\"成功\",\"result\":100,\"data\":" + wxstr + "}";
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxstr, ConfigurationManager.AppSettings["encryption"].ToString());
                }
                else
                {
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:支付通道异常", summary: "微信appid支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception E)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "微信appid支付接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }
            return(inn);
        }
Esempio n. 27
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);
        }