/// <summary> /// 订单查询 /// 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。 /// 需要调用查询接口的情况: /// ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知; /// ◆ 调用支付接口后,返回系统错误或未知交易状态情况; /// ◆ 调用刷卡支付API,返回USERPAYING的状态; /// ◆ 调用关单或撤销接口API之前,需确认支付状态; /// </summary> /// <param name="input"></param> /// <returns></returns> public OrderQueryOutput OrderQuery(OrderQueryInput input) { var url = "https://api.mch.weixin.qq.com/pay/orderquery"; //检测必填参数 if (string.IsNullOrWhiteSpace(input.TransactionId) && string.IsNullOrWhiteSpace(input.OutTradeNo)) { throw new WeChatPayException("订单查询接口中,out_trade_no、transaction_id至少填一个!"); } var config = GetConfig(); var req = new OrderQueryRequest { AppId = config.PayAppId, MchId = config.MchId, NonceStr = weChatPayHelper.GetNoncestr(), OutTradeNo = input.OutTradeNo, TransactionId = input.TransactionId, SignType = "MD5" }; req.Sign = CreateSign(req); return(weChatPayHelper.PostXML <OrderQueryOutput>(url, req)); }
/// <summary> /// 订单查询 /// </summary> /// <param name="input">查询数据</param> /// <returns></returns> public async Task <AlipayTradeQueryResponse> Query(OrderQueryInput input) { return(await this.Query(input.Data)); }