コード例 #1
0
        public override TResponse Execute <TModel, TResponse>(Request <TModel, TResponse> request)
        {
            if (request is OAuthRequest)
            {
                return(SubmitProcess.AuthExecute(_merchant, request, GatewayUrl));
            }

            return(SubmitProcess.Execute(_merchant, request, GatewayUrl));
        }
コード例 #2
0
        protected override async Task <bool> ValidateNotifyAsync()
        {
            base.NotifyResponse = await GatewayData.ToObjectAsync <NotifyResponse>(StringCase.Snake);

            base.NotifyResponse.Raw = GatewayData.Raw;

            if (NotifyResponse.ReturnCode != "SUCCESS")
            {
                throw new GatewayException("不是成功的返回码");
            }

            if (string.IsNullOrEmpty(NotifyResponse.ReqInfo))
            {
                NotifyResponse.Coupons = ConvertUtil.ToList <CouponResponse, object>(GatewayData, -1);
                if (NotifyResponse.Sign != SubmitProcess.BuildSign(GatewayData, _merchant.Key))
                {
                    throw new GatewayException("签名不一致");
                }
            }
            else
            {
                var tempNotify  = NotifyResponse;
                var key         = EncryptUtil.MD5(_merchant.Key).ToLower();
                var data        = EncryptUtil.AESDecrypt(NotifyResponse.ReqInfo, key);
                var gatewayData = new GatewayData();
                gatewayData.FromXml(data);
                base.NotifyResponse = await gatewayData.ToObjectAsync <NotifyResponse>(StringCase.Snake);

                GatewayData.Add(NotifyResponse, StringCase.Snake);

                NotifyResponse.AppId      = tempNotify.AppId;
                NotifyResponse.MchId      = tempNotify.MchId;
                NotifyResponse.NonceStr   = tempNotify.NonceStr;
                NotifyResponse.ReqInfo    = tempNotify.ReqInfo;
                NotifyResponse.ReturnCode = tempNotify.ReturnCode;
            }

            return(true);
        }