/// <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); }
protected void Page_Load(object sender, EventArgs e) { int oid = !string.IsNullOrEmpty(Request["pid"]) ? Convert.ToInt32(Request["pid"].ToString()) : 0; //订单表ID try { if (oid > 0) { string code = !string.IsNullOrEmpty(Request["code"]) ? Request["code"] : ""; if (!string.IsNullOrEmpty(code)) { TwoJump(oid, code); } else { OnJump(oid); } } else { Response.Write("非法访问!"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号支付接口错误信息", channelId: oid); Response.Write("非法访问!"); } }
/// <summary> /// 获取返回时的签名验证结果 /// </summary> /// <param name="inputPara">通知返回参数数组</param> /// <param name="sign">对比的签名结果</param> /// <returns>签名验证结果</returns> private bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign) { Dictionary <string, string> sPara = new Dictionary <string, string>(); //过滤空值、sign与sign_type参数 sPara = Core.FilterPara(inputPara); //获取待签名字符串 string preSignStr = Core.CreateLinkString(sPara); //获得签名验证结果 bool isSgin = false; if (sign != null && sign != "") { switch (_sign_type) { case "RSA": isSgin = RSAFromPkcs8.verify(preSignStr, sign, alipay_public_key, _input_charset); break; default: break; } } PayApiDetailErrorLogger.UpstreamNotifyErrorLog("支付宝组装待验证字符串:" + preSignStr + ",加密方式:" + _sign_type + ",支付宝公钥:" + alipay_public_key + ",验证结果:" + isSgin, summary: "支付宝官网扫码通知接口", channelId: 0); return(isSgin); }
protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; StreamReader reader = new StreamReader(Request.InputStream); String xmlData = reader.ReadToEnd();//获取xml数据 Dictionary <string, string> jsonlist = JMP.TOOL.xmlhelper.FromXmls(xmlData); if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; if (jsonlist.Count > 0 && pid > 0) { if (jsonlist["return_code"] == "SUCCESS") { JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid);//获取通道key值 Dictionary <string, string> list = jsonlist.Where(x => x.Key != "sign").ToDictionary(x => x.Key, x => x.Value); string md5 = JMP.TOOL.UrlStr.AzGetStr(list) + "&key=" + key;; string sing = JMP.TOOL.MD5.md5strGet(md5, true); if (jsonlist["sign"] == sing && jsonlist["result_code"] == "SUCCESS") { decimal o_price = decimal.Parse((decimal.Parse(jsonlist["total_fee"]) / 100).ToString("f2")); //支付金额(单位分转换成元) DateTime gmt_payment = DateTime.ParseExact(jsonlist["time_end"], "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);; //交易时间 string message = notic.PubNotice(jsonlist["out_trade_no"], o_price, gmt_payment, jsonlist["transaction_id"], jsonlist["transaction_id"], pid, "兴业银行", jsonstr); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("FAIL"); } } else { Response.Write("FAIL"); } } else { Response.Write("FAIL"); } } else { Response.Write("FAIL"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "兴业银行通知接口错误", channelId: pid); Response.Write("FAIL"); } }
protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pdpid = 0; Dictionary <string, string> jsonlist = JMP.TOOL.UrlStr.GetRequestfrom(HttpContext.Current, "微派支付通知接口"); if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { int pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; int alpayid = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["alpayid"].ToString()) ? int.Parse(ConfigurationManager.AppSettings["alpayid"].ToString()) : 0; //判断 if (jsonlist["synType"] == "wxpay") { pdpid = pid; } else { pdpid = alpayid; } if (pdpid > 0) { //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pdpid); Dictionary <string, string> dic = jsonlist.Where(x => x.Key != "sign").ToDictionary(x => x.Key, s => s.Value); //签名 string md5 = JMP.TOOL.UrlStr.AzGetStr(dic) + key; string signstr = JMP.TOOL.MD5.md5strGet(md5, true).ToUpper(); DateTime gmt_payment = DateTime.ParseExact(jsonlist["time"].ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); //判断 if (signstr == jsonlist["sign"].ToString() && jsonlist["status"].ToString() == "success") { string message = notic.PubNotice(jsonlist["cpparam"], decimal.Parse(jsonlist["price"]), gmt_payment, jsonlist["orderNo"], jsonlist["orderNo"], pdpid, "微派网络通知接口", jsonstr); if (message == "ok") { Response.Write("success"); } else { Response.Write("error"); } } } else { Response.Write("error"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "微派网络通知接口", channelId: pdpid); Response.Write("error"); } }
/// <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="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; Dictionary <string, string> jsonlist = UrlStr.GetRequestfrom(HttpContext.Current, "智付通知接口"); if (jsonlist != null) { jsonstr = JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"]) : 0; var callbackVerify = new CallbackVerify(); var form = Request.Form.AllKeys.ToDictionary(key => key, key => Request.Form[key]); if (pid > 0 && jsonlist.Count > 0) { //商户订单号 string out_trade_no = jsonlist["order_no"].Trim(); //智付交易号 string trade_no = jsonlist["trade_no"].Trim(); //交易状态 string trade_status = jsonlist["trade_status"].Trim(); //买家账号 string buyer_email = jsonlist["merchant_code"].Trim(); //买家付款时间 DateTime gmt_payment = Convert.ToDateTime(jsonlist["trade_time"].Trim()); //实际支付金额 decimal o_price = decimal.Parse(jsonlist["order_amount"].Trim()); if (callbackVerify.Verify(form) && jsonlist["trade_status"].Trim() == "SUCCESS") { JMALI.notice.notice notic = new notice.notice(); string message = notic.PubNotice(out_trade_no, o_price, gmt_payment, trade_no, buyer_email, pid, "智付通知接口", jsonstr); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("FAILED"); } } else { Response.Write("FAILED"); } } else { Response.Write("FAILED"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "智付通知接口错误", channelId: pid); Response.Write("FAILED"); } }
/// <summary> /// 获取公众号转微信wap账号信息 /// </summary> /// <param name="cache">缓存key</param> /// <param name="apptype">风控配置表id</param> /// <param name="appid">应用id</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str;//获取key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); } else { dt = bll.SelectPay("GZHZWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str; //获取公众号转微信wap支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "公众号转微信wap支付支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("GZHZWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string l_str = dt.Rows[row]["l_str"].ToString(); SeIn.UserKey = l_str; //获取公众号转微信wap支付key JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据库未查询到相关信息!", summary: "公众号转微信wap支付支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "公众号转微信wap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId); } return(SeIn); }
protected void Page_Load(object sender, EventArgs e) { int pid = 0; StreamReader reader = new StreamReader(Request.InputStream); String jsonData = reader.ReadToEnd();//获取数据 try { RootObject obj = new RootObject(); obj = JMP.TOOL.JsonHelper.Deserialize <RootObject>(jsonData); pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; if (pid > 0) { JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid);//获取通道key值 string json = JMP.TOOL.JsonHelper.Serialize(obj.info); Dictionary <string, string> dic = JMP.TOOL.JsonHelper.DataRowJSON(json); string signstr = JMP.TOOL.UrlStr.AzGetStr(dic) + "&key=" + key; string signstring = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower(); if (obj != null && signstring == obj.sign) { if (obj.resultCode == "20000" && obj.info.pay_status == "TRADE_SUCCESS") { DateTime gmt_payment = DateTime.Now; string message = notic.PubNotice(obj.info.pay_order, decimal.Parse(obj.info.pay_fee), gmt_payment, obj.info.transid, obj.info.transid, pid, "小小贝支付宝wap通知接口错误", jsonData); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("FAILURE"); } } else { Response.Write("FAILURE"); } } else { Response.Write("FAILURE"); } } else { Response.Write("FAILURE"); PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数Pid错误:" + pid + "小小贝支付宝wap通知接口错误", channelId: pid); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonData + ",错误信息:" + ex, summary: "小小贝支付宝wap通知接口错误", channelId: pid); Response.Write("FAILURE"); } }
/// <summary> /// 通知接口外部调用公共方式(主入口) /// </summary> /// <param name="code">订单编号</param> /// <param name="price">支付金额(单位:元)</param> /// <param name="gmt_payment">支付时间</param> /// <param name="trade_no">第三方流水号</param> /// <param name="payuser">付款账号</param> /// <param name="channelId">通道id</param> /// <param name="tname">接口名称</param> /// <param name="noticestr">传入参数字符串</param> /// <returns></returns> public string PubNotice(string code, decimal price, DateTime gmt_payment, string trade_no, string payuser, int channelId, string tname, string noticestr) { string message = ""; try { JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(gmt_payment.ToString()); //获取订单表名 morder = SelectOrder(code, noticestr); //获取订单信息 if (morder != null) { if (price == morder.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, price, payid))//调单设置 { message = "ok"; } else { if (morder.o_interface_id != channelId) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("订单号:" + code + ",我们记录的通道id:" + morder.o_interface_id + ",上游获取回来的id:" + channelId + ",订单表id:" + morder.o_id, summary: tname + "通知接口错误,串单了", channelId: channelId); } if (morder.o_state != 1) { if (UpdateOrder(morder, trade_no, gmt_payment, price, payuser, noticestr, channelId)) { message = addqueuelist(morder, orderTableName, tname, noticestr); } } else { message = "ok"; } } } else { message = AddAuditor(morder, orderTableName, trade_no, gmt_payment, price, noticestr); } } else { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("订单号:" + code + ",未查询到相关信息!,传入参数:" + noticestr, summary: tname + "通知接口错误", channelId: channelId); message = "error"; } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("通知接口主入口出错,订单号:" + code + ",传入参数:" + noticestr + ",错误信息:" + ex.ToString(), summary: tname + "通知接口错误", channelId: channelId); message = "error"; } return(message); }
/// <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> /// 南粤异步通知接口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; Dictionary <string, string> jsonlist = JMP.TOOL.UrlStr.GetRequestJson(HttpContext.Current, "南粤通知接口"); if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; if (pid > 0 && jsonlist.Count > 0) { //买家付款时间 DateTime gmt_payment = DateTime.ParseExact(jsonlist["transTime"].ToString(), "yyyyMMddHHmmss", CultureInfo.InvariantCulture); //交易金额(单位:元) decimal o_price = decimal.Parse(jsonlist["amount"]); //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); //组装签名 Dictionary <string, string> list = jsonlist.Where(x => x.Key != "sign").ToDictionary(x => x.Key, x => x.Value); string md5 = JMP.TOOL.UrlStr.AzGetStr(list) + "&key=" + key; string md5str = JMP.TOOL.MD5.md5strGet(md5, true); if (md5str == jsonlist["sign"] && jsonlist["status"] == "02") { string message = notic.PubNotice(jsonlist["outTradeNo"], o_price, gmt_payment, jsonlist["outChannelNo"], jsonlist["outChannelNo"], pid, "南粤通知接口", jsonstr); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("fail"); } } else { Response.Write("fail"); } } else { Response.Write("fail"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "南粤通知接口错误", channelId: pid); Response.Write("fail"); } }
protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; jsonstr = JMP.TOOL.UrlStr.PostInput(HttpContext.Current, "现在通知接口");//获取通知参数(post数据流) jsonstr = HttpUtility.UrlDecode(jsonstr); try { string json = jsonstr.Replace("=", "\":\"").Replace("&", "\",\""); json = "{\"" + json + "\"}"; Dictionary <string, string> jsonlist = JMP.TOOL.JsonHelper.Deserialize <Dictionary <string, string> >(json); pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; if (pid > 0 && jsonlist.Count > 0 && jsonlist["transStatus"] == "A001") { //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); // string key = "1FZMAlAplOTamX6OARDVV8hrswhbGEVg"; Dictionary <string, string> list = jsonlist.Where(x => x.Key != "signature").ToDictionary(x => x.Key, x => x.Value); string signstr = JMP.TOOL.UrlStr.AzGetStr(list) + "&" + JMP.TOOL.MD5.md5strGet(key, true).ToLower(); string sign = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower(); if (sign == jsonlist["signature"]) { //交易金额(单位:分) DateTime gmt_payment = DateTime.ParseExact(jsonlist["payTime"].ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); decimal o_price = decimal.Parse((decimal.Parse(jsonlist["oriMhtOrderAmt"]) / 100).ToString("f2"));//支付金额(单位分转换成元) string message = notic.PubNotice(jsonlist["mhtOrderNo"], o_price, gmt_payment, jsonlist["nowPayOrderNo"], jsonlist["channelOrderNo"], pid, "现在通知接口", jsonstr); if (message == "ok") { Response.Write("success=Y"); } else { Response.Write("fail"); } } else { Response.Write("fail"); } } else { Response.Write("fail"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "现在通知接口", channelId: pid); Response.Write("fail"); } }
protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; Dictionary <string, string> jsonlist = JMP.TOOL.UrlStr.GetRequestGet(HttpContext.Current, "融梦通知接口"); if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; if (pid > 0 && jsonlist.Count > 0 && jsonlist["return_code"] == "0") { //买家付款时间 DateTime gmt_payment = DateTime.Now; //交易金额(单位:分) decimal o_price = decimal.Parse((decimal.Parse(jsonlist["totalFee"]) / 100).ToString("f2"));//支付金额(单位分转换成元) //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelecRmHdKey(pid); //组装签名 string sign = "channelOrderId=" + jsonlist["channelOrderId"] + "&key=" + key + "&orderId=" + jsonlist["orderId"] + "&timeStamp=" + jsonlist["timeStamp"] + "&totalFee=" + jsonlist["totalFee"]; string md5str = JMP.TOOL.MD5.md5strGet(sign, true).ToLower(); if (md5str == jsonlist["sign"]) { string message = notic.PubNotice(jsonlist["channelOrderId"], o_price, gmt_payment, jsonlist["orderId"], jsonlist["orderId"], pid, "融梦通知接口", jsonstr); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("fail"); } } else { Response.Write("fail"); } } else { Response.Write("fail"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "融梦通知接口", channelId: pid); Response.Write("fail"); } }
/// <summary> /// 根据应用id查询对应的支付通道 /// </summary> /// <param name="cache">缓存名称</param> /// <param name="appid">应用id</param> /// <param name="apptype">风控配置表id</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int appid, int apptype, int infoTimes) { SelectInterface SeIn = new SelectInterface(); DataTable dt = new DataTable(); JMP.BLL.jmp_interface blls = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = blls.SelectPay("WX", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存失败后,从数据库未查询到相关信息!", summary: "微信支付接口错误", channelId: SeIn.PayId); } } } else { dt = blls.SelectPay("WX", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",从数据未查询到相关信息!", summary: "微信支付接口错误", channelId: SeIn.PayId); } } return(SeIn); }
public void callback(int pid) { //加载配置数据 this.cfg = Utils.Load_CfgInterfaceId(pid); //初始化数据 using (StreamReader sr = new StreamReader(Request.InputStream)) { this.resHandler.setContent(sr.ReadToEnd()); this.resHandler.setKey(this.cfg["key"]); Hashtable resParam = this.resHandler.getAllParameters(); if (this.resHandler.isTenpaySign()) { if (int.Parse(resParam["status"].ToString()) == 0 && int.Parse(resParam["result_code"].ToString()) == 0) { //Utils.writeFile("接口回调", resParam); //通知返回参数写入result.txt文本文件。 //商户订单号 string out_trade_no = resParam["out_trade_no"].ToString(); //微付通交易号 string trade_no = resParam["transaction_id"].ToString(); //买家账号 string buyer_email = resParam["out_transaction_id"].ToString(); //买家付款时间 DateTime gmt_payment = DateTime.ParseExact(resParam["time_end"].ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); //付款金额(单位分转换成元) JMALI.notice.notice notic = new notice.notice(); decimal o_price = decimal.Parse((decimal.Parse(resParam["total_fee"].ToString()) / 100).ToString("f2")); string message = notic.PubNotice(out_trade_no, o_price, gmt_payment, trade_no, buyer_email, pid, "威富通通知程序接口", JMP.TOOL.JsonHelper.Serialize(resParam)); if (message == "ok") { Response.Write("success"); } else { Response.Write("fail"); } } } else { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + resParam, summary: "威富通通知接口错误", channelId: pid); Response.Write("fail"); } } }
/// <summary> /// 微信公众号第一次跳转 /// </summary> /// <param name="Oid">订单id</param> private void OnJump(int Oid) { try { string str = ""; JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + Oid + ") ").Tables[0]); if (mo != null) { SelectInterface SeIn = new SelectInterface(); string cache = "wxgfgzh" + Oid; SeIn = SelectInfo(cache, mo.a_rid, mo.a_id, int.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString())); if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey)) { str = "{\"Message\":\"支付通道未配置\",\"ErrorCode\":106}"; Response.Write(str); } JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = bll.SelectOrderGoodsName(Oid, "jmp_order"); if (morder.o_price < SeIn.minmun) { str = "{\"Message\":\"订单金额不能小于单笔最小支付金额\",\"ErrorCode\":8990}"; Response.Write(str); } if (morder.o_price > SeIn.maximum) { str = "{\"Message\":\"订单金额不能大于单笔最大支付金额\",\"ErrorCode\":8989}"; Response.Write(str); } if (bll.UpdatePay(Oid, SeIn.PayId)) { string redirect_uri = ConfigurationManager.AppSettings["WxGzhRturnUrl"].ToString() + Oid + ".html"; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + "回调地址:" + redirect_uri, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + SeIn.wxappid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_base#wechat_redirect"; Response.Redirect(url, false); } } else { str = "{\"Message\":\"支付接口异常\",\"ErrorCode\":102}"; Response.Write(str); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); Response.Write("非法访问!"); } }
/// <summary> /// 验证平台订单号是否存在重复 /// </summary> /// <param name="Code">订单号</param> /// <param name="CacheTime">缓存时间</param> /// <returns></returns> private bool VerificationCode(string Code, int CacheTime, int appid) { bool msg = false; string Cachekey = "VerificationCode" + Code; if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存 { PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: appid, errorType: EnumForLogForApi.ErrorType.RequestRepeat); } else { JMP.TOOL.CacheHelper.CacheObjectLocak <string>(Code, Cachekey, CacheTime);//存入缓存 msg = true; } return(msg); }
/// <summary> /// 支付宝官网通知程序接口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); string jsonstr = ""; int pid = 0; Dictionary <string, string> jsonlist = JMP.TOOL.UrlStr.GetRequestfrom(HttpContext.Current, "支付宝官网通知接口"); if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; Notify aliNotify = new Notify(pid); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult && pid > 0 && jsonlist["trade_status"] == "TRADE_SUCCESS") { //买家付款时间 DateTime gmt_payment = DateTime.Parse(jsonlist["gmt_payment"]); //订单金额(单位:元) decimal price = jsonlist.ContainsKey("total_fee") ? decimal.Parse(jsonlist["total_fee"]) : decimal.Parse(jsonlist["total_amount"]);//支付金额(单位元) string buyer_email = jsonlist.ContainsKey("buyer_email") ? jsonlist["buyer_email"] : jsonlist["buyer_id"]; JMALI.notice.notice notic = new notice(); string message = notic.PubNotice(jsonlist["out_trade_no"], price, gmt_payment, jsonlist["trade_no"], buyer_email, pid, "支付宝官网通知接口", jsonstr); if (message == "ok") { Response.Write("success"); } else { Response.Write("fail"); } } else { Response.Write("fail"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "支付宝官网通知接口", channelId: pid); Response.Write("fail"); } }
/// <summary> /// 获取浦发账号信息 截取到通道id /// </summary> /// <param name="cache">缓存key</param> /// <param name="apptype">风控配置表id</param> /// <param name="appid">应用id</param> /// <returns></returns> private int SelectUserInfo(int apptype, int appid) { int PayId = 0; string cache = "pfyhwxgzhpay" + appid; try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); PayId = Int32.Parse(dt.Rows[row]["l_id"].ToString()); } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype, channelId: PayId); } } else { dt = bll.SelectPay("PFWXGZH", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); PayId = Int32.Parse(dt.Rows[row]["l_id"].ToString()); JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, int.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString()));//存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype, channelId: PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "浦发银行微信公众号支付接口错误", channelId: PayId); } return(PayId); }
/// <summary> /// 验证商户订单号是否唯一 /// </summary> /// <param name="bizcode">商户订单号</param> /// <param name="appid">应用id</param> /// <returns></returns> private bool VerificationCode(string bizcode, int appid) { bool IsRepeat = false; JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); string Cachekey = "VerificationCode" + bizcode + appid; if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存 { PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口验证参数错误,商户订单重复,缓存值:" + Cachekey + ",商户订单号:" + bizcode, summary: "接口错误信息", appId: appid, errorType: EnumForLogForApi.ErrorType.OrderNoRepeat); IsRepeat = true; } else { IsRepeat = false; } return(IsRepeat); }
/// <summary> /// 根据通道id查询通道信息 /// </summary> /// <param name="pid">通道id</param> /// <returns>返回通道key值</returns> public string SelectKey(int pid) { string key = ""; try { var zf = new JMP.BLL.jmp_interface(); string str = zf.strzf_monitor(pid);//获取通道key值 if (!string.IsNullOrEmpty(str)) { key = str.Split(',')[1]; } return(key); } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("通道id:" + pid + ",错误信息:" + ex.ToString(), summary: "通知接口查询通道信息错误", channelId: pid); return(key); } }
/// <summary> /// 根据订单编号查询订单信息并调取支付当时 /// </summary> /// <param name="Code">订单编号</param> /// <param name="json">接受参数json字符串</param> /// <param name="ip">请求ip地址</param> /// <returns></returns> private JMP.MDL.jmp_order SelectCode(string Code, int CacheTime, string paytype) { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); string Cachekey = "SelectCode" + Code + paytype; if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存 { if (paytype == "4") { mode = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存 } else { JMP.MDL.jmp_order moded = new JMP.MDL.jmp_order(); moded = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存 PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: moded.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat); mode = null; } //mode = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_order>(Cachekey);//获取缓存 //if (mode == null) //{ // mode = bll.GetModelbycode(Code, "jmp_order"); // if (mode != null) // { // JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存 // } //} } else { mode = bll.SelectCode(Code, "jmp_order"); if (mode != null) { JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存 } } return(mode); }
/// <summary> /// 调用微信jsapi放方法 /// </summary> /// <param name="Oid">订单id</param> /// <param name="dictionary">微信回传的键值集合</param> /// <param name="UserKey">api秘钥</param> /// <param name="showaddress">同步地址</param> private void CallJsApid(int Oid, Dictionary <string, object> dictionary, string UserKey, string showaddress) { try { string timestamp = JMP.TOOL.WeekDateTime.GetMilis;//时间戳 Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("appId", dictionary["appid"].ToString()); dict.Add("timeStamp", timestamp); dict.Add("nonceStr", dictionary["nonce_str"].ToString()); dict.Add("signType", "MD5"); string package = @"prepay_id=" + dictionary["prepay_id"]; dict.Add("package", package); string apimd5 = JMP.TOOL.UrlStr.AzGetStr(dict) + "&key=" + UserKey; string jspaimd5 = JMP.TOOL.MD5.md5strGet(apimd5, true).ToUpper(); string chengstr = "<script type=\"text/javascript\">function onBridgeReady(){WeixinJSBridge.invoke( 'getBrandWCPayRequest', {\"appId\": \"" + dictionary["appid"] + "\", \"timeStamp\": \"" + timestamp + "\", \"nonceStr\": \"" + dictionary["nonce_str"] + "\",\"package\":\"" + package + "\",\"signType\": \"MD5\",\"paySign\": \"" + jspaimd5 + "\" },function(res) { if (res.err_msg ==\"get_brand_wcpay_request:ok\") { window.location.href=\"" + showaddress + "\" }else{ alert(res.err_msg) } });}if (typeof WeixinJSBridge == \"undefined\"){if (document.addEventListener){document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);}else if (document.attachEvent){document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);} }else{onBridgeReady();}</script> "; Response.Write(chengstr); } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号支付接口调用jsApi时错误信息", channelId: Oid); String str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; Response.Write(str); } }
/// <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="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); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int oid = !string.IsNullOrEmpty(Request["pid"]) ? Convert.ToInt32(Request["pid"].ToString()) : 0; //订单表ID if (oid > 0) { //获取缓存 try { string code = !string.IsNullOrEmpty(Request["code"]) ? Request["code"] : ""; if (!string.IsNullOrEmpty(code)) { string url = ""; System.Threading.Thread.Sleep(new Random().Next(100, 500)); if (JMP.TOOL.CacheHelper.IsCache(oid.ToString()) == false) { url = "/pfwxgzhorder" + oid + ".html?code=" + code; JMP.TOOL.CacheHelper.CacheObject(url, oid.ToString(), 1);//存入缓存 } else { url = JMP.TOOL.CacheHelper.GetCaChe <string>(oid.ToString()); } Response.Redirect(url, false); } else { string appid = ""; JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + oid + ") ").Tables[0]); int pay_id = SelectUserInfo(mo.a_rid, mo.a_id); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (pay_id > 0) { if (bll.UpdatePay(oid, pay_id)) { string ddjj = Get_paystr(pay_id.ToString()); appid = ddjj.ToString().Split(',')[2]; string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + ConfigurationManager.AppSettings["redirecturipf"].ToString() + oid + ".html&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; Response.Redirect(url, false); } } else { Response.Write("非法访问!"); } } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "浦发银行公众号支付接口错误信息", channelId: oid); Response.Write("非法访问!"); } } else { Response.Write("非法访问!"); } } }
/// <summary> /// 获取支付账号信息 /// </summary> /// <param name="cache">缓存Key</param> /// <param name="apptype">风控配置表ID</param> /// <param name="appid">应用Id</param> /// <param name="infoTimes">查询接口信息缓存时间</param> /// <returns></returns> private SelectInterface SelectUserInfo(string cache, int apptype, int appid, int infoTimes) { SelectInterface SeIn = new SelectInterface(); try { DataTable dt = new DataTable(); JMP.BLL.jmp_interface bll = new JMP.BLL.jmp_interface(); if (JMP.TOOL.CacheHelper.IsCache(cache)) { dt = JMP.TOOL.CacheHelper.GetCaChe <DataTable>(cache); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 } else { dt = bll.SelectPay("TBQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",获取缓存未成功后在次查询数据!", summary: "途贝QQwap支付支付接口错误", channelId: SeIn.PayId); } } } else { dt = bll.SelectPay("TBQQWAP", apptype, appid); if (dt != null && dt.Rows.Count > 0) { int row = new Random().Next(0, dt.Rows.Count); string[] PayConfigure = dt.Rows[row]["l_str"].ToString().Split(','); SeIn.UserId = PayConfigure[0].Replace("\r", "").Replace("\n", "").Trim(); //支付商户账号 SeIn.UserKey = PayConfigure[1].Replace("\r", "").Replace("\n", "").Trim(); //支付key SeIn.PayId = int.Parse(dt.Rows[row]["l_id"].ToString()); SeIn.minmun = decimal.Parse(dt.Rows[row]["l_minimum"].ToString()); //单笔最小支付金额 SeIn.maximum = decimal.Parse(dt.Rows[row]["l_maximum"].ToString()); //单笔最大支付金额 JMP.TOOL.CacheHelper.CacheObjectLocak <DataTable>(dt, cache, infoTimes); //存入缓存 } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("应用id为:" + appid + "的支付通道为空!风控id为:" + apptype + ",在数据库为查询到数据", summary: "途贝QQwap支付支付接口错误", channelId: SeIn.PayId); } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString();//报错信息 PayApiDetailErrorLogger.UpstreamPaymentErrorLog(bcxx, summary: "途贝QQwap支付支付接口错误应用类型ID:" + apptype, channelId: SeIn.PayId); } return(SeIn); }
/// <summary> /// 验证数据是否合法(需要使用查询数据) /// </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> /// 途贝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); }