Skip to content

申请退款(支持单品)

如果使用不支持单品优惠部分退款的历史接口,请看

请求参数类型描述
xmlobject声明请求的XML数据结构
detailstring退款包含的商品列表信息,全额退款可不传,必须按照规范上传,JSON格式
appidstring公众账号ID
sub_appidstring子商户公众账号ID
mch_idstring商户号
sub_mch_idstring子商户号
sign_typestring签名类型
transaction_idstring微信订单号
out_trade_nostring商户订单号
out_refund_nostring商户退款单号
total_feeinteger订单金额
refund_feeinteger退款金额
refund_fee_typestring退款货币种类
refund_descstring退款原因
refund_accountstring退款资金来源
notify_urlstring退款结果通知url
securityboolean声明加载商户API证书
固定值true
php
$instance->v2->secapi->pay->refundv2->postAsync([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/secapi/pay/refundv2')->postAsync([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/secapi/pay/refundv2']->postAsync([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->secapi->pay->refundv2->post([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/secapi/pay/refundv2')->post([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/secapi/pay/refundv2']->post([
  'xml' => [
    'detail' => '{"goods_detail":[{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":528800},{"goods_id":"商品编码","wxpay_goods_id":"1001","goods_name":"iPhone6s 16G","refund_amount":528800,"refund_quantity":1,"price":608800}]}',
    '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/',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
return_msgstring返回信息
result_codestring业务结果
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
promotion_detailstring营销详情列表

参阅 这里,本接口支持单品优惠订单全额退款和单品优惠订单部分退款,推荐使用本接口,官方文档

Published on the GitHub by TheNorthMemory