public static bool VerifyNotify(FengHeNotify notifyinfo) { //-------记录请求参数 YSWL.Log.LogHelper.AddInfoLog("FengHe-->VerifyNotify", String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign)); if (String.IsNullOrWhiteSpace(notifyinfo.memberid) || String.IsNullOrWhiteSpace(notifyinfo.orderid)) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【FengHe支付回调通知失败"), "参数错误"); return(false); } string signStr = StringHelper.GetMD5(String.Format("amount={0}&datetime={1}&memberid={2}&orderid={3}&returncode={4}&transaction_id={5}&key={6}", notifyinfo.amount, notifyinfo.datetime, notifyinfo.memberid, notifyinfo.orderid, notifyinfo.returncode, notifyinfo.transaction_id, apikey)).ToUpper(); if (signStr == notifyinfo.sign) { if (notifyinfo.returncode == "00") { ColoPay.BLL.Pay.Order orderBll = new BLL.Pay.Order(); ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.orderid); if (orderInfo == null) { return(false); } if (orderInfo.PaymentStatus == 2) { return(true); } bool isSuccess = orderBll.CompleteOrder(orderInfo); if (isSuccess)//成功之后需要回调商家回调地址 { try { ColoPay.BLL.Pay.Enterprise.Notify(orderInfo); } catch (Exception ex) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】FengHe支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace); return(isSuccess); } } return(isSuccess); } else { return(false); } } else { YSWL.Log.LogHelper.AddErrorLog(String.Format("订单【{0}】FengHe支付验证失败", notifyinfo.orderid), String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign)); //验证失败,记录日志 ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】FengHe支付验证失败", notifyinfo.orderid), String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign)); return(false); } }
public static bool VerifyNotify(QrNotify notifyinfo) { //-------记录请求参数 YSWL.Log.LogHelper.AddInfoLog("QR_Pay-->VerifyNotify", String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign)); if (notifyinfo.customerid == 0 || String.IsNullOrWhiteSpace(notifyinfo.sdpayno) || String.IsNullOrWhiteSpace(notifyinfo.sdorderno) || String.IsNullOrWhiteSpace(notifyinfo.paytype)) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【QRPay支付回调通知失败"), "参数错误"); return(false); } string signStr = StringHelper.GetMD5(String.Format("customerid={0}&status={1}&sdpayno={2}&sdorderno={3}&total_fee={4}&paytype={5}&{6}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey)); if (signStr == notifyinfo.sign) { if (notifyinfo.status == 1) { ColoPay.BLL.Pay.Order orderBll = new BLL.Pay.Order(); ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.sdorderno); if (orderInfo == null) { return(false); } if (orderInfo.PaymentStatus == 2) { return(true); } bool isSuccess = orderBll.CompleteOrder(orderInfo); if (isSuccess)//成功之后需要回调商家回调地址 { try { ColoPay.BLL.Pay.Enterprise.Notify(orderInfo); } catch (Exception ex) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】QrPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace); return(isSuccess); } } return(isSuccess); } else { return(false); } } else { YSWL.Log.LogHelper.AddInfoLog(String.Format("订单【{0}】QrPay支付验证失败", notifyinfo.sdorderno), String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign)); //验证失败,记录日志 ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】QrPay支付验证失败", notifyinfo.sdorderno), String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign)); return(false); } }
public static bool VerifyNotify(DaNotify notifyinfo) { //-------记录请求参数 YSWL.Log.LogHelper.AddInfoLog("DaDaBank-->VerifyNotify", String.Format("参数为:order-->{0}&code-->{1}&mount-->{2}&msg-->{3}&time-->{4}&sign-->{5}", notifyinfo.order, notifyinfo.code, notifyinfo.mount, notifyinfo.msg, notifyinfo.time, notifyinfo.sign)); if (String.IsNullOrWhiteSpace(notifyinfo.order) || String.IsNullOrWhiteSpace(notifyinfo.code)) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【DaPay支付回调通知失败"), "参数错误"); return(false); } string signStr = GetNotifySignStr(notifyinfo.order, notifyinfo.mount, notifyinfo.code, notifyinfo.msg, notifyinfo.time); //StringHelper.GetMD5(String.Format("mch_id={0}&status={1}&sdpayno={2}&order_no={3}&money={4}&paytype={5}&{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey)); if (signStr == notifyinfo.sign) { if (notifyinfo.code == "200") { ColoPay.BLL.Pay.Order orderBll = new BLL.Pay.Order(); ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.order); if (orderInfo == null) { return(false); } if (orderInfo.PaymentStatus == 2) { return(true); } bool isSuccess = orderBll.CompleteOrder(orderInfo); if (isSuccess)//成功之后需要回调商家回调地址 { try { ColoPay.BLL.Pay.Enterprise.Notify(orderInfo); } catch (Exception ex) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】DaPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace); return(isSuccess); } } return(isSuccess); } else { return(false); } } else { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单DaPay支付回调通知失败"), String.Format("加密签名错误:接口签名字段为【{0}】---生成的签名为【{1}】", notifyinfo.sign, signStr)); //验证失败,记录日志 ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】DaPay支付验证失败", notifyinfo.order), String.Format("参数为:order-->{0}&code-->{1}&mount-->{2}&msg-->{3}&time-->{4}", notifyinfo.order, notifyinfo.code, notifyinfo.mount, notifyinfo.msg, notifyinfo.time)); return(false); } }
/// <summary> /// 获取订单信息 /// </summary> /// <param name="orderIdStr">订单ID</param> public Order GetOrderInfo(string orderIdStr) { int orderId = YSWL.Common.Globals.SafeInt(orderIdStr, -1); if (orderId < 1) { return(null); } //返回订单信息 return(_orderManage.GetModel(orderId)); }
public static bool VerifyNotify(BZNotify notifyinfo) { if (String.IsNullOrWhiteSpace(notifyinfo.mch_id) || String.IsNullOrWhiteSpace(notifyinfo.sdpayno) || String.IsNullOrWhiteSpace(notifyinfo.order_no) || String.IsNullOrWhiteSpace(notifyinfo.paytype)) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【BZPay支付回调通知失败"), "参数错误"); return(false); } string signStr = StringHelper.GetMD5(String.Format("mch_id={0}&status={1}&sdpayno={2}&order_no={3}&money={4}&paytype={5}&{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey)); if (signStr == notifyinfo.sign) { if (notifyinfo.status == 1) { ColoPay.BLL.Pay.Order orderBll = new BLL.Pay.Order(); ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.order_no); if (orderInfo == null) { return(false); } if (orderInfo.PaymentStatus == 2) { return(true); } bool isSuccess = orderBll.CompleteOrder(orderInfo); if (isSuccess)//成功之后需要回调商家回调地址 { try { ColoPay.BLL.Pay.Enterprise.Notify(orderInfo); } catch (Exception ex) { ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】BZPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace); return(isSuccess); } } return(isSuccess); } else { return(false); } } else { //验证失败,记录日志 ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】BZPay支付验证失败", notifyinfo.order_no), String.Format("参数为:mch_id-->{0}&status-->{1}&sdpayno-->{2}&order_no-->{3}&money-->{4}&paytype-->{5}&apikey-->{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey)); return(false); } }
/// <summary> /// 验证请求是否合法 /// </summary> protected override bool VerifySendPayment(System.Web.HttpContext context) { #region 验证请求是否合法 string[] orderIds = YSWL.Payment.OrderProcessor.GetQueryString4OrderIds(context.Request); if (orderIds == null || orderIds.Length < 1) { return(false); } int orderId = YSWL.Common.Globals.SafeInt(orderIds[0], -1); if (orderId < -1) { return(false); } Model.Pay.Order orderInfo = _orderManage.GetModel(orderId); YSWL.Payment.Model.PaymentModeInfo paymentMode = YSWL.Payment.BLL.PaymentModeManage.GetPaymentModeById(orderInfo.PaymentTypeId); if (paymentMode == null) { Web.LogHelp.AddErrorLog(string.Format(MSG_ERRORLOG, orderId, -1), "非法操作订单", "Shop >> SendPaymentHandler >> Verification >> PaymentModeInfo Is NULL"); context.Response.Redirect("/"); return(false); } #endregion string basePath = "/"; string u = context.Request.ServerVariables["HTTP_USER_AGENT"]; string area = context.Request.QueryString["Area"]; if (!string.IsNullOrWhiteSpace(area)) { basePath = string.Format("/{0}/", area); } //向网关写入请求发起源的Area #pragma warning disable CS0612 // “SendPaymentHandlerBase<Order>.GatewayDatas”已过时 this.GatewayDatas.Add(area); #pragma warning restore CS0612 // “SendPaymentHandlerBase<Order>.GatewayDatas”已过时 #region 支付宝银联 if (paymentMode.Gateway == "alipaybank") { /** * 关于银行编码: * 如: 招商银行【CMB】、中国建设银行【CCB】、中国工商银行【ICBCB2C】 * 注意:优先使用B2C通道 * 混合渠道: https://doc.open.alipay.com/doc2/detail.htm?spm=0.0.0.0.Nz80L8&treeId=63&articleId=103763&docType=1 * 纯借记卡渠道: https://doc.open.alipay.com/doc2/detail.htm?spm=0.0.0.0.1NpxKf&treeId=63&articleId=103764&docType=1 **/ string bankCode = context.Request.QueryString["BankCode"]; if (!string.IsNullOrWhiteSpace(bankCode)) { //向网关写入用户选择的银行编码 #pragma warning disable CS0612 // “SendPaymentHandlerBase<Order>.GatewayDatas”已过时 this.GatewayDatas.Add(bankCode); #pragma warning restore CS0612 // “SendPaymentHandlerBase<Order>.GatewayDatas”已过时 } } #endregion //微信支付 向网关写入 APPID OPENID //if (paymentMode.Gateway.StartsWith("wechat")) //{ // string action = context.Request.QueryString["action"]; // //微信支付电脑端定向到 // if (action != "qr" && !u.ToLower().Contains("android") && !u.ToLower().Contains("mobile")) // { // context.Response.Redirect(MvcApplication.GetCurrentRoutePath(AreaRoute.Shop) + "PayWeChat/Pay/"+ orderId); // return false; // } // //微信支付app端定向 // if (string.IsNullOrWhiteSpace(action) && u.ToLower().Contains("ys56")) // { // context.Response.Redirect($"/pay/certification{orderId}/{area}?action=app"); // return false; // } // string weChatAppId = YSWL.WeChat.BLL.Core.Config.GetValueByCache("WeChat_AppId", -1, "AA"); // if (string.IsNullOrWhiteSpace(weChatAppId)) // { // context.Response.Clear(); // context.Response.Write("NO WECHAT_APPID > WECHAT APPID IS NULL!"); // return false; // } // this.GatewayDatas.Add(weChatAppId); // if (string.IsNullOrWhiteSpace(action) || action == "show") // { // #region 获取微信用户OpenId // //获取微信用户OpenId // string weChatOpenId = YSWL.WeChat.BLL.Core.Config.GetValueByCache("WeChat_OpenId", -1, "AA"); // string weChatAppSercet = YSWL.WeChat.BLL.Core.Config.GetValueByCache("WeChat_AppSercet", -1, "AA"); // if (string.IsNullOrWhiteSpace(weChatOpenId) || string.IsNullOrWhiteSpace(weChatAppSercet)) // { // context.Response.Clear(); // context.Response.Write("NO WECHATINFO > WECHAT WECHAT_OPENID OR WECHAT_APPSERCET IS NULL!"); // return false; // } // string authorizeCode = context.Request.QueryString["code"]; // if (string.IsNullOrWhiteSpace(authorizeCode)) // { // string authorizeUrl = // string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state={2}#wechat_redirect" // , weChatAppId, Common.Globals.UrlEncode(context.Request.Url.ToString()), "YS56BEN"); // context.Response.Redirect(authorizeUrl); // return false; // } // string userOpenId = YSWL.WeChat.BLL.Core.Utils.GetUserOpenId(weChatAppId, weChatAppSercet, authorizeCode); // if (string.IsNullOrWhiteSpace(userOpenId)) // { // context.Response.Clear(); // context.Response.Write("NO USEROPENID > WECHAT USEROPENID IS NULL!"); // return false; // } // this.GatewayDatas.Add(userOpenId); // #endregion // } //} if (u.ToLower().Contains("android") || u.ToLower().Contains("mobile")) //手机访问 { if (!paymentMode.DrivePath.Contains("|2|")) //不能手机支付 { context.Session[KEY_ORDERID] = orderInfo.OrderId.ToString(); context.Response.Redirect("/m/PayResult/MFail"); return(false); } } else//电脑访问 { if (!paymentMode.DrivePath.Contains("|1|")) //不能电脑支付 { context.Session[KEY_ORDERID] = orderInfo.OrderId.ToString(); context.Response.Redirect(MvcApplication.GetCurrentRoutePath(AreaRoute.Shop) + "PayResult/MFail"); return(false); } } return(true); }