申请退款
当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家账号上。
请求参数 | 类型 | 描述 |
---|---|---|
base_uri | string | 声明接入点https://apihk.mch.weixin.qq.com/ (香港接入) |
json | object | 声明请求的JSON 数据结构 |
mchid | string | 商户号 |
appid | string | APPID |
sp_mchid | string | 机构商户号 |
sub_mchid | string | 子商户号 |
sp_appid | string | 机构APPID |
sub_appid | string | 子商户APPID |
transaction_id | string | 微信订单号 |
out_trade_no | string | 商户订单号 |
out_refund_no | string | 商户退款单号 |
reason | string | 退款原因 |
notify_url | string | 退款通知地址 |
php
$instance->v3->global->refunds->postAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds')->postAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds']->postAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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->global->refunds->post([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds')->post([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds']->post([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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));
返回字典 | 类型 | 描述 |
---|---|---|
id | string | 微信支付退款订单号 |
out_refund_no | string | 商户退款单号 |
create_time | string | 退款创建时间 |
amount | object | 退款金额 |
refund | integer | 退款金额 |
currency | string | 退款币种 |
payer_refund | integer | 用户退款金额 |
payer_currency | string | 支付币种 |
exchange_rate | object | 汇率 |
type | string | 汇率类型 |
rate | integer | 汇率值 |
detail | object | 优惠退款详情 |
promotion_id | string | 券ID |
scope | string | 优惠范围 |
type | string | 优惠类型 |
amount | integer | 优惠券面额 |
refund_amount | integer | 优惠券退款额 |
currency | string | 货币类型 |
参阅 官方文档
查询所有退款
提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
请求参数 | 类型 | 描述 |
---|---|---|
base_uri | string | 声明接入点https://apihk.mch.weixin.qq.com/ (香港接入) |
query | object | 声明请求的查询参数 |
transaction_id | string | 微信支付订单号 |
out_trade_no | string | 商户订单号 |
mchid | string | 商户号 |
sub_mchid | string | 子商户号 |
sp_mchid | string | 机构商户号 |
offset | integer | 记录起始位置 |
count | integer | 每页笔数 |
php
$instance->v3->global->refunds->getAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds')->getAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds']->getAsync([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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->global->refunds->get([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds')->get([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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/global/refunds']->get([
'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
'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));
返回字典 | 类型 | 描述 |
---|---|---|
id | string | 微信支付交易订单号 |
mchid | string | 商户号 |
sub_mchid | string | 子商户号 |
sp_mchid | string | 机构商户号 |
out_trade_no | string | 商户原交易订单号 |
amount | object | 订单金额 |
total | integer | 订单金额 |
currency | string | 货币类型 |
payer_total | integer | 用户支付金额 |
payer_currency | string | 支付币种 |
data | object[] | 退款单列表 |
id | string | 微信退款单号 |
out_refund_no | string | 商户退款单号 |
channel | string | 退款渠道 |
recv_account | string | 退款入账账户 |
fund_source | string | 退款资金来源 |
success_time | string | 退款成功时间 |
create_time | string | 退款创建时间 |
status | string | 退款状态 |
amount | object | 退款金额 |
refund | integer | 退款金额 |
currency | string | 货币类型 |
payer_refund | integer | 用户退款金额 |
payer_currency | string | 支付币种 |
exchange_rate | object | 汇率 |
type | string | 汇率类型 |
rate | integer | 汇率值 |
refund_detail | object | 优惠退款详情 |
promotion_id | string | 券ID |
scope | string | 优惠范围 |
type | string | 优惠类型 |
amount | integer | 优惠券面额 |
refund_amount | integer | 优惠券退款额 |
currency | string | 货币类型 |
total_num | integer | 订单总退款次数 |
current_total_num | integer | 本次返回退款单数 |
参阅 官方文档