Skip to content

关闭订单(商户订单号)

以下情况需要调用关单接口:商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。

请求参数类型描述
base_uristring声明接入点https://api.mch.weixin.qq.com/hk/(国内接入)
out_trade_nostring商户订单号
jsonobject声明请求的JSON数据结构
mchidstring直连商户号
sub_mchidstring子商户号
sp_mchidstring机构商户号
php
$instance->v3->transactions->outTradeNo->_out_trade_no_->close->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 204);
})
->wait();
php
$instance->chain('v3/transactions/out-trade-no/{out_trade_no}/close')->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 204);
})
->wait();
php
$instance['v3/transactions/out-trade-no/{out_trade_no}/close']->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 204);
})
->wait();
php
$response = $instance->v3->transactions->outTradeNo->_out_trade_no_->close->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
php
$response = $instance->chain('v3/transactions/out-trade-no/{out_trade_no}/close')->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
php
$response = $instance['v3/transactions/out-trade-no/{out_trade_no}/close']->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'out_trade_no' => '1217752501201407033233368018',
  'json' => [
    'mchid' => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid' => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
返回字典类型描述
空字符串(无返回内容)

参阅 官方文档

Published on the GitHub by TheNorthMemory