Esempio n. 1
0
        public HttpResponseMessage Notify([FromBody] BZNotify notifyinfo)
        {
            bool   isSuccess   = ColoPay.WebApi.PayApi.BZ_Pay.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);
        }
Esempio n. 2
0
        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);
            }
        }