/// <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> /// 智付通知接口程序 /// </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"); } }
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> /// 南粤异步通知接口 /// </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"); } }
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="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="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="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.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; if (pid > 0) { //订单号码 string order_id = jsonlist["order_id"]; //系统订单 string orderNo = jsonlist["orderNo"]; //支付金额 decimal money = decimal.Parse((decimal.Parse(jsonlist["money"]) / 100).ToString()); //商务号 string mch = jsonlist["mch"]; //支付类型 string pay_type = jsonlist["pay_type"]; //支付状态 string status = jsonlist["status"]; //签名 string sign = jsonlist["sign"]; //时间戳 string time = jsonlist["time"]; //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); //组装签名 string md5 = order_id + orderNo + jsonlist["money"] + mch + pay_type + time + JMP.TOOL.MD5.md5strGet(key, true).ToLower(); string signstr = JMP.TOOL.MD5.md5strGet(md5, true).ToLower(); if (signstr == sign && status == "1") { string message = notic.PubNotice(order_id, money, JMP.TOOL.WeekDateTime.GetTime(time), orderNo, orderNo, pid, "微唯网络通知接口", jsonstr); if (message == "ok") { Response.Write("SUCCESS"); } else { Response.Write("ERROR"); } } else { Response.Write("ERROR"); } } else { Response.Write("ERROR"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "微唯网络通知接口", channelId: pid); Response.Write("ERROR"); } }
/// <summary> /// 汇元通知接口程序 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { int pid = 0; string jsonstr = ""; 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) { //订单编号 string userpara = jsonlist["agent_bill_id"].ToString().Trim(); //签名 string sign = jsonlist["sign"].ToString().Trim(); //第三方流水号 string trade_no = jsonlist["jnet_bill_no"].ToString(); //交易状态 string trade_status = jsonlist["result"].ToString(); //买家账号 string buyer_email = trade_no; //买家付款时间 DateTime gmt_payment = DateTime.Now; //交易金额(单位:元) decimal o_price = decimal.Parse(Request.QueryString["pay_amt"]); var zf = new JMP.BLL.jmp_interface(); JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid);//获取通道key值 string md5 = "result=" + trade_status + "&agent_id=" + jsonlist["agent_id"] + "&jnet_bill_no=" + trade_no + "&agent_bill_id=" + userpara + "&pay_type=" + Request.QueryString["pay_type"] + "&pay_amt=" + jsonlist["pay_amt"] + "&remark=" + jsonlist["remark"] + "&key=" + key; string md5str = JMP.TOOL.MD5.md5strGet(md5, true).ToLower(); if (md5str == sign && trade_status == "1") { string message = notic.PubNotice(userpara, o_price, gmt_payment, trade_no, buyer_email, pid, "汇元通知接口", jsonstr); if (message == "ok") { Response.Write("ok"); } else { Response.Write("error"); } } else { Response.Write("error"); } } else { Response.Write("error"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "汇元通知接口", channelId: pid); Response.Write("error"); } }
protected void Page_Load(object sender, EventArgs e) { string jsonstr = ""; int pid = 0; StreamReader reader = new StreamReader(Request.InputStream); String xmlData = reader.ReadToEnd();//获取xml数据 PAY_NODIFY obj = new PAY_NODIFY(); jsonstr = xmlData.ToString(); try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; obj = xmlhelper.Deserialize <PAY_NODIFY>(xmlData); } catch { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("解析xml格式出错,获取到的xml数据:" + xmlData.ToString(), summary: "浦发银行通知接口错误", channelId: pid); obj = JsonHelper.Deserializes <PAY_NODIFY>(xmlData.Replace(" ", "")); } try { string signstr = string.IsNullOrEmpty(Request["sign"]) ? "" : Request["sign"]; if (obj != null && !string.IsNullOrEmpty(signstr) && pid > 0) { if (obj.STATE == "1") { JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); //获取通道key值 decimal price = decimal.Parse((decimal.Parse(obj.AMT) / 100).ToString()); //支付金额(单位分转换成元) string mch_id = obj.BUSI_ID; //商户号(浦发账号) string code = obj.CHARGE_CODE; //商户订单号(我们平台编号) string timestamp = signstr.Split(':')[1]; string signs = timestamp + key + xmlData.Replace(" ", "").Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Replace("\\", ""); string sign = JMP.TOOL.MD5.md5strGet(signs, true).ToLower() + ":" + timestamp; if (signstr == sign) { DateTime gmt_payment = DateTime.Now;//交易时间 string message = notic.PubNotice(code, price, gmt_payment, obj.CHARGE_DOWN_CODE, obj.CHARGE_DOWN_CODE, pid, "浦发支付宝通知接口", jsonstr); if (message == "ok") { Response.StatusCode = 200; Response.Write("200"); } 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 pid = 0; //var nameValue = JMP.TOOL.UrlStr.GetRequestfrom(HttpContext.Current, "掌趣支付通知接口"); //Dictionary<string, string> jsonlist = nameValue.Cast<string>().ToDictionary(x => x, x => nameValue[x]); 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; if (pid > 0) { //状态码 string reCode = jsonlist["reCode"]; //商户编号 string merchantNo = jsonlist["merchantNo"]; //商户订单号 string merchantOrderno = jsonlist["merchantOrderno"]; //订单状态 string result = jsonlist["result"]; //支付类型 string payType = jsonlist["payType"]; //商品名称 string memberGoods = HttpUtility.UrlDecode(jsonlist["memberGoods"]); //成功金额 decimal amount = decimal.Parse(jsonlist["amount"]); //单位:元,保留两位小数 //签名数据 string hmac = jsonlist["hmac"]; //获取通道key值 JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); //组装签名 string md5 = reCode + merchantNo + merchantOrderno + result + payType + memberGoods + amount; //签名 string signstr = JMP.TOOL.Digest.HmacSign(md5, key); if (signstr == hmac && reCode == "1" && result == "SUCCESS") { DateTime time_payment = DateTime.Now; string message = notic.PubNotice(merchantOrderno, amount, time_payment, merchantOrderno, merchantOrderno, 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> /// 优乐通知接口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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 = new Dictionary <string, string>(); try { pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"].ToString()) : 0; jsonlist = JMP.TOOL.xmlhelper.FromXmls(xmlData); } catch { PayApiDetailErrorLogger.UpstreamNotifyErrorLog("解析xml格式出错,获取到的xml数据:" + xmlData.ToString(), summary: "优乐通知接口错误", channelId: pid); jsonlist = JMP.TOOL.xmlhelper.FromXmls(xmlData.Replace(" ", "")); } if (jsonlist != null) { jsonstr = JMP.TOOL.JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串 } try { if (jsonlist.Count > 0 && pid > 0) { if (jsonlist["return_code"] == "SUCCESS" && jsonlist["result_code"] == "SUCCESS") { JMALI.notice.notice notic = new notice.notice(); string key = notic.SelectKey(pid); //获取通道key值 decimal price = decimal.Parse((decimal.Parse(jsonlist["total_fee"]) / 100).ToString()); //支付金额(单位分转换成元) string mch_id = jsonlist["mch_id"]; //商户号(优乐账号) string code = jsonlist["out_trade_no"]; //商户订单号(我们平台编号) string sign = JMP.TOOL.MD5.md5strGet(mch_id + code + key, true).ToUpper(); //组装签名验证 if (jsonlist["attach"] == sign) { DateTime gmt_payment = DateTime.ParseExact(jsonlist["time_end"], "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);; //交易时间 string message = notic.PubNotice(code, 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"); } }