修复旧版支付宝通知校验

This commit is contained in:
egzosn@gmail.com
2017-06-08 15:39:49 +08:00
parent f9c818c6e1
commit fae122a55d
2 changed files with 13 additions and 10 deletions

View File

@@ -36,11 +36,11 @@ public class AliPayService extends BasePayService {
protected final Log log = LogFactory.getLog(AliPayService.class);
//正式测试环境
private String httpsReqUrl = "https://openapi.alipay.com/gateway.do";
private final static String httpsReqUrl = "https://openapi.alipay.com/gateway.do";
//沙箱测试环境账号
private String devReqUrl = "https://openapi.alipaydev.com/gateway.do";
private final static String devReqUrl = "https://openapi.alipaydev.com/gateway.do";
//兼容上一版本即时收款
private String httpsReqUrlBefore = "https://mapi.alipay.com/gateway.do";
private final static String httpsReqUrlBefore = "https://mapi.alipay.com/gateway.do";
/**
@@ -305,7 +305,6 @@ public class AliPayService extends BasePayService {
*/
@Override
public String buildRequest(Map<String, Object> orderInfo, MethodType method) {
StringBuffer formHtml = new StringBuffer();
formHtml.append("<form id=\"_alipaysubmit_\" name=\"alipaysubmit\" action=\"");
if (null == orderInfo.get("method")) {
@@ -332,11 +331,6 @@ public class AliPayService extends BasePayService {
formHtml.append("<input type=\"hidden\" name=\"biz_content\" value=\"" + biz_content.replace("\"", "&quot;") + "\"/>");
}
//submit按钮控件请不要含有name属性
// formHtml.append("<input type=\"submit\" value=\"\" style=\"display:none;\">");
formHtml.append("</form>");
formHtml.append("<script>document.forms['_alipaysubmit_'].submit();</script>");

View File

@@ -85,7 +85,7 @@ public class AliPayService extends BasePayService {
*/
@Override
public boolean verifySource(String id) {
return "true".equals(requestTemplate.getForObject( getHttpsVerifyUrl() + "partner=" + payConfigStorage.getPid() + "&notify_id=" + id, String.class));
return "true".equals(requestTemplate.getForObject( getHttpsVerifyUrl() + "&partner=" + payConfigStorage.getPid() + "&notify_id=" + id, String.class));
}
/**
@@ -228,6 +228,15 @@ public class AliPayService extends BasePayService {
}
//乱码解决这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
if (!valueStr.matches("\\w+")){
try {
if(valueStr.equals(new String(valueStr.getBytes("iso8859-1"), "iso8859-1"))){
valueStr=new String(valueStr.getBytes("iso8859-1"), payConfigStorage.getInputCharset());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
params.put(name, valueStr);
}