|
@@ -170,7 +170,8 @@ public class AliPayService {
|
|
String paynum = map.get("out_trade_no"); // paynum
|
|
String paynum = map.get("out_trade_no"); // paynum
|
|
String tradenum = map.get("trade_no"); // 支付宝交易号
|
|
String tradenum = map.get("trade_no"); // 支付宝交易号
|
|
int totalAmount = DecimalUtil.toInt(map.get("total_amount")); // 实际支付金额
|
|
int totalAmount = DecimalUtil.toInt(map.get("total_amount")); // 实际支付金额
|
|
- return payService.finish(paynum, tradenum, totalAmount, PayService.FLAG_NOTIFY);
|
|
|
|
|
|
+ payService.finish(paynum, tradenum, totalAmount, PayService.FLAG_NOTIFY);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -179,27 +180,26 @@ public class AliPayService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
- public boolean doReturn(Map<String, String> map) throws Exception {
|
|
|
|
|
|
+ public String doReturn(Map<String, String> map) throws Exception {
|
|
// 验证签名
|
|
// 验证签名
|
|
if(!this.checkSign(map)) {
|
|
if(!this.checkSign(map)) {
|
|
logger.error("支付宝同步回调: 签名验证失败: {}", map);
|
|
logger.error("支付宝同步回调: 签名验证失败: {}", map);
|
|
- return false;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
// 查询订单 (同步回调不可靠)
|
|
// 查询订单 (同步回调不可靠)
|
|
String paynum = map.get("out_trade_no");
|
|
String paynum = map.get("out_trade_no");
|
|
-
|
|
|
|
String result = this.query(paynum);
|
|
String result = this.query(paynum);
|
|
Map<String, Object> resultMap = JsonUtil.toObject(result, HashMap.class);
|
|
Map<String, Object> resultMap = JsonUtil.toObject(result, HashMap.class);
|
|
// {"alipay_trade_query_response":{"code":"10000","msg":"Success","buyer_logon_id":"ipb***@sandbox.com","buyer_pay_amount":"0.00","buyer_user_id":"2088102170394382","buyer_user_type":"PRIVATE","invoice_amount":"0.00","out_trade_no":"1529637131201603","point_amount":"0.00","receipt_amount":"0.00","send_pay_date":"2018-06-22 11:12:23","total_amount":"12.00","trade_no":"2018062221001004380200826678","trade_status":"TRADE_SUCCESS"},"sign":"gnWtxKDDhkRmoWnfwLVs2RGtt4GbiY+xaVs5+G47D5e9SnQHqGnElKme4jlDdnqhAroX3aqyJLVexohBjzA+DlpRzDhIu5EZLXnDr/B2FZEVjyiU66ImVH6vSyWyOVEjbGIgmVhUslhXqXYK5KxAx3QAdLrJLQeMO/gUdjs0qWcGO9yTU/suDy0YcdLSLlFyUutwD2MBz4Ri0tBk+uHjpxXoTZeb9/lQ7e4BixwCy+wB3hcESWN1b/m77YLKztmbLy67auhxzP9TRwQQ+6WRrTdMe/9rouIt6AW9T+6XSFd/LwL73Qo+1MfQa+iEUx2Iq+AYekhSgVyLJMRgz/qoZA=="}
|
|
// {"alipay_trade_query_response":{"code":"10000","msg":"Success","buyer_logon_id":"ipb***@sandbox.com","buyer_pay_amount":"0.00","buyer_user_id":"2088102170394382","buyer_user_type":"PRIVATE","invoice_amount":"0.00","out_trade_no":"1529637131201603","point_amount":"0.00","receipt_amount":"0.00","send_pay_date":"2018-06-22 11:12:23","total_amount":"12.00","trade_no":"2018062221001004380200826678","trade_status":"TRADE_SUCCESS"},"sign":"gnWtxKDDhkRmoWnfwLVs2RGtt4GbiY+xaVs5+G47D5e9SnQHqGnElKme4jlDdnqhAroX3aqyJLVexohBjzA+DlpRzDhIu5EZLXnDr/B2FZEVjyiU66ImVH6vSyWyOVEjbGIgmVhUslhXqXYK5KxAx3QAdLrJLQeMO/gUdjs0qWcGO9yTU/suDy0YcdLSLlFyUutwD2MBz4Ri0tBk+uHjpxXoTZeb9/lQ7e4BixwCy+wB3hcESWN1b/m77YLKztmbLy67auhxzP9TRwQQ+6WRrTdMe/9rouIt6AW9T+6XSFd/LwL73Qo+1MfQa+iEUx2Iq+AYekhSgVyLJMRgz/qoZA=="}
|
|
Map<String, String> responseMap = (Map<String, String>) resultMap.get("alipay_trade_query_response");
|
|
Map<String, String> responseMap = (Map<String, String>) resultMap.get("alipay_trade_query_response");
|
|
if(!"10000".equals(responseMap.get("code"))) {
|
|
if(!"10000".equals(responseMap.get("code"))) {
|
|
logger.error("支付宝同步回调: 查询状态异常: {}", responseMap);
|
|
logger.error("支付宝同步回调: 查询状态异常: {}", responseMap);
|
|
- return false;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
// 验证支付宝交易状态
|
|
// 验证支付宝交易状态
|
|
if(!this.checkStatus(responseMap)) {
|
|
if(!this.checkStatus(responseMap)) {
|
|
logger.error("支付宝同步回调: 交易状态异常: {}", responseMap);
|
|
logger.error("支付宝同步回调: 交易状态异常: {}", responseMap);
|
|
- return false;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
// 完成支付
|
|
// 完成支付
|
|
String tradenum = responseMap.get("trade_no"); // 支付宝交易号
|
|
String tradenum = responseMap.get("trade_no"); // 支付宝交易号
|