/// <summary> ///添加到终端属性表 /// </summary> /// <param name="model"></param> /// <returns></returns> private InnerResponse InsertNew(jmp_terminal model) { InnerResponse Inn = new InnerResponse(); try { model.t_time = DateTime.Now; int cg = 0; JMP.BLL.jmp_terminal zdbll = new JMP.BLL.jmp_terminal();//终端属性业务逻辑层 cg = zdbll.Add(model); if (cg > 0) { Inn = Inn.InfoToResponse(InfoErrorCode.Code100); } else { Inn = Inn.InfoToResponse(InfoErrorCode.Code101); } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 //AddLocLog.AddLog(1, 4, "", "接口错误信息", "添加到终端属性表,报错信息:" + bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log("添加到终端属性表,报错信息:" + bcxx, summary: "接口错误信息"); Inn = Inn.InfoToResponse(InfoErrorCode.Code101); } return(Inn); }
/// <summary> /// 根据商户订单号和appid查询订单信息 /// </summary> /// <param name="mod">参数实体</param> /// <param name="json">参数json字符串</param> /// <returns></returns> private jmp_order SelectOrder(QueryModels mod, string json) { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); try { mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, "jmp_order"); if (mode == null) { string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName); //查询本周归档表 string weekstr = DateTime.Now.DayOfWeek.ToString(); if (mode == null && weekstr == "Monday" && Int32.Parse(DateTime.Now.ToString("HH")) <= 2) { string TableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName); //查询上周归档表 } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 PayApiGlobalErrorLogger.Log("报错信息:查询接口查询订单报错,获取到的参数:" + json + ",报错信息:" + bcxx, summary: "接口错误信息"); return(null); } return(mode); }
/// <summary> /// 添加到活跃表 /// </summary> /// <param name="model"></param> /// <returns></returns> private InnerResponse Insertliveteral(jmp_terminal model) { InnerResponse Inn = new InnerResponse(); try { JMP.MDL.jmp_liveteral mo = new JMP.MDL.jmp_liveteral(); //活跃实体类型 JMP.BLL.jmp_liveteral hybll = new JMP.BLL.jmp_liveteral(); //活跃业务逻辑层 mo.l_teral_key = model.t_key; mo.l_time = DateTime.Now; mo.l_appid = model.t_appid; int cg = 0; cg = hybll.Add(mo); if (cg > 0) { Inn = Inn.InfoToResponse(InfoErrorCode.Code100); } else { Inn = Inn.InfoToResponse(InfoErrorCode.Code101); } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 //AddLocLog.AddLog(1, 4, "", "接口错误信息", "添加到活跃表,报错信息:" + bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log("添加到活跃表,报错信息:" + bcxx, summary: "接口错误信息"); Inn = Inn.InfoToResponse(InfoErrorCode.Code101); } return(Inn); }
/// <summary> /// from表单提交跳转界面 /// </summary> /// <returns></returns> public ActionResult UnionPay() { string UnionPay = string.IsNullOrEmpty(Request["UnionPay"]) ? "" : Request["UnionPay"]; if (!string.IsNullOrEmpty(UnionPay)) { string str = ""; string encryption = HttpUtility.UrlDecode(Request.Params["UnionPay"].ToString()); string h5key = JMP.TOOL.Encrypt.IndexDecrypt(encryption);//解密缓存key if (JMP.TOOL.CacheHelper.IsCache(h5key)) { str = JMP.TOOL.CacheHelper.GetCaChe(h5key).ToString(); if (!string.IsNullOrEmpty(str)) { Response.Write(str); } else { PayApiGlobalErrorLogger.Log("from表单提交报错,根据缓存值未获取到相关信息!获取到的缓存值:" + UnionPay, summary: "from表单提交报错"); Response.Write("{\"Message\":\"订单超时\",\"ErrorCode\":9984}"); } } else { PayApiGlobalErrorLogger.Log("from表单提交报错,根据获取到的值解密失败!获取到的缓存值:" + UnionPay, summary: "from表单提交报错"); Response.Write("{\"Message\":\"订单超时\",\"ErrorCode\":9984}"); } } else { Response.Redirect("/H5/Error"); } return(View()); }
public IHttpActionResult Qusery(JmPayParameter.Models.QueryModels mode) { Response json = new Response(); try { Dictionary <string, string> dict = new Dictionary <string, string>(); string pamentjson = ""; //获取下单请求的参数 if (Request.Method == HttpMethod.Get) { dict = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.CurrentCultureIgnoreCase); if (dict.Count > 0) { pamentjson = JMP.TOOL.JsonHelper.DictJsonstr(dict); mode = JMP.TOOL.JsonHelper.Deserialize <QueryModels>(pamentjson); } } else if (Request.Method == HttpMethod.Post) { pamentjson = JMP.TOOL.JsonHelper.Serialize(mode); } if (mode != null) { //获取配置文件设置的缓存时间 int CacheTime = Int32.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString()); JmPayParameter.Query query = new Query(); var message = query.SelectQuery(mode, pamentjson, CacheTime); if (message.Success) { QuerySuccessResponse qu = new QuerySuccessResponse(); qu.ErrorCode = message.ErrorCode; qu.Message = message.Message; qu.trade_code = message.trade_code; qu.trade_no = message.trade_no; qu.trade_price = message.trade_price; qu.o_state = message.o_state; qu.trade_time = message.trade_time; return(Ok(qu)); } else { json = json.QueryToResponse(QueryErrorCode.Code101); } } else { json = json.QueryToResponse(QueryErrorCode.Code9999); } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace;//报错信息 PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "查询接口通道入口报错"); json = json.QueryToResponse(QueryErrorCode.Code101); } return(Ok(json)); }
/// <summary> /// 验证参数是否合法 /// </summary> /// <param name="mode">参数实体</param> /// <param name="json">获取到的json字符串</param> /// <returns></returns> private InnerResponse VerificationParameter(JmPayParameter.Models.Initialization mode, string json) { InnerResponse Inn = new InnerResponse(); try { if (string.IsNullOrEmpty(mode.t_key) || mode.t_key.Length > 64) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9997)); } if (string.IsNullOrEmpty(mode.t_mark) || mode.t_mark.Length > 32) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9995)); } if (string.IsNullOrEmpty(mode.t_imsi) || mode.t_imsi.Length > 32) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9994)); } if (string.IsNullOrEmpty(mode.t_brand) || mode.t_brand.Length > 32) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9993)); } if (string.IsNullOrEmpty(mode.t_system) || mode.t_system.Length > 32) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9992)); } if (string.IsNullOrEmpty(mode.t_hardware) || mode.t_hardware.Length > 32) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9991)); } if (string.IsNullOrEmpty(mode.t_sdkver) || mode.t_sdkver.Length > 16) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9990)); } if (string.IsNullOrEmpty(mode.t_screen) || mode.t_screen.Length > 16) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9989)); } if (string.IsNullOrEmpty(mode.t_network) || mode.t_network.Length > 16) { return(Inn = Inn.InfoToResponse(InfoErrorCode.Code9988)); } Inn = Inn.InfoToResponse(InfoErrorCode.Code100); } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 //AddLocLog.AddLog(1, 4, "", "接口错误信息", "报错信息:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log("报错信息:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + bcxx, summary: "接口错误信息"); Inn = Inn.InfoToResponse(InfoErrorCode.Code9998); } return(Inn); }
public WxPayConfig(int tid) { #region 获取微信口信息 try { DataTable dt = new DataTable(); var zf = new JMP.BLL.jmp_interface(); string wxzfjk = "wxzfjk" + tid;//组装缓存key值 if (JMP.TOOL.CacheHelper.IsCache(wxzfjk)) { string cache = JMP.TOOL.CacheHelper.GetCaChe(wxzfjk).ToString(); if (!String.IsNullOrEmpty(cache)) { string[] str = cache.Split(','); MCHID = str[0]; //获取微信账号 KEY = str[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信私钥 APPID = str[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid APPSECRET = cache.Split(',').Length > 3 ? str[3].Replace("\r", "").Replace("\n", "").Trim() : null; //获取微信appkey } else { //AddLocLog.AddLog(1, 4, "", "微信支付接口错误", "应用类型id为:" + tid + "的支付通道为空!");//写入报错日志 PayApiGlobalErrorLogger.Log("应用类型id为:" + tid + "的支付通道为空!", summary: "微信支付接口错误"); } } else { string strs = zf.strzf_monitor(tid); if (!String.IsNullOrEmpty(strs)) { string[] str = strs.Split(','); MCHID = str[0]; //获取微信账号 KEY = str[1].Replace("\r", "").Replace("\n", "").Trim(); //获取微信私钥 APPID = str[2].Replace("\r", "").Replace("\n", "").Trim(); //获取微信appid APPSECRET = strs.Split(',').Length > 3 ? str[3].Replace("\r", "").Replace("\n", "").Trim() : null; //获取微信appkey JMP.TOOL.CacheHelper.CacheObject(wxzfjk, strs, 1); //存入缓存 } else { //AddLocLog.AddLog(1, 4, "", "微信支付接口错误", "应用类型id为:" + tid + "的支付通道为空!");//写入报错日志 PayApiGlobalErrorLogger.Log("应用类型id为:" + tid + "的支付通道为空!", summary: "微信支付接口错误"); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 //AddLocLog.AddLog(1, 4, "", "微信支付接口错误", bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log(bcxx, summary: "微信支付接口错误"); } #endregion }
/// <summary> /// 验证数据是否合法 /// </summary> /// <param name="dict">请求参数键值集合</param> /// <param name="json">参数json字符串</param> /// <param name="bizcodeTime">缓存时间从配置文件中读取的</param> /// <param name="app">应用实体</param> /// <returns></returns> private InnerResponse ValidationParameter(RequestParameter mode, string json, int bizcodeTime) { InnerResponse Inn = new InnerResponse(); try { if (string.IsNullOrEmpty(mode.timestamp) || mode.timestamp.Length != 10) { return(Inn = Inn.ToResponse(ErrorCode.Code9985)); } if (!VerificationTimestamp(mode.timestamp, bizcodeTime)) { return(Inn = Inn.ToResponse(ErrorCode.Code9984)); } if (string.IsNullOrEmpty(mode.bizcode) && mode.bizcode.Length > 64) { return(Inn = Inn.ToResponse(ErrorCode.Code9997)); } if (mode.appid <= 0) { return(Inn = Inn.ToResponse(ErrorCode.Code9998)); } if (VerificationCode(mode.bizcode, mode.appid)) { return(Inn = Inn.ToResponse(ErrorCode.Code9988)); } if (string.IsNullOrEmpty(mode.goodsname) || mode.goodsname.Length > 16) { return(Inn = Inn.ToResponse(ErrorCode.Code9993)); } if (mode.price <= 0) { return(Inn = Inn.ToResponse(ErrorCode.Code9992)); } if (!string.IsNullOrEmpty(mode.privateinfo) && mode.privateinfo.Length > 64) { return(Inn = Inn.ToResponse(ErrorCode.Code9991)); } if (!JMP.TOOL.Regular.IsDem(mode.price.ToString())) { return(Inn = Inn.ToResponse(ErrorCode.Code9986)); } Inn = Inn.ToResponse(ErrorCode.Code100); } catch (Exception e) { PayApiGlobalErrorLogger.Log("报错信息103:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + e.ToString(), summary: "接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code103); } return(Inn); }
/// <summary> /// 根据id修改支付通道(非appid方式) /// </summary> /// <param name="oid">订单id</param> /// <param name="payid">支付通道id</param> /// <returns></returns> public bool OrdeUpdateInfo(int oid, int payid, string code) { bool isSuccess = false; JMP.BLL.jmp_order blls = new JMP.BLL.jmp_order(); if (!blls.UpdatePay(oid, payid)) { PayApiGlobalErrorLogger.Log("修改支付渠道失败!订单id:" + oid + ",通道id:" + payid + ",订单编号:" + code, summary: "修改支付通道报错"); } else { isSuccess = true; } return(isSuccess); }
public override void OnException(HttpActionExecutedContext actionExecutedContext) { var exception = actionExecutedContext.Exception as ApiException; if (exception != null) { actionExecutedContext.Response = actionExecutedContext.Request.CreateErrorResponse( exception.StatusCode, exception.Message); } else { //actionExecutedContext.Response =actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.InternalServerError,new HttpError(actionExecutedContext.Exception.Message)); PayApiGlobalErrorLogger.Log(actionExecutedContext.Exception.ToString(), "接口服务错误"); } }
/// <summary> /// 根据id修改支付通道(非appid方式) /// </summary> /// <param name="oid">订单id</param> /// <param name="payid">支付通道id</param> /// <returns></returns> public static bool OrdeUpdateInfo(int oid, int payid) { bool isSuccess = false; JMP.BLL.jmp_order blls = new JMP.BLL.jmp_order(); if (!blls.UpdatePay(oid, payid)) { //AddLocLog.AddLog(1, 4, "", "修改支付通道报错", "修改支付渠道失败!订单id:" + oid.ToString() + ",通道id:" + payid);//写入报错日志 PayApiGlobalErrorLogger.Log("修改支付渠道失败!订单id:" + oid + ",通道id:" + payid, summary: "修改支付通道报错"); } else { isSuccess = true; } return(isSuccess); }
public int pay_id = 0;//支付渠道id #endregion /// <summary> /// 构造函数 /// </summary> /// <param name="interfaceId">通道ID</param> public ConfigMonitor(int interfaceId) { #region 获取支付宝接口信息 var zfbjkhc = "ZFBjkhc_monitor_" + interfaceId;//组装缓存key值 try { if (CacheHelper.IsCache(zfbjkhc)) { var zfbpz = CacheHelper.GetCaChe(zfbjkhc).ToString(); if (!string.IsNullOrEmpty(zfbpz)) { var payzf = zfbpz.Split(','); private_key = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的支付宝私钥 partner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的支付宝账号 } } else { var zf = new JMP.BLL.jmp_interface(); var str = zf.strzf_monitor(interfaceId); if (!string.IsNullOrEmpty(str)) { var payzf = str.Split(','); partner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝账号 private_key = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝私钥 CacheHelper.CacheObject(zfbjkhc, str, 1); //存入缓存 } } } catch (Exception e) { var bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 //AddLocLog.AddLog(1, 4, "", "支付宝支付接口错误通道ID:" + interfaceId, bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log(bcxx, summary: "支付宝支付接口错误通道ID:" + interfaceId); throw; } #endregion seller_id = partner; //public_key = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB"; public_key = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB"; input_charset = "utf-8"; sign_type = "RSA"; }
public Response Info(JmPayParameter.Models.Initialization mode) { Response json = new Response(); string ip = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress; try { #region 获取传入的参数 Dictionary <string, string> dict = new Dictionary <string, string>(); string pamentjson = ""; if (Request.Method == HttpMethod.Get) { dict = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.CurrentCultureIgnoreCase); if (dict.Count > 0) { pamentjson = JMP.TOOL.JsonHelper.DictJsonstr(dict); mode = JMP.TOOL.JsonHelper.Deserialize <Initialization>(pamentjson); } } else if (Request.Method == HttpMethod.Post) { pamentjson = JMP.TOOL.JsonHelper.Serialize(mode); } #endregion if (mode != null) { //获取配置文件设置的缓存时间 int CacheTime = Int32.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString()); InfoInterface infoInterface = new InfoInterface(); var message = infoInterface.InfoPass(mode, pamentjson, CacheTime, ip); json.ErrorCode = message.ErrorCode; json.Message = message.Message; } else { json = json.InfoToResponse(InfoErrorCode.Code9999); } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace;//报错信息 PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "初始化接口主通道Info报错"); json = json.InfoToResponse(InfoErrorCode.Code9998); } return(json); }
/// <summary> /// sdk收银台模式返回数据组装 /// </summary> /// <param name="mode">参数实体</param> /// <param name="ip">ip地址</param> /// <returns></returns> public InnerResponse BankSdk(PayBankModels mode, string ip) { InnerResponse Inn = new InnerResponse(); try { string json = JMP.TOOL.JsonHelper.Serialize(mode); Inn = Inn.ToResponse(ErrorCode.Code100); Inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(json, ConfigurationManager.AppSettings["encryption"].ToString()); } catch (Exception e) { //string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 //JMP.TOOL.AddLocLog.AddLog(1, 4, ip, "收银台sdk模式返回加密地址接口错误信息", "报错信息:" + bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log("报错信息103:" + e.ToString(), summary: "收银台sdk模式返回加密地址接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code103); } return(Inn); }
/// <summary> /// 添加订单入库 /// </summary> /// <param name="mode">传入参数实体</param> /// <param name="json">传入参数json字符串</param> /// <returns></returns> private InnerResponse DownOrder(RequestParameter mode, string json) { InnerResponse Inn = new InnerResponse(); JMP.MDL.jmp_order mod = new JMP.MDL.jmp_order(); //订单表实体类 JMP.BLL.jmp_order jmp_orderbll = new JMP.BLL.jmp_order(); //订单表业务逻辑层 mod.o_address = mode.address; mod.o_showaddress = mode.showaddress; mod.o_app_id = mode.appid; mod.o_bizcode = mode.bizcode; mod.o_term_key = mode.termkey; mod.o_paymode_id = mode.paytype.ToString(); mod.o_goodsname = mode.goodsname; mod.o_price = mode.price; mod.o_privateinfo = mode.privateinfo; Random r = new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0)); mod.o_code = DateTime.Now.ToString("yyyyMMddHHmmssfff") + r.Next(111111111, 999999999).ToString() + r.Next(1111, 9999).ToString(); mod.o_state = 0; mod.o_times = 0; mod.o_noticestate = 0; mod.o_ctime = DateTime.Now; mod.o_noticetimes = DateTime.Now; mod.o_ptime = DateTime.Now; int cg = 0; cg = jmp_orderbll.AddOrder(mod); if (cg > 0) { pr.orderid = cg; pr.code = mod.o_code; pr.goodsname = mode.goodsname; pr.price = mode.price; Inn = Inn.ToResponse(ErrorCode.Code100); } else { PayApiGlobalErrorLogger.Log("报错信息:支付信息生成订单失败,获取到的参数:" + json, summary: "接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code101); } return(Inn); }
/// <summary> /// 查询接口参数验证方法 /// </summary> /// <param name="mode">参数实体</param> /// <param name="json">参数json字符串</param> /// <returns></returns> private QueryRespon parameter(QueryModels mode, string json, int CacheTime) { QueryRespon qu = new QueryRespon(); try { //订单缓存时间 int bizcodeTime = Int32.Parse(ConfigurationManager.AppSettings["bizcodeTime"]); if (!string.IsNullOrEmpty(mode.bizcode) && mode.bizcode.Length > 64) { return(qu = qu.QueryResp(QueryErrorCode.Code9998)); } if (!string.IsNullOrEmpty(mode.code) && mode.code.Length > 32) { return(qu = qu.QueryResp(QueryErrorCode.Code9997)); } if (string.IsNullOrEmpty(mode.timestamp) || mode.timestamp.Length != 10) { return(qu = qu.QueryResp(QueryErrorCode.Code9996)); } PreOrder preOrder = new PreOrder(); if (!preOrder.VerificationTimestamp(mode.timestamp, bizcodeTime)) { return(qu = qu.QueryResp(QueryErrorCode.Code9995)); } if (string.IsNullOrEmpty(mode.code) && string.IsNullOrEmpty(mode.bizcode)) { return(qu = qu.QueryResp(QueryErrorCode.Code9991)); } qu = qu.QueryResp(QueryErrorCode.Code100); } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 PayApiGlobalErrorLogger.Log("报错信息:查询接口验证参数错误,获取到的参数:" + json + ",报错信息:" + bcxx, summary: "接口错误信息"); qu = qu.QueryResp(QueryErrorCode.Code101); } return(qu); }
public IHttpActionResult PayBank(JmPayParameter.Models.BanlModels mod) { Response json = new Response(); string ip = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress; try { Dictionary <string, string> dict = new Dictionary <string, string>(); string pamentjson = ""; #region 获取请求参数 //获取下单请求的参数 if (Request.Method == HttpMethod.Get) { dict = Request.GetQueryNameValuePairs() .ToDictionary(x => x.Key, x => x.Value, StringComparer.CurrentCultureIgnoreCase); if (dict.Count > 0) { pamentjson = JMP.TOOL.JsonHelper.DictJsonstr(dict); mod = JMP.TOOL.JsonHelper.Deserialize <BanlModels>(pamentjson); } } else if (Request.Method == HttpMethod.Post) { pamentjson = JMP.TOOL.JsonHelper.Serialize(mod); } #endregion var strjson = ""; if (mod != null && !string.IsNullOrEmpty(mod.code)) { #region 判断请求方式调用不同的方式解密 //判断请求方式(0为H5,1:sdk)根据不同的方式使用不同的方式解密 switch (mod.type) { case 0: //H5模式 strjson = JMP.TOOL.Encrypt.IndexDecrypt(mod.code); break; case 1: //SDK模式 strjson = JMP.TOOL.AesHelper.AesDecrypt(mod.code, ConfigurationManager.AppSettings["encryption"].ToString()); break; default: json = json.ToResponse(ErrorCode.Code9999); return(Ok(json)); } #endregion var mode = JMP.TOOL.JsonHelper.Deserialize <PayBankModels>(strjson); if (mode != null) { #region 根据参数信息调取对应的通道 //获取配置文件设置的缓存时间 int CacheTime = Int32.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString()); JmPayParameter.BankOrder bankOrder = new BankOrder(); //调用预下单接口 var message = bankOrder.H5OrBankEntrance(mode, CacheTime, ip); //判断是否成功(成功后返回) if (message != null && message.Success == true && !string.IsNullOrEmpty(message.ExtraData.ToString())) { #region 单成功后根据关联平台和支付方式组装对应的返回数据格式 if (mode.paymode == 3 && message.IsJump) { //成功后跳转方式 return(Redirect(message.ExtraData.ToString())); } else if (mode.paymode == 3 && (mode.paytype == "7" || mode.paytype == "6")) { string jsonurl = JMP.TOOL.JsonHelper.Serialize(message.ExtraData); Dictionary <string, object> exdata = JMP.TOOL.JsonHelper.DataRowFromJSON(jsonurl); return(Redirect(exdata["ImgQRcode"].ToString())); } else { SuccessResponse sucee = new SuccessResponse(); sucee.ErrorCode = message.ErrorCode; sucee.Message = message.Message; sucee.ExtraData = message.ExtraData; return(Ok(sucee)); } #endregion } else { json.ErrorCode = message.ErrorCode; json.Message = message.Message; } #endregion } else { json = json.ToResponse(ErrorCode.Code9999); } } else { json = json.ToResponse(ErrorCode.Code9999); } } catch (Exception e) { string bcxx = "报错提示" + e.ToString() + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace + ",Model:" + JMP.TOOL.JsonHelper.Serialize(mod);//报错信息 PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "收银台和H5模式第二次请求发起支付接口PayBank错误信息"); json = json.ToResponse(ErrorCode.Code103); } return(Ok(json)); }
public IHttpActionResult JmPay(JmPayApiServer.Models.RequestParameter model) { Response json = new Response(); //string ip = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress; string ip = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress; try { Dictionary <string, string> dict = new Dictionary <string, string>(); #region 获取参数 string pamentjson = ""; //获取下单请求的参数 if (Request.Method == HttpMethod.Get) { dict = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.CurrentCultureIgnoreCase); if (dict.Count > 0) { pamentjson = JMP.TOOL.JsonHelper.DictJsonstr(dict); model = JMP.TOOL.JsonHelper.Deserialize <RequestParameter>(pamentjson); } } else if (Request.Method == HttpMethod.Post) { pamentjson = JMP.TOOL.JsonHelper.Serialize(model); } #endregion if (model != null) { //获取配置文件设置的缓存时间 int CacheTime = Int32.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString()); if (string.IsNullOrEmpty(model.privateinfo)) { model.privateinfo = "404"; } //调用预下单接口 JmPayParameter.PreOrder pre = new PreOrder(); var message = pre.OrderInterface(pamentjson, model, CacheTime, ip); //判断是否成功(成功后返回) if (message.Success) { SuccessResponse sucee = new SuccessResponse(); sucee.ErrorCode = message.ErrorCode; sucee.Message = message.Message; sucee.ExtraData = message.ExtraData; if (message.IsJump) { return(Redirect(message.ExtraData.ToString())); } else { return(Ok(sucee)); } } else { json.ErrorCode = message.ErrorCode; json.Message = message.Message; } } else { json = json.ToResponse(ErrorCode.Code9999); } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace;//报错信息 PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "支付接口JmPay错误信息"); json = json.ToResponse(ErrorCode.Code103); } return(Ok(json)); }
/// <summary> /// 验证数据是否合法(需要使用查询数据) /// </summary> /// <param name="mode">请求参数实体</param> /// <param name="json">参数json字符串</param> /// <param name="app">应用实体</param> /// <returns></returns> private InnerResponse ValidationApp(RequestParameter mode, string json, jmp_app app) { InnerResponse Inn = new InnerResponse(); try { if (app == null) { return(Inn = Inn.ToResponse(ErrorCode.Code9998)); } //验证签名的方式 price + bizcode+timestamp+appkey string Verificationsign = mode.price + mode.bizcode + mode.timestamp + app.a_key; string sign = JMP.TOOL.MD5.md5strGet(Verificationsign, true).ToUpper(); if (mode.sign != sign) { PayApiDetailErrorLogger.DownstreamErrorLog("报错信息9989:支付接口签名验证失败,获取到的参数:" + json + ",组装的签名字符串:" + Verificationsign + ",我们生产的签名:" + sign, summary: "接口错误信息", appId: app.a_id, errorType: EnumForLogForApi.ErrorType.Other); return(Inn = Inn.ToResponse(ErrorCode.Code9989)); } //判断终端唯一标示码。ios和安卓模式为必传 if (app.a_platform_id < 3 && app.a_platform_id > 0) { if (string.IsNullOrEmpty(mode.termkey) || mode.termkey.Length > 64) { return(Inn = Inn.ToResponse(ErrorCode.Code9996)); } } else { mode.termkey = ""; } if (string.IsNullOrEmpty(mode.address)) { mode.address = app.a_notifyurl; } else { if (mode.address.Length > 200) { return(Inn = Inn.ToResponse(ErrorCode.Code9995)); } } if (app.a_platform_id == 3) { if (string.IsNullOrEmpty(mode.showaddress)) { mode.showaddress = app.a_showurl; } else { if (mode.showaddress.Length > 200) { return(Inn = Inn.ToResponse(ErrorCode.Code9994)); } } } if (mode.paytype < 0 || mode.paytype > 8) { return(Inn = Inn.ToResponse(ErrorCode.Code9990)); } else { if (mode.paytype > 0 && !app.a_paymode_id.Contains(mode.paytype.ToString())) { return(Inn = Inn.ToResponse(ErrorCode.Code105)); } else { pr.ThispayType = app.a_paymode_id; } } Inn = Inn.ToResponse(ErrorCode.Code100); } catch (Exception e) { PayApiGlobalErrorLogger.Log("报错信息103:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + e.ToString(), summary: "接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code103); } return(Inn); }
/// <summary> /// H5和收银台模式下单主通道 /// </summary> /// <param name="mode">接受参数modes实体</param> /// <param name="CacheTime"></param> /// <param name="ip"></param> /// <returns></returns> public InnerResponse H5OrBankEntrance(PayBankModels mode, int CacheTime, string ip) { InnerResponse Inn = new InnerResponse(); if (mode != null) { Inn = InspectParameter(mode); if (Inn.Success == true) { JMP.MDL.jmp_order mod = new JMP.MDL.jmp_order(); mod = SelectCode(mode.code, CacheTime, mode.paytype); if (mod != null && mod.o_state == 0) { Inn = checkSign(mode, mod); if (Inn.Success == true) { Apprate apprate = new Apprate(); if (Int32.Parse(mode.paytype) > 0 && !apprate.SelectApprate(mod.o_app_id, Int32.Parse(mode.paytype), CacheTime)) { return(Inn = Inn.ToResponse(ErrorCode.Code8987)); } if (UpdateCode(mod.o_id, int.Parse(mode.paytype))) { try { JmPayParameter.PayTypeFactory.PayTypeFactory payTypeFactory = new PayTypeFactory.PayTypeFactory(); var payType = payTypeFactory.Create(int.Parse(mode.paytype)); if (mode.paytype == "4" && (mode.paymode == 2 || mode.paymode == 1)) { mode.paymode = 3; } var channel = payType.LoadChannel(mode.paymode, mode.apptype, CacheTime, mod.o_app_id); JmPayParameter.PlaceOrder.PlaceOrderFactory placeOrderFactory = new PlaceOrder.PlaceOrderFactory(); //返回支付信息 Inn = placeOrderFactory.Create(channel.PassName, mode.paymode, mode.apptype, mode.code, mode.goodsname, mode.price, mod.o_id, ip, mod.o_app_id); } catch (Exc e) { Inn = e.Response; return(Inn); } } else { PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口收银台模式报错,修改订单失败:订单id:" + mod.o_id + ",支付方式:" + mode.paymode + ",订单编号:" + mode.code, summary: "接口错误信息", appId: mod.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat); Inn = Inn.ToResponse(ErrorCode.Code8999); } } } else { Inn = Inn.ToResponse(ErrorCode.Code8991); } } } else { PayApiGlobalErrorLogger.Log("报错信息103:支付接口收银台模式报错,未获取到下单参数,接收参数的实体为空", summary: "接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code103); } return(Inn); }
public Config(int tid, int appid) { #region 获取支付宝接口信息 string zfbjkhc = "ZFBjkhc" + appid;//组装缓存key值 try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(zfbjkhc)) { //string zfbpz = JMP.TOOL.CacheHelper.GetCaChe(zfbjkhc).ToString(); dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(zfbjkhc); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); private_key = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的支付宝私钥 partner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的支付宝账号 pay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); partner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝账号 private_key = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝私钥 pay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 //JMP.TOOL.CacheHelper.CacheObject(zfbjkhc, str, 1);//存入缓存 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, zfbjkhc, 1); } else { PayApiGlobalErrorLogger.Log("报错信息:支付宝支付接口错误", "应用id为:" + appid + "的支付通道为空,风控配置表id:" + tid + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "支付宝支付接口错误"); } } } else { dt = bll.SelectPay("ZFB", tid, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); partner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝账号 private_key = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取支付宝私钥 pay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 //JMP.TOOL.CacheHelper.CacheObject(zfbjkhc, str, 1);//存入缓存 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, zfbjkhc, 1); } else { PayApiGlobalErrorLogger.Log("报错信息:支付宝支付接口错误", "应用id为:" + appid + "的支付通道为空,风控配置表id:" + tid + ",直接从数据库未查询到相关信息", summary: "支付宝支付接口错误"); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString(); //报错信息 // AddLocLog.AddLog(1, 4, "", "支付宝支付接口错误", bcxx);//写入报错日志 PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "支付宝支付接口错误"); throw; } #endregion seller_id = partner; //public_key = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB"; public_key = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB"; input_charset = "utf-8"; sign_type = "RSA"; }
public override void ProcessNotify(int tid) { WxPayData notifyData = GetNotifyData(tid); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); page.Response.Write(res.ToXml()); page.Response.End(); } string transaction_id = notifyData.GetValue("transaction_id").ToString(); //查询订单,判断订单真实性 string ordertime = notifyData.GetValue("time_end").ToString(); if (ordertime == "null") { //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); page.Response.Write(res.ToXml()); page.Response.End(); } //查询订单成功 else { //商户订单号 string out_trade_no = notifyData.GetValue("out_trade_no").ToString(); //交易号 string trade_no = notifyData.GetValue("transaction_id").ToString(); //交易状态 string trade_status = notifyData.GetValue("result_code").ToString(); //买家账号 string buyer_email = notifyData.GetValue("transaction_id").ToString(); //买家付款时间 string gmt_payment = ordertime; //交易金额(单位:分转换成元) decimal o_price = decimal.Parse((decimal.Parse(notifyData.GetValue("total_fee").ToString()) / 100).ToString("f2")); if (trade_status == "SUCCESS") { try { JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string TableName = "jmp_order"; string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd"));//获取订单表名 morder = order.GetModelbycode(out_trade_no, TableName); if (morder != null) { if (morder.o_price == o_price) { int payid = !string.IsNullOrEmpty(morder.o_paymode_id) ? Int32.Parse(morder.o_paymode_id) : 0; if (JMP.TOOL.OrderProportion.ddbl(morder.o_app_id, o_price, payid)) { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { if (morder.o_state != 1) { morder.o_tradeno = trade_no; morder.o_ptime = DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); morder.o_payuser = buyer_email; morder.o_state = 1; morder.o_noticestate = 0; morder.o_price = o_price; order.Update(morder, TableName); JMP.MDL.jmp_app app = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app appbll = new JMP.BLL.jmp_app(); app = appbll.SelectId(morder.o_app_id); if (app != null) { JMP.MDL.jmp_queuelist quli = new JMP.MDL.jmp_queuelist(); JMP.BLL.jmp_queuelist bllq = new JMP.BLL.jmp_queuelist(); quli.q_address = morder.o_address; quli.q_sign = new JMP.BLL.jmp_app().GetModel(morder.o_app_id).a_secretkey; quli.q_noticestate = 0; quli.q_times = 0; quli.q_noticetimes = DateTime.Now; quli.q_tablename = orderTableName; quli.q_o_id = morder.o_id; quli.trade_type = Int32.Parse(morder.o_paymode_id); quli.trade_time = morder.o_ptime; quli.trade_price = morder.o_price; quli.trade_paycode = morder.o_tradeno; quli.trade_code = morder.o_code; quli.trade_no = morder.o_bizcode; quli.q_privateinfo = morder.o_privateinfo; quli.q_uersid = app.u_id; int cg = bllq.Add(quli); if (cg > 0) { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知错误", "订单号:" + morder.o_code + "添加到通知队列失败");//写入报错日志 PayApiGlobalErrorLogger.Log("订单号:" + morder.o_code + "添加到通知队列失败", summary: "微信官网通知错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知错误", "应用id:" + morder.o_app_id + ",获取用户id失败!");//写入报错日志 PayApiGlobalErrorLogger.Log("应用id:" + morder.o_app_id + ",获取用户id失败!", summary: "微信官网通知错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知接口错误", "订单号:" + out_trade_no + ",未查询到相关信息!");//写入报错日志 PayApiGlobalErrorLogger.Log("订单号:" + out_trade_no + ",未查询到相关信息!", summary: "微信官网通知接口错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } } } else { if (JMP.TOOL.UpdateOrder.OrderState.UpdateOrderState(morder.o_code, TableName)) { string ddsm = "订单号:" + morder.o_code + ",支付信息异常请核实!";//短信说明 JMP.TOOL.Auditor.IAuditor audit = new JMP.TOOL.Auditor.OrderAbnormalAuditor(morder.o_code, orderTableName, morder.o_app_id, ddsm, trade_no, DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture), o_price, "成功", morder.o_price); audit.Add(); WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } } else { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } catch { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } } }
/// <summary> /// 加载配置文件 /// </summary> /// <returns></returns> public static Dictionary <String, String> loadCfg(int tid, int appid) { Dictionary <String, String> cfg = new Dictionary <string, string>(); string dpkey = ""; //智付私钥 string dppartner = ""; //智付账号 int dppay_id = 0; //支付渠道id decimal minmun = 0; decimal maximum = 0; try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface blli = new JMP.BLL.jmp_interface(); string DPzfjkhc = "DPzfjkhc" + appid;//组装缓存key值 if (JMP.TOOL.CacheHelper.IsCache(DPzfjkhc)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(DPzfjkhc); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); dpkey = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的智付私钥 dppartner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取缓存数据中的智付账号 dppay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = blli.SelectPay("ZF", tid, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); dppartner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取智付账号 dpkey = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取智付私钥 dppay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, DPzfjkhc, 1); //存入缓存 } else { PayApiGlobalErrorLogger.Log("应用id为:" + appid + "的支付通道为空!风控id为:" + tid + ",获取缓存失败后从数据库未查询到相关信息!", summary: "智付支付接口错误"); } } } else { dt = blli.SelectPay("ZF", tid, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] payzf = dt.Rows[row]["l_str"].ToString().Split(','); dppartner = payzf[0].Replace("\r", "").Replace("\n", "").Trim(); //获取智付账号 dpkey = payzf[1].Replace("\r", "").Replace("\n", "").Trim(); //获取智付私钥 dppay_id = Int32.Parse(dt.Rows[row]["l_id"].ToString()); //支付渠道id minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, DPzfjkhc, 1); //存入缓存 } else { PayApiGlobalErrorLogger.Log("应用id为:" + appid + "的支付通道为空!风控id为:" + tid + ",从数据库未查询到相关信息!", summary: "智付支付接口错误"); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString(); //报错信息 AddLocLog.AddLog(1, 4, "", "智付支付接口错误", bcxx); //写入报错日志 throw; } //从数据库读取配置文件 cfg.Add("partner", dppartner); cfg.Add("dpkey", dpkey); cfg.Add("pay_id", dppay_id.ToString()); cfg.Add("minmun", minmun.ToString()); cfg.Add("maximum", maximum.ToString()); return(cfg); }