Skip to content

撤销订单(商户订单号)

支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。

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

参阅 官方文档

Published on the GitHub by TheNorthMemory