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); } }
public HttpResponseMessage DaNotify([FromBody] DaNotify notifyinfo) { bool isSuccess = ColoPay.WebApi.PayApi.DaDaBank.VerifyNotify(notifyinfo); string responseStr = isSuccess ? "success" : "fail"; // HttpContext.Current.Response.Write(responseStr); HttpResponseMessage responseMessage = new HttpResponseMessage { Content = new StringContent(responseStr, Encoding.GetEncoding("UTF-8"), "text/plain") }; return(responseMessage); }