Skip to content

申请退款

一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号

请求参数类型描述
securitytrue声明加载商户API证书
xmlobject声明请求的XML数据结构
appidstring公众账号ID
sub_appidstring子商户公众账号ID
mch_idstring商户号
sub_mch_idstring子商户号
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
transaction_idstring微信订单号
out_trade_nostring商户订单号
out_refund_nostring商户退款单号
total_feeinteger订单金额
refund_feeinteger退款金额
refund_fee_typestring退款货币种类
refund_descstring退款原因
refund_accountstring退款资金来源
notify_urlstring退款结果通知url
php
$instance->v2->secapi->pay->refund->postAsync([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/secapi/pay/refund')->postAsync([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/secapi/pay/refund']->postAsync([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->secapi->pay->refund->post([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/secapi/pay/refund')->post([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/secapi/pay/refund']->post([
  'security' => true,
  'xml' => [
    'appid'           => 'wx8888888888888888',
    'sub_appid'       => 'wx8888888888888888',
    'mch_id'          => '1900000109',
    'sub_mch_id'      => '1900000109',
    'sign_type'       => 'HMAC-SHA256',
    'transaction_id'  => '1217752501201407033233368018',
    'out_trade_no'    => '1217752501201407033233368018',
    'out_refund_no'   => '1217752501201407033233368018',
    'total_fee'       => '100',
    'refund_fee'      => '100',
    'refund_fee_type' => 'CNY',
    'refund_desc'     => '商品已售完',
    'refund_account'  => 'REFUND_SOURCE_RECHARGE_FUNDS',
    'notify_url'      => 'https://weixin.qq.com/notify/',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误代码描述
appidstring公众账号ID
mch_idstring商户号
sub_appidstring子商户公众账号ID
sub_mch_idstring子商户号
nonce_strstring随机字符串
signstring签名
transaction_idstring微信订单号
out_trade_nostring商户订单号
out_refund_nostring商户退款单号
refund_idstring微信退款单号
refund_feeinteger退款金额
settlement_refund_feeinteger应结退款金额
total_feeinteger标价金额
settlement_total_feeinteger应结订单金额
fee_typestring标价币种
cash_feeinteger现金支付金额
cash_fee_typestring现金支付币种
cash_refund_feeinteger现金退款金额
coupon_type_$nstring代金券类型
coupon_refund_feeinteger代金券退款总金额
coupon_refund_fee_$ninteger单个代金券退款金额
coupon_refund_countinteger退款代金券使用数量
coupon_refund_id_$nstring退款代金券ID

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

Published on the GitHub by TheNorthMemory