Beispiel #1
0
        public CreateOrderResult CreateOrderAsync(CreateOrderParameter createOrderParameter)
        {
            string str;

            if (!this.ValidateParameter <CreateOrderParameter>(createOrderParameter, out str))
            {
                CreateOrderResult result1 = new CreateOrderResult();
                result1.ErrorMessage = str;
                return(result1);
            }
            UnifiedOrderRequest request = new UnifiedOrderRequest
            {
                AppId         = this.m_AppId,
                MerchantId    = createOrderParameter.MerchantId,
                DeviceInfo    = _DeviceInfo,
                NonceString   = WeChatSignHelper.CreateRandomString(),
                Body          = createOrderParameter.Body,
                Detail        = createOrderParameter.Detail,
                Attach        = createOrderParameter.Attach,
                OutTradeNo    = createOrderParameter.OutTradeNo,
                FeeType       = _OrderFeeType,
                TotalFee      = (int)(createOrderParameter.TotalFee * 100.0),
                SpbllCreateIP = createOrderParameter.IP,
                TimeStart     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                TimeExpire    = DateTime.Now.AddHours((double)_OrderExpireHour).ToString("yyyyMMddHHmmss"),
                NotifyUrl     = createOrderParameter.NotifyUrl,
                TradeType     = createOrderParameter.TradeType,
                ProductId     = createOrderParameter.ProductId,
                OpenId        = createOrderParameter.OpenId
            };
            UnifiedOrderResponse response = this.InvokeApiAsync <UnifiedOrderRequest, UnifiedOrderResponse>(_UnifiedorderUrl, request);

            if (!response.IsSuccess)
            {
                CreateOrderResult result3 = new CreateOrderResult();
                result3.ErrorCode    = response.ErrCode;
                result3.ErrorMessage = response.ReturnMsg;
                return(result3);
            }
            CreateOrderResult result2 = new CreateOrderResult();

            result2.IsSuccess = true;
            result2.CodeUrl   = response.CodeUrl;
            result2.PrepayId  = response.PrepayId;
            return(result2);
        }
Beispiel #2
0
        public CreateWxPayToUserResult CreateWxPayToUser(CreateWxPayToUserParameter createOrderParameter)
        {
            string str;

            if (!this.ValidateParameter <CreateWxPayToUserParameter>(createOrderParameter, out str))
            {
                CreateWxPayToUserResult result1 = new CreateWxPayToUserResult();
                result1.ErrorMessage = str;
                return(result1);
            }
            WxPayToUserRequest request = new WxPayToUserRequest
            {
                AppId         = this.m_AppId,
                MerchantId    = createOrderParameter.MerchantId,
                DeviceInfo    = _DeviceInfo,
                NonceString   = WeChatSignHelper.CreateRandomString(),
                OutTradeNo    = createOrderParameter.OutTradeNo,
                Amount        = (int)(createOrderParameter.Amount * 100.0),
                SpbllCreateIP = createOrderParameter.IP,
                Desc          = createOrderParameter.Desc,
                CheckName     = "NO_CHECK",
                ReUserName    = createOrderParameter.ReUserName,
                OpenId        = createOrderParameter.OpenId
            };

            if (!string.IsNullOrEmpty(request.ReUserName))
            {
                request.CheckName = "FORCE_CHECK";
            }
            WxPayToUserResponse response = this.InvokeApiWithCertificateAsync <WxPayToUserRequest, WxPayToUserResponse>(_WxPayToUser, request);

            if (response.IsSuccess)
            {
                CreateWxPayToUserResult result2 = new CreateWxPayToUserResult();
                result2.IsSuccess = true;
                return(result2);
            }
            CreateWxPayToUserResult result3 = new CreateWxPayToUserResult();

            result3.ErrorCode    = response.ErrCode;
            result3.ErrorMessage = response.ReturnMsg;
            return(result3);
        }
Beispiel #3
0
        public QueryOrderResult QueryOrderAsync(QueryOrderParameter queryOrderParameter)
        {
            string str;

            if (!this.ValidateParameter <QueryOrderParameter>(queryOrderParameter, out str))
            {
                QueryOrderResult result1 = new QueryOrderResult();
                result1.ErrorMessage = str;
                return(result1);
            }
            OrderQueryRequest request = new OrderQueryRequest
            {
                AppId       = this.m_AppId,
                MerchantId  = queryOrderParameter.MerchantId,
                NonceString = WeChatSignHelper.CreateRandomString(),
                OutTradeNo  = queryOrderParameter.OutTradeNo
            };
            OrderQueryResponse response = this.InvokeApiAsync <OrderQueryRequest, OrderQueryResponse>(_OrderQueryUrl, request);

            if (!response.IsSuccess)
            {
                QueryOrderResult result3 = new QueryOrderResult();
                result3.ErrorCode    = response.ErrCode;
                result3.ErrorMessage = response.ReturnMsg;
                return(result3);
            }
            QueryOrderResult result2 = new QueryOrderResult();

            result2.IsSuccess             = true;
            result2.EndTime               = response.TimeEnd;
            result2.OutTradeNo            = response.OutTradeNo;
            result2.TotalFee              = ((double)response.TotalFee.GetValueOrDefault()) / 100.0;
            result2.TradeState            = (TradeState)Enum.Parse(typeof(TradeState), response.TradeState, true);
            result2.TradeStateDescription = response.TradeStateDesc;
            result2.TransactionId         = response.TransactionId;
            result2.Bank = WeChatBankTypes.GetBank(response.BankType);
            return(result2);
        }