/// <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); }
/// <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); }
/// <summary> /// 获取公众号转微信wap账号信息 /// </summary> /// <param name="cache">缓存key</param> /// <param name="apptype">风控配置表id</param> /// <param name="appid">应用id</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str;//获取key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); } else { dt = bll.SelectPay("GZHZWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str; //获取公众号转微信wap支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "公众号转微信wap支付支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("GZHZWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str; //获取公众号转微信wap支付key JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据库未查询到相关信息!", summary: "公众号转微信wap支付支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "公众号转微信wap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId); } return(SeIn); }
/// <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); }
/// <summary> /// 根据应用id查询对应的支付通道 /// </summary> /// <param name="cache">缓存名称</param> /// <param name="appid">应用id</param> /// <param name="apptype">风控配置表id</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int appid, int apptype, int infoTimes) { SelectInterface SeIn = new SelectInterface(); DataTable dt = new DataTable(); JMP.BLL.jmp_interface blls = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = blls.SelectPay("WX", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "微信支付接口错误", channelId: SeIn.PayId); } } } else { dt = blls.SelectPay("WX", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据未查询到相关信息!", summary: "微信支付接口错误", channelId: SeIn.PayId); } } return(SeIn); }
/// <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"] + "¬ify_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); }
/// <summary> /// 微信公众号第一次跳转 /// </summary> /// <param name="Oid">订单id</param> private void OnJump(int Oid) { try { string str = ""; JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + Oid + ") ").Tables[0]); if (mo != null) { SelectInterface SeIn = new SelectInterface(); string cache = "wxgfgzh" + Oid; SeIn = SelectInfo(cache, mo.a_rid, mo.a_id, int.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString())); if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey)) { str = "{\"Message\":\"支付通道未配置\",\"ErrorCode\":106}"; Response.Write(str); } JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = bll.SelectOrderGoodsName(Oid, "jmp_order"); if (morder.o_price < SeIn.minmun) { str = "{\"Message\":\"订单金额不能小于单笔最小支付金额\",\"ErrorCode\":8990}"; Response.Write(str); } if (morder.o_price > SeIn.maximum) { str = "{\"Message\":\"订单金额不能大于单笔最大支付金额\",\"ErrorCode\":8989}"; Response.Write(str); } if (bll.UpdatePay(Oid, SeIn.PayId)) { string redirect_uri = ConfigurationManager.AppSettings["WxGzhRturnUrl"].ToString() + Oid + ".html"; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + "回调地址:" + redirect_uri, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + SeIn.wxappid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_base#wechat_redirect"; Response.Redirect(url, false); } } else { str = "{\"Message\":\"支付接口异常\",\"ErrorCode\":102}"; Response.Write(str); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); Response.Write("非法访问!"); } }
/// <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); }
/// <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"] + "¬ify_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); }
/// <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"] + "¬ify_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); }
/// <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); }
/// <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); }
/// <summary> /// 查询微信官方扫码支付账户信息 /// </summary> /// <param name="cache">缓存值</param> /// <param name="appid">应用id</param> /// <param name="apptype">风控配置表id</param> /// <returns></returns> private SelectInterface SelectInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取微信商户号 SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid SeIn.UserIdZ = paypz[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.UserKey = paypz[3].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); //获取支付通道id SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = bll.SelectPay("WXService", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取微信商户号 SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid SeIn.UserIdZ = paypz[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.UserKey = paypz[3].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); //获取支付通道id SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "微信官方扫码支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("WXService", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取微信商户号 SeIn.wxappid = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid SeIn.UserIdZ = paypz[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.UserKey = paypz[3].Replace("\r", "").Replace("\n", "").Trim(); //获取微信秘钥 SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); //获取支付通道id SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",直接从数据库未查询到相关信息!", summary: "微信官方扫码支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString(); //报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "微信官方扫码支付接口错误应用ID:" + appid, channelId: SeIn.PayId); //写入报错日志 } return(SeIn); }
/// <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"] + "¬ify_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); }
/// <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"] + "¬ify_url=" + Palist["notify_url"] + "&return_url=" + Palist["return_url"] + "&user_ip=" + Palist["user_ip"] + "&key=" + SeIn.UserKey + "×tamp=" + 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); }
/// <summary> /// 获取汇元网账号信息 /// </summary> /// <param name="cache">缓存key</param> /// <param name="apptype">风控配置表id</param> /// <param name="appid">应用id</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的汇元QQwap支付账号 SeIn.UserKey = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的汇元QQwap支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.GotoURL = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.ReturnUrl = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null; } else { dt = bll.SelectPay("HYQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元QQwap支付账号 SeIn.UserKey = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元QQwap支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.GotoURL = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.ReturnUrl = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null; JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes);//存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "汇元QQwap支付支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("HYQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] paypz = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = paypz[0].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元QQwap支付账号 SeIn.UserKey = paypz[1].Replace("\r", "").Replace("\n", "").Trim(); //获取汇元QQwap支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 SeIn.RequestUrl = paypz.Length > 2 ? paypz[2].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.GotoURL = paypz.Length > 3 ? paypz[3].Replace("\r", "").Replace("\n", "").Trim() : null; SeIn.ReturnUrl = paypz.Length > 4 ? paypz[4].Replace("\r", "").Replace("\n", "").Trim() : null; JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes);//存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据库未查询到相关信息!", summary: "汇元QQwap支付支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "汇元QQwap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId); } return(SeIn); }
/// <summary> /// 公众号转微信wap支付接口H5模式 /// </summary> /// <param name="apptype">风控配置表id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">支付金额</param> /// <param name="orderid">订单id</param> /// <param name="ip">ip地址</param> /// <param name="appid">应用id</param> /// <returns></returns> private InnerResponse gzhwaph5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes, int paymode) { InnerResponse respon = new InnerResponse(); InnerResponse inn = new InnerResponse(); SelectInterface SeIn = new SelectInterface(); try { //查询应用是否开通微信公众号支付 var payType = new PayWxGzh(); var payc = payType.LoadChannel(paymode, apptype, infoTimes, appid); if (string.IsNullOrEmpty(payc.PassName)) { inn = inn.ToResponse(ErrorCode.Code106); return(inn); } System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection(); string hckey = "wxgzhzwap" + appid; SeIn = SelectUserInfo(hckey, apptype, appid, infoTimes); JmPayParameter.JsonStr jsonStr = new JsonStr(); PayBankModels modes = jsonStr.ParameterEntity(code, goodsname, price, "4", apptype, paymode); //h5模式 respon = jsonStr.H5JsonStr(modes, ip); if (respon.ErrorCode == 100) { Palist.Add("key", SeIn.UserKey); //key Palist.Add("f", "json"); //API返回的格式支持json和js Palist.Add("url", respon.ExtraData.ToString()); //要跳转的链接,先要经过urlencode编码 Palist.Add("b", "other"); //浏览器 默认other 表示其他浏览器, baidu则表示手机百度,androd_chrome表示android chrome浏览器 string urlstr = ConfigurationManager.AppSettings["gzhzwapUrl"].ToString(); //公众号转wap请求地址 WebClient webClient = new WebClient(); byte[] responseData = webClient.UploadValues(urlstr, "POST", Palist); //得到返回字符流 string srcString = Encoding.UTF8.GetString(responseData); //解码 Dictionary <string, object> dic = new Dictionary <string, object>(); dic = JMP.TOOL.JsonHelper.DataRowFromJSON(srcString); if (dic["status"].ToString() == "ok") { inn = inn.ToResponse(ErrorCode.Code100); string ticket_url = dic["ticket_url"].ToString(); if (paymode == 3) { inn.ExtraData = ticket_url; inn.IsJump = true; } else { string json = "{\"data\":\"" + ticket_url + "\",\"PaymentType\":\"2\",\"SubType\":\"6\",\"IsH5\":\"1\"}"; inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(json, ConfigurationManager.AppSettings["encryption"].ToString()); } } else { inn = inn.ToResponse(ErrorCode.Code104); //转换微信链接失败 PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + srcString, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId); } return(inn); } else { return(respon); } } catch (Exception ex) { inn = inn.ToResponse(ErrorCode.Code104); //转换微信链接失败 PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId); return(inn); } }
/// <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); }
/// <summary> /// 获取支付账号信息 /// </summary> /// <param name="cache">缓存Key</param> /// <param name="apptype">风控配置表ID</param> /// <param name="appid">应用Id</param> /// <param name="infoTimes">查询接口信息缓存时间</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = bll.SelectPay("TBQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存未成功后在次查询数据!", summary: "途贝QQwap支付支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("TBQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",在数据库为查询到数据", summary: "途贝QQwap支付支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "途贝QQwap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId); } return(SeIn); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }