Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                logger.Info("------------------Esalse退款开始------------------------");
                logger.Info("请求参数:" + context.Request.RawUrl);
                string channelNo = context.Request["cid"];
                string orderNo   = context.Request["oid"];
                string orderFace = context.Request["fm"];
                string sucFace   = context.Request["rm"];
                string tsp       = context.Request["tsp"];
                string signStr   = context.Request["sign"];
                //校验参数
                if (string.IsNullOrEmpty(channelNo) || string.IsNullOrEmpty(orderNo) ||
                    string.IsNullOrEmpty(orderFace) || string.IsNullOrEmpty(sucFace) ||
                    string.IsNullOrEmpty(signStr))
                {
                    logger.Info("参数错误:必填参数为空,收到参数【" + context.Request.QueryString + "】");
                    context.Response.Write("Fail");
                    return;
                }
                ;

                logger.Info("-------------------签名校验开始---------------------------");

                string esKey     = ApiHelper.Get_es_key(channelNo);
                string originStr = string.Format("{0}{1}{2}{3}{4}{5}", channelNo, orderNo, orderFace, sucFace, tsp, esKey);
                logger.Info("es_key:" + esKey);
                string sign = SecurityCore.ToHex(SecurityCore.MD5(originStr, Encoding.GetEncoding("GBK")), true).ToLower();
                if (!sign.Equals(signStr, StringComparison.OrdinalIgnoreCase))
                {
                    logger.Info(string.Format("签名失败,签名原串:{0},签名:{1},源签名:{2}", originStr, sign, signStr));
                    context.Response.Write("Fail");
                    return;
                }

                logger.Info("-------------------保存退款申请开始-------------------------");

                bool rst = ApiHelper.Save18RefundApply(orderNo, decimal.Parse(sucFace), logger);
                context.Response.Write(rst ? "success" : "Fail");
                return;
            }
            catch (Exception ex)
            {
                logger.Info("异常:" + ex.Message, ex);
                logger.Fatal("异常:" + ex.Message, ex);
                context.Response.Write("Fail System Error");
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// 18Esalse回调签名校验
        /// </summary>
        /// <param name="obj">数据对象</param>
        /// <param name="key">签名Key</param>
        /// <param name="logger"></param>
        /// <returns></returns>
        public static bool EsalseNotifyCheckSign(dynamic obj, ILogger logger)
        {
            string es_key     = Get_es_key(obj.cid).Trim();
            string origin_str = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}", obj.sid, obj.ste, obj.cid, obj.pid, obj.oid, obj.pn, obj.tf, obj.fm, es_key);

            logger.Info("es_key:" + es_key);
            string sign = SecurityCore.ToHex(SecurityCore.MD5(origin_str, Encoding.GetEncoding("GBK")), true).ToLower();

            if (!sign.Equals(obj.sign, StringComparison.OrdinalIgnoreCase))
            {
                logger.Info(string.Format("签名失败,签名原串:{0},签名:{1},源签名:{2}", origin_str, sign, obj.sign));
                return(false);
            }
            return(true);
        }