/// <summary> /// 智付支付通道苹果调用方式 /// </summary> /// <param name="apptype">风控配置表id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">商品价格</param> /// <param name="TableName">订单表表名</param> /// <param name="appid">应用id</param> /// <returns></returns> private InnerResponse PayZfIos(int apptype, string code, string goodsname, decimal price, int orderid, int appid) { InnerResponse inn = new InnerResponse(); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); Dictionary <string, string> DPcfg = DPConfing.loadCfg(apptype, appid); if (!UpdateOrde.OrdeUpdateInfo(orderid, Int32.Parse(DPcfg["pay_id"].ToString()))) { inn = inn.ToResponse(ErrorCode.Code101); return(inn); } //调用示例 var formField = new FormField( DPcfg["partner"].ToString(), //商家账号 code, //订单编号 price.ToString("f2"), //交易金额 ConfigurationManager.AppSettings["ZFTokenUrl"].ToString().Replace("{0}", DPcfg["pay_id"].ToString()), //通知地址 "RSA-S", //签名方式 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), //订单时间 goodsname, //商品描述 new FormProperty("") //表单属性对象 ); //商家私钥 string merchantPrivateKey = DPcfg["dpkey"].ToString(); //实例化HTML构造器 var htmlCreator = new HtmlCreator(formField, new PrivateKeySignRsas(merchantPrivateKey)); //生成表单字符串 var htmlForm = htmlCreator.CreateHtmlAz(); inn = inn.ToResponse(ErrorCode.Code100); string data = "{" + htmlForm.ToString().Replace("{", "").Replace("}", "") + ",\"PaymentType\":\"3\",\"SubType\":\"1\",\"IsH5\":\"0\"}"; inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(data, ConfigurationManager.AppSettings["encryption"].ToString()); 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="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> /// 途贝QQ钱包wap支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓 2:IOS 3:H5)</param> /// <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="infoTimes">查询接口信息缓存时间</param> /// <param name="appid">应用ID</param> /// <returns></returns> public InnerResponse TbQQPayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int appid) { InnerResponse inn = new InnerResponse(); switch (paymode) { case 1: //安卓 inn = TbQQWapAz(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 2: //ios inn = TbQQWapIOS(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 3: //h5 inn = TbQQWapH5(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; default: inn = inn.ToResponse(ErrorCode.Code9987); break; } return(inn); }
/// <summary> /// 途贝微信wap支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <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> public InnerResponse TbWxPayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int appid) { InnerResponse inn = new InnerResponse(); switch (paymode) { case 1: //安卓方式 inn = TbWxWaPAz(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 2: //ios方式 inn = TbWxWaPIOS(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 3: //H5支付方式 inn = TbWxWaPH5(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; default: //throw new Exc { Response = new InnerResponse { ErrorCode = ErrorCode.Code9987.GetValue() } }; inn = inn.ToResponse(ErrorCode.Code9987); break; } return(inn); }
/// <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); }
/// <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> /// 浦发银行微信公众号支付H5调用模式 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <param name="orderid">订单id</param> /// <returns></returns> private InnerResponse PfWxGzhH5(int orderid) { InnerResponse inn = new InnerResponse(); inn = inn.ToResponse(ErrorCode.Code100); inn.ExtraData = ConfigurationManager.AppSettings["wftwxgzhget"].ToString() + "/PfWxGzh" + orderid + ".html"; inn.IsJump = true; 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="infoTime">缓存时间</param> /// <param name="appid">应用id</param> /// <param name="ip">ip地址</param> /// <returns></returns> private InnerResponse WxGzhH5(int apptype, string code, decimal price, int orderid, string goodsname, int infoTime, int appid, string ip) { InnerResponse inn = new InnerResponse(); inn = inn.ToResponse(ErrorCode.Code100); //inn.ExtraData = ConfigurationManager.AppSettings["wftwxgzhget"].ToString() + "/WeChatNumber" + orderid + ".html"; inn.ExtraData = ConfigurationManager.AppSettings["wftwxgzhget"].ToString() + "/WeChatNumber.aspx?pid=" + orderid; inn.IsJump = true; return(inn); }
/// <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); }
/// <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> /// 微唯微信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> /// 微信扫码主通道 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <param name="apptype">应用类型子id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">价格</param> /// <param name="orderid">订单id</param> /// <param name="infoTime">缓存时间</param> /// <param name="appid">应用id</param> /// <param name="ip">ip地址</param> /// <returns></returns> public InnerResponse WxServiceSmPayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, int infoTime, int appid, string ip) { InnerResponse inn = new InnerResponse(); if (paymode == 3) { inn = WxServiceSmH5(apptype, code, price, orderid, goodsname, infoTime, appid, ip); } else { inn = inn.ToResponse(ErrorCode.Code9987); } return(inn); }
/// <summary> /// 途贝微信公众号支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <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> public InnerResponse TbWxGzhPayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int appid) { InnerResponse inn = new InnerResponse(); if (paymode == 3) { inn = TbWxGzhPayH5(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); } else { inn = inn.ToResponse(ErrorCode.Code9987); } return(inn); }
/// <summary> /// 公众号转微信wap支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <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> public InnerResponse LmsjWxPayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int appid) { InnerResponse inn = new InnerResponse(); if (paymode >= 1 && paymode <= 3) { inn = gzhwaph5(apptype, code, goodsname, price, orderid, ip, appid, infoTimes, paymode); } else { inn = inn.ToResponse(ErrorCode.Code9987); } return(inn); }
/// <summary> /// 浦发银行微信公众号支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <param name="orderid">订单id</param> /// <returns></returns> public InnerResponse PfWxGzhPayInfo(int paymode, int orderid) { InnerResponse inn = new InnerResponse(); if (paymode == 3) { inn = PfWxGzhH5(orderid); } else { inn = inn.ToResponse(ErrorCode.Code9987); } return(inn); }
/// <summary> /// 微信appid支付通道主入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <param name="appid">应用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="apptype">风控配置表id</param> /// <returns></returns> public InnerResponse MyWxPayInfo(int paymode, int appid, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int apptype) { InnerResponse inn = new InnerResponse(); switch (paymode) { case 1: //安卓方式 inn = PayWxAz(appid, code, goodsname, price, orderid, ip, apptype, infoTimes); break; case 2: //ios方式 inn = PayWxIos(appid, code, goodsname, price, orderid, ip, apptype, infoTimes); break; default: inn = inn.ToResponse(ErrorCode.Code9987); break; } return(inn); }
/// <summary> /// 支付宝官方扫码封装wap支付通道入口 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <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> public InnerResponse IAlPaySmPackingInfo(int paymode, int apptype, string code, string goodsname, decimal price, int orderid, string ip, int infoTimes, int appid) { InnerResponse inn = new InnerResponse(); switch (paymode) { case 1: //安卓方式 inn = IAlPaySmPackingAZ(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 2: //ios方式 inn = IAlPaySmPackingIos(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; case 3: //H5方式 inn = IAlPaySmPackingH5(apptype, code, goodsname, price, orderid, ip, appid, infoTimes); break; default: inn = inn.ToResponse(ErrorCode.Code9987); break; } return(inn); }
/// <summary> /// 支付宝接口主通道 /// </summary> /// <param name="paymode">平台类型(1:安卓,2:ios,3:H5)</param> /// <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> /// <param name="appid">应用id</param> /// <returns></returns> public InnerResponse AlpayInfo(int paymode, int apptype, string code, string goodsname, decimal price, int oderid, string ip, int appid) { InnerResponse inn = new InnerResponse(); switch (paymode) { case 1: //安卓方式 inn = PayZfbAz(apptype, code, goodsname, price, oderid, ip, appid); break; case 2: //ios方式 inn = PayZfbIos(apptype, code, goodsname, price, oderid, ip, appid); break; case 3: //H5支付方式 inn = PayZfbH5(apptype, code, goodsname, price, oderid, ip, appid); break; default: inn = inn.ToResponse(ErrorCode.Code9987); break; } return(inn); }
/// <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); }
/// <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支付苹果调用模式 /// </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> /// 兴业银行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); }
/// <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); }
/// <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); }
/// <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> /// 威富通支付通道安卓调用方式 /// </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); }
/// <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> /// 优乐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); }