# DEMO示例
# 服务场景描述
在线续费业务通过调用在线支付API完成在线支付功能的调用,满足在线收款的需求。
# 服务地址
测试环境:https://apigate.glodon.com/ngtrade-test
生产环境:https://apigate.glodon.com/ngtrade
# 服务调用流程
# 1.本服务调用依赖以下API:
# 2.服务调用前置条件:
创建应用,获取appkey、通信密钥;
计算数字签名;
以上步骤可参考前置准备
# 3.具体调用步骤
step1: 通过GET请求调用在线支付的API接口
String payUrl = buildPayRequestUri();
LOGGER.info("directOnlinePay url: [{}]", payUrl);
response.sendRedirect(payUrl);
1
2
3
4
5
6
2
3
4
5
6
step2: 开发接收前端回调通知的接口
/**
* 在线支付-支付系统前端回调通知.
*/
@RequestMapping("return")
public void payReturn(TradePayResponse tradeResponse, HttpServletResponse response)
throws Exception {
LOGGER.info("payReturn:{}", JSON.toJSONString(tradeResponse, false));
// 对支付中心的通知做验签
validateTradeNotifySignWithException(response);
// 业务线实现前端回调的处理逻辑
// ..................
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
step3: 开发接收后端回调通知的接口
/**
* 在线支付-支付系统后端回调通知.
*/
@RequestMapping("notify")
public String payNotify(TradePayResponse response) throws Exception {
LOGGER.info("payNotify:[{}]", JSON.toJSONString(response, false));
// 对支付中心的通知做验签
validateTradeNotifySignWithException(response);
boolean handlerResult = handlePayNotify(response);
LOGGER.info("payNotify handle pay notify result: {}", handlerResult);
/**
* 返回给支付中心通知回执
*/
if (handlerResult) {
// 成功接收通知并反馈, 支付中心后续不会再发送通知
return "success";
} else {
// 通知接收失败并反馈, 支付中心后续将继续补偿发送该通知
return "fail";
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24