Skip to content

关闭订单

以下情况需要调用关单接口:商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。**注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。**

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring公众账号ID
mch_idstring商户号
out_trade_nostring商户订单号
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
php
$instance->v2->pay->closeorder->postAsync([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    '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/pay/closeorder')->postAsync([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    '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/pay/closeorder']->postAsync([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    '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->pay->closeorder->post([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    'out_trade_no' => '1217752501201407033233368018',
    'sign_type'    => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/pay/closeorder')->post([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    'out_trade_no' => '1217752501201407033233368018',
    'sign_type'    => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/pay/closeorder']->post([
  'xml' => [
    'appid'        => 'wx8888888888888888',
    'mch_id'       => '1900000109',
    'out_trade_no' => '1217752501201407033233368018',
    'sign_type'    => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号ID
mch_idstring商户号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
result_msgstring业务结果描述
err_codestring错误代码
err_code_desstring错误代码描述

参阅 官方JSAPI文档 官方NATIVE文档 官方APP文档 官方H5文档 官方小程序支付文档

Published on the GitHub by TheNorthMemory