Skip to content

关闭订单(微信支付订单号)

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

请求参数类型描述
base_uristring声明接入点https://apihk.mch.weixin.qq.com/(香港接入)
transaction_idstring微信支付订单号
jsonobject声明请求的JSON数据结构
mchidstring直连商户号
sub_mchidstring子商户号
sp_mchidstring机构商户号
php
$instance->v3->global->transactions->id->_transaction_id_->close->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '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/global/transactions/id/{transaction_id}/close')->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '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/global/transactions/id/{transaction_id}/close']->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '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->global->transactions->id->_transaction_id_->close->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '1217752501201407033233368018',
  'json' => [
    'mchid'     => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid'  => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
php
$response = $instance->chain('v3/global/transactions/id/{transaction_id}/close')->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '1217752501201407033233368018',
  'json' => [
    'mchid'     => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid'  => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
php
$response = $instance['v3/global/transactions/id/{transaction_id}/close']->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'transaction_id' => '1217752501201407033233368018',
  'json' => [
    'mchid'     => '1230000109',
    'sub_mchid' => '1230000109',
    'sp_mchid'  => '1230000109',
  ],
]);
print_r($response->getStatusCode() === 204);
返回字典类型描述
空字符串(无返回内容)

参阅 官方文档

Published on the GitHub by TheNorthMemory