文档中心 商家相关 订单退款接口

订单退款接口

1.使用场景

商家退款接口(非幂等,第二次请求外部退款号一致,会提示退款号已存在)。需要回调通知的话,请按要求提供接口

2.接口调用说明

请求URL

https://openapi.guanaitong.tech/seller/pay/syncRefund

HTTP请求方式

POST

输入参数说明

(1)公共参数

发送请求是必须传入公共参数,详见公共参数

(2)私有参数

参数名称 是否必须 参数类型 长度限制 描述
outer_trade_no string [10,32] 外部交易号,请以appid开头,例如:10000001101
outer_refund_no string [10,32] 外部退款号,请以appid开头,例如:10000001201
reason string [1,254] 退款原因
refund_amount decimal [0.01,99999999.99] 退款金额
cost_amount decimal [0.01,99999999.99] 结算价(差价结算时需要,具体咨询关爱通对接人员)
delivery_fee decimal [0.01,99999999.99] 运费(结算价包含运费时,该字段不用传递)
notify_url string [1,254] 通知url,非同步,退款完成时进行通知结果,与同步返回结果一致
请求示例
POST /seller/pay/syncRefund HTTP/1.1
Host: openapi.guanaitong.tech
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

access_token=b983eef183a789a693b91406f38b7e23&
outer_refund_no=10000001201&outer_trade_no=10000001101&reason=部分退款测试-退款10积分,订单总额100&
timestamp=1531039596&refund_amount=10&version=1.0.0
                    
返回参数说明
参数名称 描述
code 返回码。详见错误返回码
msg 如果错误,返回错误信息。
data 如果没有错误,返回关爱通交易号
正确返回示例
{
    "code": 0,
    "data": "2018070820000016",
    "msg": "OK"
}
错误返回示例
{
    "code": 1000210001,
    "msg": "timestamp check failed!",
    "data": null
}

3.支付回调

请求URL

调用退款接口时,填写的notify_url

HTTP请求方式

POST

输入参数说明
参数名称 参数类型 描述
appid string 应用appid
outer_trade_no string 外部交易号
outer_refund_no string 外部退款号
refund_amount decimal 退款金额
trade_no string 关爱通交易号
timestamp string 时间戳,其值为1970-1-01 00:00:00.000到当前时刻的时间距离,单位是秒,时区为GMT+8(东八区)。如1469691921。关爱通接口允许的时间戳偏差为5分钟,偏差超过5分钟的请求将被拒绝。
sign string 签名,见 签名机制
请求示例
POST 商家URI,如:/syncRefund/notify HTTP/1.1
Host: 商家域名,如:test.guanaitong.tech
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

appid=10000001&outer_trade_no=10000001101&outer_refund_no=10000001201&
refund_amount=10.0&trade_no=2018070920000005&sign=edceccd3117ff3d32690a6caf23355a0b407074f&
timestamp=1531039298
                    
返回参数说明

(1)notify只有在关爱通退款成功后才会发送;

(2)商家在收到了请求、校验通过后,请即时更新自己的订单状态,并返回success(不要带任何其他源码内容);

(3)若关爱通的notify请求无响应或者接收的内容不是“success”,则认为通知失败,等一段时间后会再次请求(notify请求会在此后24小时内按递增时间间隔继续发送通知);

(4)notify仅为通知,不论第三方返回成功或失败,都不会改变关爱通的订单状态;

正确返回示例
success
错误返回示例
fail