/// <summary> /// 根据支付类型获取支付通道 /// </summary> /// <param name="payType"></param> /// <returns></returns> public PayTypeAbstract Create(int payType) { PayTypeAbstract payTypeInstance; switch (payType) { case 1: //支付宝 payTypeInstance = new PayTypeForAliPay(); break; case 2: //微信 payTypeInstance = new PayWxWap(); break; case 3: //银联 payTypeInstance = new UnionPay(); break; case 4: //微信公众号 payTypeInstance = new PayWxGzh(); break; case 5: //微信appid payTypeInstance = new PayWxApp(); break; case 6: //微信扫码 payTypeInstance = new PayWxSm(); break; case 7: //支付宝扫码 payTypeInstance = new PayAlPaySm(); break; case 8: //QQ钱包wap payTypeInstance = new PayQQWap(); break; default: throw new Exc { Response = new InnerResponse { ErrorCode = ErrorCode.Code107.GetValue(), Message = ErrorCode.Code107.GetDescription() } }; //break; } return(payTypeInstance); }
/// <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); } }