public override Task <NotifyReturnModel> Notify(HttpRequest request) { NotifyReturnModel notifyReturn = new NotifyReturnModel(); string content = string.Empty; #region MyRegion long contentLen = request.ContentLength == null ? 0 : request.ContentLength.Value; if (contentLen > 0) { // 读取请求体中所有内容 System.IO.Stream stream = request.Body; request.Body.Position = 0; byte[] buffer = new byte[contentLen]; stream.Read(buffer, 0, buffer.Length); // 转化为字符串 content = System.Text.Encoding.UTF8.GetString(buffer); } #endregion //var body = request.Body; //using (StreamReader dRead = new StreamReader(body, Encoding.UTF8)) //{ // content = dRead.ReadToEnd(); //} hyNotify j = JsonConvert.DeserializeObject <hyNotify>(content); string krid = j.krid; string money = j.money; string order_sn = j.order_sn; string out_order_sn = j.out_order_sn; string status = j.status; data data = j.data; string kts = j.kts; string sign = j.sign; string signstr = string.Format("krid={0}&money={1}&order_sn={2}&out_order_sn={3}&status={4}&kts={5}", krid, money, order_sn, out_order_sn, status, kts); string _sign = PayHelper.Md5Hash4(signstr); _sign = PayHelper.Md5Hash4(_sign + this.MchKey); if (status == "success" && _sign.ToLower() == sign.ToLower()) { notifyReturn.ReturnMsg = "ok"; notifyReturn.IsPay = true; notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = true; } else { notifyReturn.ReturnMsg = "支付失败"; notifyReturn.IsPay = false; notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = false; } return(Task.FromResult <NotifyReturnModel>(notifyReturn)); }
public override Task <NotifyReturn> Notify(HttpRequest request) { NotifyReturn notifyReturn = new NotifyReturn(); var body = request.Body; string content = string.Empty; using (StreamReader dRead = new StreamReader(body, Encoding.UTF8)) { content = dRead.ReadToEnd(); } hyNotify j = JsonConvert.DeserializeObject <hyNotify>(content); string P_UserId = j.P_UserId; string P_OrderId = j.P_OrderId; string P_FaceValue = j.P_FaceValue; string P_Notic = j.P_Notic; string P_Return = j.P_Return; string P_ErrCode = j.P_ErrCode; string P_SuccTime = j.P_SuccTime; string P_PostKey = j.P_PostKey; string signstr = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", P_UserId, P_OrderId, P_FaceValue, P_Notic, P_Return, P_ErrCode, P_SuccTime, this.MchKey2); string _sign = PayHelper.MD5Hash2(signstr); if (P_Return == "1" && _sign.ToLower() == P_PostKey.ToLower()) { notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = true; } else { notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = false; } return(new Task <NotifyReturn>(() => notifyReturn)); }
public override Task <NotifyReturn> Notify(HttpRequest request) { NotifyReturn notifyReturn = new NotifyReturn(); var body = request.Body; string content = string.Empty; using (StreamReader dRead = new StreamReader(body, Encoding.UTF8)) { content = dRead.ReadToEnd(); } hyNotify j = JsonConvert.DeserializeObject <hyNotify>(content); string krid = j.krid; string money = j.money; string order_sn = j.order_sn; string out_order_sn = j.out_order_sn; string status = j.status; data data = j.data; string kts = j.kts; string sign = j.sign; string signstr = string.Format("krid={0}&money={1}&order_sn={2}&out_order_sn={3}&status={4}&kts={5}", krid, money, order_sn, out_order_sn, status, kts); string _sign = PayHelper.Md5Hash4(signstr); _sign = PayHelper.Md5Hash4(_sign + this.MchKey); if (status == "success" && _sign.ToLower() == sign.ToLower()) { notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = true; } else { notifyReturn.MchID = this.MchID; notifyReturn.IsCheck = false; } return(new Task <NotifyReturn>(() => notifyReturn)); }