Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        public HttpResponseMessage FhNotify([FromBody] FengHeNotify notifyinfo)
        {
            //YSWL.Log.LogHelper.AddInfoLog("qrpay/notify-->postdata", postdata);
            //QrNotify notifyinfo = JsonConvert.Import<QrNotify>(postdata);
            bool   isSuccess   = ColoPay.WebApi.PayApi.FengHe.VerifyNotify(notifyinfo);
            string responseStr = isSuccess ? "ok" : "fail";
            // HttpContext.Current.Response.Write(responseStr);
            HttpResponseMessage responseMessage = new HttpResponseMessage {
                Content = new StringContent(responseStr, Encoding.GetEncoding("UTF-8"), "text/plain")
            };

            return(responseMessage);
        }