Skip to content

撤销订单

支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。调用支付接口后请勿立即调用撤销订单API,建议支付后至少15s后再调用撤销订单接口。

请求参数类型描述
securitytrue声明加载商户API证书
xmlobject声明请求的XML数据结构
appidstring公众账号ID
sub_appidstring子商户公众账号ID
mch_idstring商户号
sub_mch_idstring子商户号
transaction_idstring微信订单号
out_trade_nostring商户订单号
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
php
$instance->v2->secapi->pay->facepayreverse->postAsync([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/secapi/pay/facepayreverse')->postAsync([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/secapi/pay/facepayreverse']->postAsync([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->secapi->pay->facepayreverse->post([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/secapi/pay/facepayreverse')->post([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/secapi/pay/facepayreverse']->post([
  'security' => true,
  'xml' => [
    'appid'          => 'wx8888888888888888',
    'sub_appid'      => 'wx8888888888888888',
    'mch_id'         => '1900000109',
    'sub_mch_id'     => '1900000100',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no'   => '1217752501201407033233368018',
    'sign_type'      => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号ID
sub_appidstring子商户公众账号ID
mch_idstring商户号
sub_mch_idstring子商户号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误描述
recallstring是否重调
Y | N 枚举值之一

参阅 官方人脸支付文档

Published on the GitHub by TheNorthMemory