申请退款(支持单品)
如果使用不支持单品优惠部分退款的历史接口,请看
请求参数 | 类型 | 描述 |
---|---|---|
security | true | 声明加载商户API证书 |
xml | object | 声明请求的XML 数据结构 |
detail | string | 退款包含的商品列表信息,全额退款可不传JSON 格式字符串 |
cost_price | number | 订单原价 |
receipt_id | string | 商品小票ID |
goods_detail | object[] | 单品列表 |
goods_id | string | 商品编码 |
wxpay_goods_id | string | 微信支付商品编码 |
goods_name | string | 商品名称 |
quantity | number | 商品数量 |
price | number | 商品单价 |
appid | string | 公众账号ID |
sub_appid | string | 子商户公众账号ID |
mch_id | string | 商户号 |
sub_mch_id | string | 子商户号 |
sign_type | string | 签名类型MD5 | HMAC-SHA256 枚举值之一 |
transaction_id | string | 微信订单号 |
out_trade_no | string | 商户订单号 |
out_refund_no | string | 商户退款单号 |
total_fee | integer | 订单金额 |
refund_fee | integer | 退款金额 |
refund_fee_type | string | 退款货币种类 |
refund_desc | string | 退款原因 |
refund_account | string | 退款资金来源 |
notify_url | string | 退款结果通知url |
php
$instance->v2->secapi->pay->refundv2->postAsync([
'security' => true,
'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/',
],
])
->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([
'security' => true,
'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/',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/secapi/pay/refundv2']->postAsync([
'security' => true,
'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/',
],
])
->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([
'security' => true,
'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/',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/secapi/pay/refundv2')->post([
'security' => true,
'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/',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/secapi/pay/refundv2']->post([
'security' => true,
'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/',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典 | 类型 | 描述 |
---|---|---|
return_code | string | 返回状态码SUCCESS | FAIL 枚举值之一 |
return_msg | string | 返回信息 |
result_code | string | 业务结果SUCCESS | FAIL 枚举值之一 |
err_code | string | 错误代码 |
err_code_des | string | 错误代码描述 |
appid | string | 公众账号ID |
mch_id | string | 商户号 |
sub_appid | string | 子商户公众账号ID |
sub_mch_id | string | 子商户号 |
nonce_str | string | 随机字符串 |
sign | string | 签名 |
transaction_id | string | 微信订单号 |
out_trade_no | string | 商户订单号 |
out_refund_no | string | 商户退款单号 |
refund_id | string | 微信退款单号 |
refund_fee | integer | 退款金额 |
settlement_refund_fee | integer | 应结退款金额 |
total_fee | integer | 标价金额 |
settlement_total_fee | integer | 应结订单金额 |
fee_type | string | 标价币种 |
cash_fee | integer | 现金支付金额 |
cash_fee_type | string | 现金支付币种 |
cash_refund_fee | integer | 现金退款金额 |
coupon_type_$n | string | 代金券类型 |
coupon_refund_fee | integer | 代金券退款总金额 |
coupon_refund_fee_$n | integer | 单个代金券退款金额 |
coupon_refund_count | integer | 退款代金券使用数量 |
coupon_refund_id_$n | string | 退款代金券ID |
promotion_detail | string | 营销详情JSON 格式字符串 |
promotion_id | string | 券ID |
name | string | 优惠名称 |
scope | string | 优惠范围GLOBAL | SINGLE 枚举值之一 |
type | string | 优惠类型COUPON | DISCOUNT 枚举值之一 |
amount | string | 优惠券面额 |
activity_id | string | 活动ID |
wxpay_contribute | string | 微信出资 |
merchant_contribute | string | 商户出资 |
other_contribute | string | 其他出资 |
goods_detail | object[] | 单品列表 |
goods_id | string | 商品编码 |
wxpay_goods_id | string | 微信支付商品编码 |
goods_name | string | 商品名称 |
quantity | number | 商品数量 |
price | number | 商品单价 |