Преглед изворни кода

优化微信公众号支付逻辑

小柒2012 пре 7 година
родитељ
комит
d9eaf5b4fc

+ 2 - 4
src/main/java/com/itstyle/modules/weixinpay/controller/WeixinMobilePayController.java

@@ -78,10 +78,8 @@ public class WeixinMobilePayController {
 	@SuppressWarnings("rawtypes")
 	@RequestMapping(value = "dopay")
 	public String dopay(HttpServletRequest request, HttpServletResponse response) throws Exception {
-		String state = request.getParameter("state");
-		String[] split = state.split("/");
-		String orderNo = split[0];
-		String totalFee = split[1];
+		String orderNo = request.getParameter("outTradeNo");
+		String totalFee = request.getParameter("totalFee");
 		//获取code 这个在微信支付调用时会自动加上这个参数 无须设置
 		String code = request.getParameter("code");
 		//获取用户openID(JSAPI支付必须传openid)

+ 2 - 2
src/main/java/com/itstyle/modules/weixinpay/service/impl/WeixinPayServiceImpl.java

@@ -213,9 +213,9 @@ public class WeixinPayServiceImpl implements IWeixinPayService {
 		totalFee =  CommonUtil.subZeroAndDot(totalFee);
 		url.append("http://open.weixin.qq.com/connect/oauth2/authorize?");
 		url.append("appid="+ConfigUtil.APP_ID);
-		url.append("&redirect_uri="+server_url+"weixinMobile/dopay");
+		url.append("&redirect_uri="+server_url+"weixinMobile/dopay?");
+		url.append("outTradeNo="+product.getOutTradeNo()+"&totalFee="+totalFee);
 		url.append("&response_type=code&scope=snsapi_base&state=");
-		url.append(product.getOutTradeNo()+"/"+totalFee);//订单号/金额(单位是分)
 		url.append("#wechat_redirect");
 		return  url.toString();
 	}