1.4 关闭订单接口
<h2>关闭订单接口</h2>
<p><strong>接口地址</strong>:<code>/pay/api/1.0/closeOrder</code></p>
<p><strong>请求方式</strong>:<code>POST</code></p>
<p><strong>请求数据类型</strong>:<code>application/json</code></p>
<p><strong>响应数据类型</strong>:<code>application/json</code></p>
<p><strong>接口描述</strong>:</p>
<p>本接口支持微信、支付宝各种下单类交易(wayCode)的关闭。<strong><code>只有未支付的订单才能发起关闭</code></strong>。</p>
<p>注意:订单生成后不能马上调用关单接口,最短调用时间间隔为<code>5</code>分钟。</p>
<p><strong><em>支付宝主扫调用关单接口</em></strong></p>
<p>如果未扫码直接关单的话会关单不成功的,一定要<code>扫码后未支付</code>才能调用关单接口。支付宝动态码的交易,下单成功(返回动态码链接只是对应支付宝的预下单,并不是下单),因此在查询、关单的时候支付宝会返回“交易不存在”, 用户扫码以后才会去下单。</p>
<p>即,调用了统一下单接口后,产生的qrCode二维码链接,必须扫一下那个链接,支付宝那边才算生成了订单,不付款,才能调用关单接口。</p>
<p><strong><em>微信主扫调用关单接口</em></strong></p>
<p>微信主扫,调用了统一下单接口,就可以直接关单,不需要去扫qrCode产生的二维码链接</p>
<p><strong>请求示例</strong>:</p>
<pre><code class="language-javascript">{
&quot;appId&quot;: &quot;MCH_A698612520&quot;,
&quot;mchNo&quot;: &quot;MCH_I293975931&quot;,
&quot;mchOrderNo&quot;: &quot;202303271529422244655558&quot;,
&quot;sign&quot;: &quot;d374750034a8f9e74a86301decaa7d56&quot;,
&quot;subAppid&quot;: &quot;&quot;,
&quot;termId&quot;: &quot;12345678&quot;,
&quot;wayCode&quot;: &quot;WECHAT&quot;
}</code></pre>
<p><strong>请求参数</strong>:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数说明</th>
<th>请求类型</th>
<th>是否必须</th>
<th>数据类型</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>req</td>
<td>req</td>
<td>body</td>
<td>关闭订单请求实体类</td>
<td>关闭订单请求实体类</td>
</tr>
<tr>
<td>&emsp;&emsp;version</td>
<td>版本号</td>
<td>false</td>
<td>string</td>
<td>默认1.0</td>
</tr>
<tr>
<td>&emsp;&emsp;sign</td>
<td>签名值</td>
<td><code>true</code></td>
<td>string</td>
<td>详见签名生成算法</td>
</tr>
<tr>
<td>&emsp;&emsp;termId</td>
<td>终端id</td>
<td><code>true</code></td>
<td>string</td>
<td>没有真实终端号统一填88888888</td>
</tr>
<tr>
<td>&emsp;&emsp;mchNo</td>
<td>商户号</td>
<td><code>true</code></td>
<td>string</td>
<td>招联分配给二级商户的商户号</td>
</tr>
<tr>
<td>&emsp;&emsp;appId</td>
<td>应用id</td>
<td><code>true</code></td>
<td>string</td>
<td>商户配置的应用id</td>
</tr>
<tr>
<td>&emsp;&emsp;mchOrderNo</td>
<td>商户订单号</td>
<td><code>true</code></td>
<td>string</td>
<td>商户订单号, 商户系统内部的订单号(5到30个字符、 只能包含字母数字下划线,区分大小写)</td>
</tr>
<tr>
<td>&emsp;&emsp;wayCode</td>
<td>支付方式</td>
<td>false</td>
<td>string</td>
<td>ALIPAY(统一下单、服务窗支付) WECHAT(统一下单、公众号支付、小程序支付)<br> WXAPP(微信 app)<br> WXH5(微信 h5))</td>
</tr>
<tr>
<td>&emsp;&emsp;subAppid</td>
<td>子商户公众号id</td>
<td>false</td>
<td>string</td>
</tr>
</tbody>
</table>
<p><strong>响应状态</strong>:</p>
<table>
<thead>
<tr>
<th>状态码</th>
<th>说明</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>OK</td>
<td>R«关闭订单返回实体类»</td>
</tr>
</tbody>
</table>
<p>>见[应答码表](<a href="https://www.showdoc.com.cn/jucaishangfu/9966099368299628">https://www.showdoc.com.cn/jucaishangfu/9966099368299628</a> "应答码表")</p>
<p><strong>响应参数</strong>:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数说明</th>
<th>类型</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>integer(int32)</td>
<td>integer(int32)</td>
</tr>
<tr>
<td>data</td>
<td>关闭订单返回实体类</td>
<td>关闭订单返回实体类</td>
</tr>
<tr>
<td>&emsp;&emsp;orgId</td>
<td>机构号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;mchNo</td>
<td>商户号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;mchOrderNo</td>
<td>商户订单号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;randomStr</td>
<td>随机字符串</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;termId</td>
<td>终端号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;wayCode</td>
<td>支付方式</td>
<td>string</td>
</tr>
<tr>
<td>msg</td>
<td>string</td>
</tr>
<tr>
<td>sign</td>
<td>string</td>
</tr>
</tbody>
</table>
<p><strong>响应示例</strong>:</p>
<pre><code class="language-javascript">{
&quot;code&quot;: 200,
&quot;msg&quot;: &quot;CLOSED&quot;,
&quot;data&quot;: {
&quot;returnCode&quot;: &quot;000000&quot;,
&quot;returnMsg&quot;: &quot;SUCCESS&quot;,
&quot;orgId&quot;: &quot;ISV_I238002400&quot;,
&quot;mchNo&quot;: &quot;MCH_I293975931&quot;,
&quot;mchOrderNo&quot;: &quot;2023032715455553865290&quot;,
&quot;randomStr&quot;: &quot;396TATUYWMODSBOPH2L93B4N52GM4IYK&quot;,
&quot;termId&quot;: &quot;&quot;,
&quot;wayCode&quot;: &quot;WECHAT&quot;
},
&quot;sign&quot;: &quot;d374750034a8f9e74a86301decaa7d56&quot;
}</code></pre>