Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        public HttpResponseMessage QrNotify([FromBody] QrNotify notifyinfo)
        {
            //YSWL.Log.LogHelper.AddInfoLog("qrpay/notify-->postdata", postdata);
            //QrNotify notifyinfo = JsonConvert.Import<QrNotify>(postdata);
            bool   isSuccess   = ColoPay.WebApi.PayApi.QR_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);
        }