Browse Source

微信h5支付

huangct 8 years ago
parent
commit
58c47295dc

+ 1 - 2
donate-service/src/main/java/com/uas/service/donate/controller/AlipayController.java

@@ -354,7 +354,7 @@ public class AlipayController {
         ModelAndView modelAndView = new ModelAndView();
         Map<String, String> params = AlipayApi.toMap(request);
         String data = AlipayApi.getRequestData(request); // data json格式
-        System.out.print(data);
+        logger.info("同步通知返回数据:" + data);
         boolean signVerified = false; //调用SDK验证签名
         try {
             signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, AlipayConfig.SIGNTYPE);
@@ -544,7 +544,6 @@ public class AlipayController {
     private ProjectRecode createProjectRecode(String jsonStr) throws Exception {
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
         String imid = jsonObject.getString("imid");
-        logger.info("移动端imid=" + imid);
         Long uuid = null;
         User user = SystemSession.getUser();
         if (user != null) {

+ 2 - 2
donate-service/src/main/java/com/uas/service/donate/controller/WxpayController.java

@@ -237,7 +237,8 @@ public class WxpayController {
             //map.put("status", "SUCCESS");
             if (WxPayConstants.TradeType.MWEB.equals(wxPayUnifiedOrderRequest.getTradeType())) {
                 /*H5支付开发步骤:https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_4*/
-                String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl() + "&redirect_url=" + URLEncoder.encode(redirectUrl,"UTF-8");
+                //String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl() + "&redirect_url=" + URLEncoder.encode(redirectUrl,"UTF-8");
+                String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl();
                 map.put("mwebUrl", mwebUrl);
             } else if (WxPayConstants.TradeType.NATIVE.equals(wxPayUnifiedOrderRequest.getTradeType())) {
                 //扫码支付
@@ -564,7 +565,6 @@ public class WxpayController {
     private ProjectRecode createProjectRecode(String jsonStr) throws Exception {
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
         String imid = jsonObject.getString("imid");
-        logger.info("移动端imid=" + imid);
         Long uuid = null;
         User user = SystemSession.getUser();
         if (user != null) {

+ 10 - 7
donate-service/src/main/webapp/resources/js/pay.js

@@ -91,15 +91,18 @@ var wxPay = function (proId, amount, payWay, imid) {
                 jsonStr : jsonStr
             },
             success : function(res){
-                var resJsonObj=JSON.parse(res);
-                if (resJsonObj.error != null) {
-                    toastr.warning(resJsonObj.error);
-                    return;
-                }
-
                 if (isMobile) {
-                    window.location.href = resJsonObj.mwebUrl;
+                    if (res.error != null) {
+                        toastr.warning(res.error);
+                        return;
+                    }
+                    window.location.href = res.mwebUrl;
                 } else {
+                    var resJsonObj=JSON.parse(res);
+                    if (resJsonObj.error != null) {
+                        toastr.warning(resJsonObj.error);
+                        return;
+                    }
                     document.cookie = 'qrcodeUrl='+encodeURIComponent(resJsonObj.qrcodeUrl);
                     window.location.href = "http://lj.ubtob.com/project#/donateQrcode/" + resJsonObj.outTradeNo;
                 }