文档中心 商家相关 关爱通支付

关爱通支付

1.使用场景

适用于与第三方供应商(商家)对接支付关爱通时,使用。

商家在其页面完成购物后,点击关爱通支付,跳转到关爱通支付页面(自适应客户端,显示PC或移动端支付页面),完成支付校验后,扣除关爱通资产,完成订单。

 

该接口使用需知:

1.请求URL时,请不要添加额外参数,签名时会用对所有参数进行签名;

2.商家服务端按规则拼接好URL后(各参数建议经过Urlencode),通知浏览器进行302跳转;

3.支付完成后会立即跳转到“return_url”,建议商家此时显示支付中页面;

4.请一定要提供接口,接收notify请求,并及时返回结果(“success”);

5.支付状态请根据notify_url的请求(或者根据订单查询接口)来判断,千万不能根据return_url中的pay_result。

2.时序图

3.接口调用说明

请求URL

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

HTTP请求方式

GET

输入参数说明

(1)公共参数

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

(2)私有参数

参数名称 是否必须 参数类型 长度限制 描述
outer_trade_no string [10,32] 外部交易号,请以appid开头,例如:1000000122
type int [1,1] 是否即时交易,1.是,2.否。有发货需求的一般填否
buyer_open_id string 32 下单员工唯一标识
reason string [1,254] 下单原因
total_amount decimal [0.01,99999999.99] 下单金额
cost_amount decimal [0.00,99999999.99] 结算价(差价结算时需要,具体咨询关爱通对接人员)
attach string [1,100] 附加信息,原样返回,复杂参数建议urlencode
order_category string [1,100] 商品分类
trade_info string [1,4000] 交易详情,JSON格式,多订单与单订单有不同格式的要求,根据是否有thirdOrders字段识别。内容如下
return_url string [1,254] 支付完成后,跳转的商家订单显示URL
notify_url string [1,254] 商家提供的notify_url。订单完成后,关爱通会对此URL进行请求,通知商家订单成功

(3)trade_info对象

参数名称 是否必须 参数类型 长度限制 描述
thirdTradeNo string [1,50] 第三方订单号
totalAmount decimal [0.01,99999999.99] 订单原金额
payAmount decimal [0.01,99999999.99] 支付金额
costAmount decimal [0.00,99999999.99] 结算成本价
thirdOrders list (多订单时,使用该字段)订单信息列表,List«ThirdOrder»
goodsDetail list (单订单时,使用该字段)商品信息列表,List«GoodsDetail»

(4)ThirdOrder对象

参数名称 是否必须 参数类型 长度限制 描述
thirdOrderNo string [1,50] 子订单编号
totalAmount decimal [0.01,99999999.99] 订单原金额
payAmount decimal [0.01,99999999.99] 支付金额
costAmount decimal [0.00,99999999.99] 结算成本价
goodsDetail list 商品信息列表,List«GoodsDetail»

(5)GoodsDetail对象

参数名称 是否必须 参数类型 长度限制 描述
skuId string [1,50] 商品编号
name string [1,50] 商品名称
quantity int 最少为1 数量
price decimal [0.01,99999999.99] 原价,若商品支付价格和原价一致,可以不填支付价,否则建议填写
payAmount decimal [0.00,99999999.99] 支付价
请求示例urlencoded前(浏览器的URL)为:
https://openapi.guanaitong.tech/seller/pay/excashier?access_token=d527ba86a98f1fc68bbddd2ae6f7f366&
appsecret=1c590e639e300f96c24f802e42912224&buyer_open_id=a0b9b67768d4470a6d93b348573c955c&
notify_url=https://test.guanaitong.com&order_category=休闲零食&outer_trade_no=100000010000000001&reason=测试收银台&
return_url=https://test.guanaitong.com&total_amount=10.01&trade_info={"thirdTradeNo":"100001","totalAmount":10.01,
"payAmount":10.01,"costAmount":10.01,"goodsDetail":[{"goodsCategory":"饮料","goodsSkuId":"123","goodsName":"果汁",
"quantity":1,"price":5.01},{"goodsCategory":"饮料","goodsSkuId":"455","goodsName":"巧克力","quantity":2,"price":2.5}]}&
timestamp=1537253188&sign=16c63d7cb5a02bf98240893f604e9ba6c2640254&version=1.0.0
                    
请求示例经过Urlencoded后(浏览器的URL)为:
https://openapi.guanaitong.tech/seller/pay/excashier?access_token=d527ba86a98f1fc68bbddd2ae6f7f366&
buyer_open_id=a0b9b67768d4470a6d93b348573c955c&outer_trade_no=100000010000000001&
notify_url=https%3A%2F%2Ftest.guanaitong.com&order_category=%E4%BC%91%E9%97%B2%E9%9B%B6%E9%A3%9F&
reason=%E6%B5%8B%E8%AF%95%E6%94%B6%E9%93%B6%E5%8F%B0&return_url=https%3A%2F%2Ftest.guanaitong.com&
sign=16c63d7cb5a02bf98240893f604e9ba6c2640254&total_amount=10.01&version=1.0.0&
timestamp=1537253188&trade_info=%7B%22thirdTradeNo%22%3A%22100001%22%2C%22totalAmount%22%3A10.01%2C%22
payAmount%22%3A10.01%2C%22costAmount%22%3A10.01%2C%22goodsDetail%22%3A%5B%7B%22goodsCategory%22%3A%22%E9%
A5%AE%E6%96%99%22%2C%22goodsSkuId%22%3A%22123%22%2C%22goodsName%22%3A%22%E6%9E%9C%E6%B1%81%22%2C%22quantity
%22%3A1%2C%22price%22%3A5.01%7D%2C%7B%22goodsCategory%22%3A%22%E9%A5%AE%E6%96%99%22%2C%22goodsSkuId%22%3A%22455
%22%2C%22goodsName%22%3A%22%E5%B7%A7%E5%85%8B%E5%8A%9B%22%2C%22quantity%22%3A2%2C%22price%22%3A2.5%7D%5D%7D
                    

4.从关爱通收银台,跳回商家页面(return_url)

请求URL

调用支付接口时,填写的return_url

HTTP请求方式

GET

跳转页面

输入参数说明
参数名称 参数类型 描述
appid string 应用appid
outer_trade_no string 跳转收银台时传递的外部交易号
attach string 前面附带的信息
pay_result string success成功 fail 失败
timestamp string 时间戳,其值为1970-1-01 00:00:00.000到当前时刻的时间距离,单位是秒,时区为GMT+8(东八区)。如1469691921。关爱通接口允许的时间戳偏差为5分钟,偏差超过5分钟的请求将被拒绝。
sign string 签名,见 签名机制
请求示例(浏览器URL)为:
https://test.guanaitong.tech/?outer_trade_no=100000010000000001&appid=10000001&
timestamp=1537253931&sign=c9a7ede47d9f40a599d76e98a8c8a039d7ae4e2d&pay_result=success
                    
跳转说明

(1)用户支付完成后,会跳转到商家填写的return_url地址;

(2)商家根据outerTradeNo进入订单支付中的页面;

(3)商家服务端等待来自关爱通的notify通知,更新订单状态后,页面改为订单成功;

5.支付回调(notify_url)

请求URL

调用支付接口时,填写的notify_url

HTTP请求方式

POST

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

appid=10000001&outer_trade_no=100000010000000001&total_amount=100.00&
buyer_open_id=d87797eea12a2f80ad72ed93214a0908&trade_no=2018070920000005&
timestamp=1531120153&sign=31f531d0ca40e6d7fb02688564f637f458e63ec8
                    
返回参数说明

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

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

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

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

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