Skip to content

退款申请

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

请求参数类型描述
jsonobject声明请求的JSON数据结构
individual_auth_idstring商品单个人收款方受理授权ID
sub_mchidstring二级商户号
sp_appidstring电商平台APPID
sub_appidstring二级商户APPID
combine_transaction_idstring交易单微信支付订单号
transaction_idstring微信订单号
out_trade_nostring商户订单号
out_refund_nostring商户退款单号
reasonstring退款原因
amountobject订单金额
refundinteger退款金额
fromobject[]退款出资账户及金额
accountstring出资账户类型
AVAILABLE | UNAVAILABLE 枚举值之一
amountnumber出资金额
totalinteger原订单金额
currencystring退款币种
notify_urlstring退款结果回调url
refund_accountstring退款出资商户
REFUND_SOURCE_SUB_MERCHANT | REFUND_SOURCE_PARTNER_ADVANCE 枚举值之一
funds_accountstring资金账户
AVAILABLE | UNSETTLED 枚举值之一
php
$instance->v3->ecommerce->refunds->apply->postAsync([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/ecommerce/refunds/apply')->postAsync([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/ecommerce/refunds/apply']->postAsync([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->ecommerce->refunds->apply->post([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/ecommerce/refunds/apply')->post([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/ecommerce/refunds/apply']->post([
  'json' => [
    'individual_auth_id'     => '1900000109',
    'sub_mchid'              => '1900000109',
    'sp_appid'               => 'wx8888888888888888',
    'sub_appid'              => 'wx8888888888888888',
    'combine_transaction_id' => '1217752501201407033233368018',
    'transaction_id'         => '1217752501201407033233368018',
    'out_trade_no'           => '1217752501201407033233368018',
    'out_refund_no'          => '1217752501201407033233368018',
    'reason'                 => '商品已售完',
    'amount'                 => [
      'refund'   => 888,
      'from'     => [[
        'account' => 'AVAILABLE',
        'amount'  => 444,
      ],],
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'notify_url'             => 'https://weixin.qq.com',
    'refund_account'         => 'REFUND_SOURCE_SUB_MERCHANT',
    'funds_account'          => 'AVAILABLE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
refund_idstring微信退款单号
out_refund_nostring商户退款单号
create_timestring退款创建时间
amountobject订单金额
refundinteger退款金额
fromobject[]退款出资账户及金额
accountstring出资账户类型
amountnumber出资金额
payer_refundinteger用户退款金额
discount_refundinteger优惠退款金额
currencystring退款币种
advancenumber垫付金额
promotion_detailobject[]优惠退款详情
promotion_idstring券ID
scopestring优惠范围
typestring优惠类型
amountinteger优惠券面额
refund_amountinteger优惠退款金额
refund_accountstring退款出资商户
REFUND_SOURCE_SUB_MERCHANT | REFUND_SOURCE_PARTNER_ADVANCE 枚举值之一

参阅 官方文档 官方文档 官方文档

Published on the GitHub by TheNorthMemory