通知退款结果代码示例
本章主要介绍通知退款结果的 Java SDK 代码示例。
代码示例
@RequestMapping(method = RequestMethod.POST,value = "/your/path/to/refund/notify")
public AcopayNotifyResponseModel reciveNotify(HttpServletRequest httpServletRequest) {
AcopayNotifyResponseModel notifyResponseModel = new AcopayNotifyResponseModel();
try {
String json = IOUtils.toString(httpServletRequest.getInputStream(), StandardCharsets.UTF_8);
log.info("接收翼辉支付结果异步通知:{}", json);
Map<String,Object> params = JSONObject.parseObject(json, Map.class);
//验证签名
AcopaySignUtil.verifySign(params,acopayPublicKey);
//TODO 处理后续业务
notifyResponseModel.setStatus(NOTIFY_SUCCESS);
notifyResponseModel.setMessage("成功");
} catch (Exception e) {
log.error("接收异步通知失败:{}", e.getMessage());
notifyResponseModel.setStatus(NOTIFY_FAIL);
notifyResponseModel.setMessage("失败");
}
return notifyResponseModel;
}