public override Task <QueryOrderReply> QueryOrder(QueryOrderRequest request, ServerCallContext context) { var orderId = request.OrderId; var order = _orders.GetValueOrDefault(orderId); if (order == null) { return(Task.FromResult(new QueryOrderReply() { Success = false, Message = $"can't find order {orderId}" })); } return(Task.FromResult(new QueryOrderReply() { Success = true, Detail = new OrderDetail() { OrderId = order.OrderId, CustomerName = order.CustomerName, GoodsName = order.GoodsName, Amount = order.Amount, State = Convert.ToInt32(order.State) } })); }
private void btnQueryOrder_Click(object sender, EventArgs e) { //创建支付通道 UnionPayChannel channel = new UnionPayChannel() { CertificateFilePassword = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePassword"] , CertificateFilePath = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePath"] , MerchantID = ConfigurationManager.AppSettings["WAPMerchantID"] , PacketEncryptKey = "654321" }; //查询订单 QueryOrderRequest req = new QueryOrderRequest(); req.SendTime = DateTime.Now; req.SendSeqID = Guid.NewGuid().ToString("N"); req.TransType = WapTransTypes.PreAuthorization; req.MerchantID = channel.MerchantID; req.MerchantOrderID = this.Session["MerchantOrderID"] as string; req.MerchantOrderTime = this.Session["MerchantOrderTime"] as DateTime?; // try { var rsp = WapGateway.QueryOrder(channel, req); this.txtOrderInfo.Text = rsp.ToString(); } catch (Exception ex) { this.txtOrderInfo.Text = "执行失败:" + Environment.NewLine + ex.Message; } }
/// <summary> /// 微信支付订单查询 /// </summary> /// <param name="out_trade_no"></param> /// <returns></returns> public ApiResult <QueryOrderResponse> QueryOrder(String out_trade_no) { var request = new QueryOrderRequest(); request.out_trade_no = out_trade_no; return(GetResponseFromAsyncTask(QueryOrderAsync(request))); }
/// <summary> /// 获取订单 /// </summary> /// <param name="parameter">参数</param> /// <returns></returns> /// <exception cref="ArgumentNullException">传入的参数是null</exception> /// <exception cref="WeChatPayException">调用微信接口失败时返回的错误信息</exception> public async Task <QueryOrderResponse> GetOrderAsync(QueryOrderRequest parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } parameter.AppId = _appId; parameter.MchId = _mchId; parameter.Sign = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey); string url = "https://api.mch.weixin.qq.com/pay/orderquery"; string body = XmlSerializeHelper.ObjectToXmlString(parameter); string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(), body, "xml/text"); XmlDocument xml = new XmlDocument(); xml.LoadXml(result); var response = XmlSerializeHelper.StringToObject <QueryOrderResponse>(result); Check(response); response.CouponType = Helper.FormatXmlField("coupon_type", xml); response.CouponId = Helper.FormatXmlField("coupon_refund_id", xml); response.SingleCouponAmount = Helper.FormatXmlField("coupon_refund_fee", xml) .Select(x => Convert.ToInt32(x)).ToArray(); return(response); }
public async Task <OrderCollectionResponse> QueryOrderAsync(QueryOrderRequest queryOrderRequest) { if (queryOrderRequest == null) { throw new RequestNullException(); } IQueryable <OrderModel> orderModels = _dataContext.OrderModels.AsQueryable(); if (queryOrderRequest.OrderId.HasValue) { orderModels = orderModels.Where(m => m.Id == queryOrderRequest.OrderId); } int totalCount = await orderModels.CountAsync(); List <OrderModel> orderModelList = orderModels.Skip(queryOrderRequest.Offset) .Take(queryOrderRequest.Take) .ToList(); if (!orderModelList.Any()) { throw new OrderNotFoundException(); } List <OrderResponse> orderResponseList = orderModelList.Select(x => x.ToOrderResponse()) .ToList(); return(new OrderCollectionResponse(totalCount, orderResponseList)); }
public async Task <IActionResult> OrderStatus(QueryOrderRequest model) { var order = await context.Orders.AsNoTracking() .SingleOrDefaultAsync(o => o.OrderId == model.OrderId && o.AppId == model.AppId); if (order != null) { var result = new QueryOrderResult() { Result = "SUCCESS", Message = "OK", AppId = order.AppId, OrderId = order.OrderId, NonceStr = this.signatureService.GenerateNonceStr(), Status = Enum.GetName(typeof(OrderStatus), order.Status), LastUpdated = order.LastUpdated.ToUniversalTime().ToString("yyyyMMddHHmmss") }; result.Signature = this.signatureService.CalculateSignature(result.AsEnumerable(), order.AppId); return(Json(result)); } else { var result = new QueryOrderResult() { Result = "FAIL", Message = "OrderNotFound", NonceStr = Guid.NewGuid().ToString().Replace("-", ""), AppId = model.AppId }; result.Signature = this.signatureService.CalculateSignature(result.AsEnumerable(), model.AppId); return(Json(result)); } }
/// <summary> /// Queries an order based on the provided request /// </summary> /// <param name="request">The <see cref="QueryOrderRequest"/> that is used to define the order</param> /// <param name="receiveWindow"></param> /// <returns></returns> public async Task <OrderResponse> QueryOrder(QueryOrderRequest request, int receiveWindow = -1) { receiveWindow = SetReceiveWindow(receiveWindow); Guard.AgainstNull(request.Symbol); return(await _apiProcessor.ProcessGetRequest <OrderResponse>(Endpoints.Account.QueryOrder(request), receiveWindow)); }
public OrderList List(long pageIndex, DateTime send_start, DateTime send_end, ref string token) { QueryOrderRequest request = new QueryOrderRequest(); request.access_token = token; request.page_curr = pageIndex; request.send_time_start = send_start.ToString(Common.DateTimeFormat); request.send_time_end = send_end.ToString(Common.DateTimeFormat); var response = SDKFactory.Executor.Execute(request); response = Common.CheckResponseError<OrderList, CommonResponse<OrderList>>(request, response, ref token); return response.data; }
public async Task GetOrder() { string nonce = Caster.WeChat.Common.Helper.GetNonceStr(32); string orderCode = "1582626752709"; var parameter = new QueryOrderRequest { OrderCode = orderCode, Nonce = nonce }; var result = await _web.PayService.GetOrderAsync(parameter); Assert.True( result.ReturnCode == WeChatConstant.PaySuccess && result.ResultCode == WeChatConstant.PaySuccess, "result.ReturnCode ==WeChatConstant.PaySuccess && result.ResultCode ==WeChatConstant.PaySuccess"); }
public async Task <IActionResult> GetOrders([FromQuery] GetOrdersRequest getOrdersRequest) { QueryOrderRequest queryOrderRequest = getOrdersRequest != null ? new QueryOrderRequest(getOrdersRequest.Offset, getOrdersRequest.Take ) { OrderId = getOrdersRequest.OrderId } : null; OrderCollectionResponse orderCollectionResponse = await _orderService.QueryOrderAsync(queryOrderRequest); return(StatusCode((int)HttpStatusCode.OK, orderCollectionResponse)); }
/// <summary> /// 根据订单号,或者用户Id,查询支付订单状态 /// </summary> /// <param name="req"><see cref="QueryOrderRequest"/></param> /// <returns><see cref="QueryOrderResponse"/></returns> public async Task <QueryOrderResponse> QueryOrder(QueryOrderRequest req) { JsonResponseModel <QueryOrderResponse> rsp = null; try { var strResp = await this.InternalRequest(req, "QueryOrder"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <QueryOrderResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public void TestQueryOrder() { //先发预订单请求 UnionPayChannel channel = new UnionPayChannel() { CertificateFilePassword = "******", CertificateFilePath = "D:/cer/630056832596.pfx", MerchantID = "630056832596", PacketEncryptKey = "654321" }; PreOrderRequest req = new PreOrderRequest(); req.SendTime = DateTime.Now; req.SendSeqID = Guid.NewGuid().ToString("N"); req.FrontUrl = "http://www.jitmarketing.cn:8090/TranNotification.ashx"; req.MerchantOrderDesc = "呵呵"; req.Misc = string.Empty; //req.GatewayType = GatewayTypes.WAP; req.TransTimeout = DateTime.Now.AddHours(1); req.BackUrl = "http://www.jitmarketing.cn:8090/TranNotification.ashx"; req.MerchantOrderCurrency = Currencys.RMB; req.MerchantOrderAmt = 1; req.MerchantID = "630056832596"; req.MerchantOrderTime = DateTime.Now.AddMinutes(-5); req.MerchantOrderID = Guid.NewGuid().ToString("N"); req.MerchantUserID = string.Empty; req.MobileNum = "15388157741"; req.CarNum = string.Empty; var rsp = WapGateway.PreOrder(channel, req); Assert.IsTrue(rsp.IsSuccess); //跳转到支付平台页面 WebClient wc = new WebClient(); string strResponse = wc.UploadString(rsp.RedirectURL, string.Empty); //在查询 QueryOrderRequest req2 = new QueryOrderRequest(); req2.SendTime = DateTime.Now; req2.SendSeqID = Guid.NewGuid().ToString("N"); req2.TransType = WapTransTypes.PreAuthorization; req2.MerchantID = "630056832596"; req2.MerchantOrderID = req.MerchantOrderID; req2.MerchantOrderTime = req.MerchantOrderTime; var rsp2 = WapGateway.QueryOrder(channel, req2); Assert.IsTrue(rsp2.IsSuccess); }
/// <summary> /// 微信支付订单查询 /// </summary> public ApiResult <QueryOrderResponse> QueryOrder(QueryOrderRequest request) { if (request == null) { return(new ApiResult <QueryOrderResponse>() { message = "require parameters" }); } else if (string.IsNullOrEmpty(request.transaction_id) && string.IsNullOrEmpty(request.out_trade_no)) { return(new ApiResult <QueryOrderResponse>() { message = "missing transaction_id or out_trade_no" }); } return(GetResponseFromAsyncTask(QueryOrderAsync(request))); }
/// <summary> /// 根据订单号(微信订单号、商户订单号二选一,优先微信订单号)查询订单信息 /// 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2 /// </summary> /// <param name="orderNumber">订单号码,支持微信订单号与商户订单号,优先微信订单号</param> /// <param name="nonceStr">随机字符串,默认null,自动生成</param> /// <param name="orderNoType">订单号类型,默认微信订单号</param> /// <param name="signType">签名类型(默认MD5)</param> public async Task <QueryOrderResponse> QueryOrder(string orderNumber, string nonceStr = null, OrderNumberType orderNoType = OrderNumberType.WechatOrderNumber, SignType signType = SignType.MD5) { var queryOrderReq = new QueryOrderRequest() { NonceStr = nonceStr ?? RandomHelper.GenerateNonceStr(), SignType = signType }; if (orderNoType == OrderNumberType.MerchantOrderNumber) { queryOrderReq.OutTradeNo = orderNumber; } else { queryOrderReq.TransactionId = orderNumber; } return(await WechatPayHelper.QueryOrder(PAY_BASE_INFO, queryOrderReq)); }
public static BinanceEndpointData QueryOrder(QueryOrderRequest request) { var queryString = GenerateQueryStringFromData(request); return(new BinanceEndpointData(new Uri($"{APIPrefix}/{ApiVersion}/order?{queryString}"), EndpointSecurityType.Signed)); }
/// <summary> /// 查询订单详情 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <QueryOrderResponse> QueryOrder(QueryOrderRequest request) { return(await new QueryOrderExecutor().Client(this).Execute <QueryOrderResponse, QueryOrderResult, QueryOrderRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 查询订单详情 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public QueryOrderResponse QueryOrder(QueryOrderRequest request) { return(new QueryOrderExecutor().Client(this).Execute <QueryOrderResponse, QueryOrderResult, QueryOrderRequest>(request)); }
/// <summary> /// 微信支付订单查询 的异步形式。 /// </summary> /// <param name="request"></param> /// <returns></returns> public Task <ApiResult <QueryOrderResponse> > QueryOrderAsync(QueryOrderRequest request) { return(CallAsync <QueryOrderRequest, QueryOrderResponse>("queryorder", request, System.Net.Http.HttpMethod.Get)); }
/// <summary> /// 查询订单 /// <remarks> /// <para>商户平台 -> 支付平台</para> /// </remarks> /// </summary> /// <param name="pChannel">调用支付接口的基本设置信息</param> /// <param name="pRequest">订单查询请求</param> /// <returns></returns> public static QueryOrderResponse QueryOrder(UnionPayChannel pChannel, QueryOrderRequest pRequest) { return(IVRGateway.CallAPI <QueryOrderRequest, QueryOrderResponse>(pChannel, pRequest)); }
public static async Task <QueryOrderResponse> QueryOrder(WechatPayBaseInfo payBaseInfo, QueryOrderRequest req) { var payData = new WechatPayData(); payData.SetStringValue("appid", payBaseInfo.AppId); payData.SetStringValue("mch_id", payBaseInfo.MchId); if (!string.IsNullOrEmpty(req.TransactionId)) { payData.SetStringValue("transaction_id", req.TransactionId); } else { payData.SetStringValue("out_trade_no", req.OutTradeNo); } payData.SetStringValue("nonce_str", req.NonceStr); payData.SetStringValue("sign_type", req.SignType == Enums.SignType.MD5 ? "MD5" : "HMAC-SHA256"); var sign = SignatureHelper.CalcSignature(payData.ToUrlParams(), payBaseInfo.Key, req.SignType); payData.SetStringValue("sign", sign); var orderQueryRes = await HttpClientHelper.Post <QueryOrderResponse>("https://api.mch.weixin.qq.com/pay/orderquery", payData.ToXml()); return(orderQueryRes); }