Skip to content

申请退款

当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家账号上。

请求参数类型描述
base_uristring声明接入点https://api.mch.weixin.qq.com/hk/(国内接入)
jsonobject声明请求的JSON数据结构
mchidstring商户号
appidstringAPPID
sp_mchidstring机构商户号
sub_mchidstring子商户号
sp_appidstring机构APPID
sub_appidstring子商户APPID
transaction_idstring微信订单号
out_trade_nostring商户订单号
out_refund_nostring商户退款单号
reasonstring退款原因
notify_urlstring退款通知地址
php
$instance->v3->refunds->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/refunds')->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/refunds']->postAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->refunds->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/refunds')->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/refunds']->post([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'json' => [
    'mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sp_mchid' => '1900000100',
    'sub_mchid' => '1900000109',
    'sp_appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888888',
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'out_refund_no' => '1217752501201407033233368018',
    'reason' => '商品已售完',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
idstring微信支付退款订单号
out_refund_nostring商户退款单号
create_timestring退款创建时间
amountobject退款金额
refundinteger退款金额
currencystring退款币种
payer_refundinteger用户退款金额
payer_currencystring支付币种
exchange_rateobject汇率
typestring汇率类型
rateinteger汇率值
detailobject优惠退款详情
promotion_idstring券ID
scopestring优惠范围
typestring优惠类型
amountinteger优惠券面额
refund_amountinteger优惠券退款额
currencystring货币类型

参阅 官方文档

查询所有退款

提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。

请求参数类型描述
base_uristring声明接入点https://api.mch.weixin.qq.com/hk/(国内接入)
queryobject声明请求的查询参数
transaction_idstring微信支付订单号
out_trade_nostring商户订单号
mchidstring商户号
sub_mchidstring子商户号
sp_mchidstring机构商户号
offsetinteger记录起始位置
countinteger每页笔数
php
$instance->v3->refunds->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/refunds')->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/refunds']->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->refunds->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/refunds')->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/refunds']->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'query' => [
    'transaction_id' => '1217752501201407033233368018',
    'out_trade_no' => '',
    'mchid' => '1900000109',
    'sub_mchid' => '1900000109',
    'sp_mchid' => '1900000100',
    'offset' => 0,
    'count' => 10,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
idstring微信支付交易订单号
mchidstring商户号
sub_mchidstring子商户号
sp_mchidstring机构商户号
out_trade_nostring商户原交易订单号
amountobject订单金额
totalinteger订单金额
currencystring货币类型
payer_totalinteger用户支付金额
payer_currencystring支付币种
dataobject[]退款单列表
idstring微信退款单号
out_refund_nostring商户退款单号
channelstring退款渠道
recv_accountstring退款入账账户
fund_sourcestring退款资金来源
success_timestring退款成功时间
create_timestring退款创建时间
statusstring退款状态
amountobject退款金额
refundinteger退款金额
currencystring货币类型
payer_refundinteger用户退款金额
payer_currencystring支付币种
exchange_rateobject汇率
typestring汇率类型
rateinteger汇率值
refund_detailobject优惠退款详情
promotion_idstring券ID
scopestring优惠范围
typestring优惠类型
amountinteger优惠券面额
refund_amountinteger优惠券退款额
currencystring货币类型
total_numinteger订单总退款次数
current_total_numinteger本次返回退款单数

参阅 官方文档

Published on the GitHub by TheNorthMemory