# 微信相关开发

## 3.1 查询订单

该接口提供所有微信支付订单的查询，商户可以通过查询订单接口主动查询订单状态，完成下一步的业务逻辑。

需要调用查询接口的情况：

◆ 当商户后台、网络、服务器等出现异常，商户系统最终未接收到支付通知；

◆ 调用支付接口后，返回系统错误或未知交易状态情况；

◆ 调用被扫支付API，返回USERPAYING的状态；

◆ 调用关单或撤销接口API之前，需确认支付状态；

接口地址：<https://api.mch.weixin.qq.com/pay/orderquery>

## 3.2 关闭订单

以下情况需要调用关单接口：

1.商户订单支付失败需要生成新单号重新发起支付，要对原订单号调用关单，避免重复支付；

2.系统下单后，用户支付超时，系统退出不再受理，避免用户继续，请调用关单接口。

注意：订单生成后不能马上调用关单接口，最短调用时间间隔为5分钟。

接口地址：<https://api.mch.weixin.qq.com/pay/closeorder>

是否需要证书：不需要。

## 3.3 统一下单

## 3.4撤销订单

文档地址：<https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9\\_11\\&index=3>

* 应用场景：
* 支付交易返回失败或支付系统超时，调用该接口撤销交易。如果此订单用户支付失败，微信支付系统会将此订单关闭；如果用户支付成功，微信支付系统会将此订单资金退还给用户。
* 注意：7天以内的交易单可调用撤销，其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】，没有明确的支付结果再调用【撤销订单API】。
* 调用支付接口后请勿立即调用撤销订单API，建议支付后至少15s后再调用撤销订单接口。
* 接口链接 ：<https://api.mch.weixin.qq.com/secapi/pay/reverse>
* 是否需要证书：请求需要双向证书。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qiangrens-organization.gitbook.io/qkd90/kai-fa-kuang-jia-he-gong-ju/wei-xin-xiang-guan-kai-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
