Example #1
0
        /// <summary>
        /// 接收推送消息
        /// </summary>
        /// <param name="xml">请求消息</param>
        /// <param name="configData">configData</param>
        /// <returns>处理结果</returns>
        public static PushResult ReceivePushMessage(string xml, ConfigData configData)
        {
            PushRequest pushRequest = new PushRequest
            {
                Xml                   = xml,
                EncodingAESKey        = configData.EncodingAESKey,
                ComponentVerifyTicket = configData.component_verify_ticket_key,
                ValidityTime          = DateTime.Now.AddDays(1)
            };
            XElement   doc            = XElement.Parse(pushRequest.Xml);
            var        encry          = doc.Element("Encrypt").GetString();
            string     encodingAESKey = pushRequest.EncodingAESKey;
            string     appid          = string.Empty;
            var        xmlContent     = Cryptography.AES_decrypt(encry, encodingAESKey, ref appid);
            PushResult pushResult     = TenpayUtil.ConvertToPushRequest(xmlContent);

            if (pushResult.InfoType == "component_verify_ticket")
            {
                // 写入缓存
                //Redis.SetRedis(pushRequest.ComponentVerifyTicket, pushResult.ComponentVerifyTicket, pushRequest.ValidityTime);
                pushResult.IsSucceed = !string.IsNullOrEmpty(pushRequest.ComponentVerifyTicket);
            }
            else
            {
                pushResult.IsSucceed = false;
                pushResult.Message   = $"暂不处理类型{pushResult.InfoType}";
            }
            return(pushResult);
        }