...
|
...
|
@@ -4,29 +4,25 @@ |
|
|
*/
|
|
|
package com.alipay.servlet.gateway;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.PrintWriter;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServlet;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.alipay.api.AlipayApiException;
|
|
|
import com.alipay.api.AlipayClient;
|
|
|
import com.alipay.api.AlipayConstants;
|
|
|
import com.alipay.api.DefaultAlipayClient;
|
|
|
import com.alipay.api.domain.AlipayTradeAppPayModel;
|
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
|
import com.alipay.api.internal.util.StringUtils;
|
|
|
import com.alipay.api.request.AlipayTradeAppPayRequest;
|
|
|
import com.alipay.constants.AlipayServiceEnvConstants;
|
|
|
import com.alipay.dispatcher.Dispatcher;
|
|
|
import com.alipay.executor.ActionExecutor;
|
|
|
import com.alipay.factory.AlipayAPIClientFactory;
|
|
|
import com.alipay.util.LogUtil;
|
|
|
import com.alipay.util.RequestUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServlet;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.PrintWriter;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 开发者网关,支付宝所有主动和开发者的交互会经过此网关进入开发者系统(配置在开放平台的应用网关)
|
...
|
...
|
@@ -36,6 +32,9 @@ import com.alipay.util.RequestUtil; |
|
|
*/
|
|
|
public class GatewayServlet extends HttpServlet {
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(GatewayServlet.class);
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
...
|
...
|
@@ -46,8 +45,10 @@ public class GatewayServlet extends HttpServlet { |
|
|
*/
|
|
|
@Override
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
|
|
IOException {
|
|
|
IOException {
|
|
|
logger.info("enter ali GatewayServlet req {} ",req);
|
|
|
this.doPost(req, resp);
|
|
|
logger.info("enter ali GatewayServlet end ");
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -59,6 +60,7 @@ public class GatewayServlet extends HttpServlet { |
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
|
throws ServletException,
|
|
|
IOException {
|
|
|
logger.info("enter ali GatewayServlet post ");
|
|
|
//支付宝响应消息
|
|
|
String responseMsg = "";
|
|
|
|
...
|
...
|
@@ -82,11 +84,13 @@ public class GatewayServlet extends HttpServlet { |
|
|
catch (AlipayApiException alipayApiException) {
|
|
|
//开发者可以根据异常自行进行处理
|
|
|
alipayApiException.printStackTrace();
|
|
|
logger.error("enter ali GatewayServlet post error {} ",alipayApiException);
|
|
|
|
|
|
}
|
|
|
catch (Exception exception) {
|
|
|
//开发者可以根据异常自行进行处理
|
|
|
exception.printStackTrace();
|
|
|
logger.error("enter ali GatewayServlet post exception {} ",exception);
|
|
|
|
|
|
} finally {
|
|
|
//5. 响应结果加签及返回
|
...
|
...
|
@@ -110,6 +114,7 @@ public class GatewayServlet extends HttpServlet { |
|
|
} catch (AlipayApiException alipayApiException) {
|
|
|
//开发者可以根据异常自行进行处理
|
|
|
alipayApiException.printStackTrace();
|
|
|
logger.error("enter ali GatewayServlet post exception {} ",alipayApiException);
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -117,7 +122,7 @@ public class GatewayServlet extends HttpServlet { |
|
|
/**
|
|
|
* 验签
|
|
|
*
|
|
|
* @param request‘
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
private void verifySign(Map<String, String> params) throws AlipayApiException {
|
...
|
...
|
|