Ejemplo n.º 1
0
        public PayResult GetOrderPaidStatus(string xmlParamter)
        {
            WeiXinPayData responseData = new WeiXinPayData(xmlParamter);
            SortedDictionary <string, object> sortedDictionary = responseData.SortedDictionary;
            PayResult payResult = new PayResult();

            if (sortedDictionary.Count == 0)
            {
                return(payResult);
            }
            if (sortedDictionary.ContainsKey(Common.WeiXinPayInfo.Sign) == false)
            {
                return(payResult);
            }
            if (sortedDictionary.ContainsKey(Common.WeiXinPayInfo.TransactionId) == false)
            {
                return(payResult);
            }
            WeiXinPayData checkData = new WeiXinPayData();

            checkData.SetDictionaryValue(Common.WeiXinPayInfo.TransactionId, sortedDictionary[Common.WeiXinPayInfo.TransactionId]);
            checkData.SetDictionaryValue(Common.WeiXinPayInfo.Appid, WeiXinPayInfo.WeiXinPayAppId);
            checkData.SetDictionaryValue(Common.WeiXinPayInfo.MchId, WeiXinPayInfo.WeiXinPayMchid);
            checkData.SetDictionaryValue(Common.WeiXinPayInfo.NonceStr, DateTime.Now.Ticks);
            checkData.SetDictionaryValue(Common.WeiXinPayInfo.SignType, "MD5");
            checkData.SetDictionaryValue(Common.WeiXinPayInfo.Sign, checkData.MakeSign());
            string responseXmlPostRequest = _iWebUtilService.PostRequest(
                WeiXinPayInfo.WeiXinPayServerUrl,
                checkData.ToXml());
            WeiXinPayData response   = new WeiXinPayData(responseXmlPostRequest);
            string        returnCode = response.GetDictionaryValue(Common.WeiXinPayInfo.ReturnCode)?.ToString() ?? "";
            string        resultCode = response.GetDictionaryValue(Common.WeiXinPayInfo.ResultCode)?.ToString() ?? "";

            if (returnCode == "SUCCESS" && resultCode == "SUCCESS")
            {
                payResult.IsSuccess  = true;
                payResult.OrderRef   = response.GetDictionaryValue(Common.WeiXinPayInfo.OutTradeNo).ToString();
                payResult.GatewayRef = response.GetDictionaryValue(Common.WeiXinPayInfo.TransactionId).ToString();
            }
            return(payResult);
        }
Ejemplo n.º 2
0
        public void PostRequest_Should_Return_Correct_Number_Of_Records()
        {
            var result = _webUtilService.PostRequest("http://localost/api/user/1", "a");

            Assert.Equal("test", result);
        }