码迷,mamicode.com
首页 > 移动开发 > 详细

支付宝APP支付Java回调具体步骤

时间:2016-08-30 00:07:40      阅读:718      评论:0      收藏:0      [点我收藏+]

标签:

/**
* 支付宝异步请求通知
*
* @param request
* @return
*/
@RequestMapping(value = "async", method = RequestMethod.POST)
@ResponseBody
@Transactional(readOnly = false)
public String async(HttpServletRequest request) {
Map<String, String> params = new HashMap<String, String>();
Map requestParams = request.getParameterMap();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
String[] values = (String[]) requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
}
System.out.println(">>>>>参数" + name + ":" + valueStr);
params.put(name, valueStr);
}
requestParams.get("trade_status");
String tradeNo = request.getParameter("out_trade_no");
String tradeStatus = request.getParameter("trade_status");
if (AlipayNotify.verify(params)) {//验证成功
if (tradeStatus.equals("TRADE_FINISHED") || tradeStatus.equals("TRADE_SUCCESS")) {
System.out.println(">>>>>状态要更新了");
    //商品交易成功之后的业务逻辑代码

System.out.println(">>>>>下单成功" + tradeNo);
}
return "success";
} else {//验证失败
System.out.println(">>>>>验签失败" + tradeNo);
System.out.println(">>>>>交易被关闭了");
MemberOrder order = this.memberOrderService.get(tradeNo);
this.memberOrderService.updateActualPayAndSurplusPay("0.00", order.getActualPay().toString(), tradeNo);
return "fail";
}
}

支付宝APP支付Java回调具体步骤

标签:

原文地址:http://www.cnblogs.com/xu-xiang/p/5820215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!