Просмотр исходного кода

支付宝支付请求失败提示

huangct 8 лет назад
Родитель
Сommit
3c4262c88e

+ 18 - 4
donate-service/src/main/java/com/uas/service/donate/controller/AlipayController.java

@@ -78,7 +78,9 @@ public class AlipayController {
         try {
             projectRecode = this.createProjectRecode(jsonStr);
         } catch (Exception e) {
-            response.getWriter().write(e.getMessage());
+            e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("生成订单失败,请稍后再试!");
             return;
         }
 
@@ -97,8 +99,9 @@ public class AlipayController {
 
             AlipayApi.wapPay(response, model, alipayClient, AlipayConfig.RETURN_URL, AlipayConfig.NOTIFY_URL);
         } catch (Exception e) {
-            response.getWriter().write(e.getMessage());
             e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("创建订单失败,请稍后再试!");
         }
     }
 
@@ -113,7 +116,9 @@ public class AlipayController {
         try {
             projectRecode = this.createProjectRecode(jsonStr);
         } catch (Exception e) {
-            response.getWriter().write(e.getMessage());
+            e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("生成订单失败,请稍后再试!");
             return;
         }
 
@@ -169,6 +174,8 @@ public class AlipayController {
             AlipayApi.tradePage(response,model,alipayClient,AlipayConfig.RETURN_URL,AlipayConfig.NOTIFY_URL);
         } catch (Exception e) {
             e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("创建订单失败,请稍后再试!");
         }
 
     }
@@ -183,7 +190,9 @@ public class AlipayController {
         try {
             newProjectRecode = this.createProjectRecode(jsonStr);
         } catch (Exception e) {
-            response.getWriter().write(e.getMessage());
+            e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("生成订单失败,请稍后再试!");
             return;
         }
 
@@ -208,8 +217,12 @@ public class AlipayController {
 
         } catch (AlipayApiException e) {
             e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("创建订单失败,请稍后再试!");
         } catch (IOException e) {
             e.printStackTrace();
+            response.setContentType("text/plain;charset=UTF-8");
+            response.getWriter().write("系统异常,请稍后再试!");
         }
 
     }
@@ -534,6 +547,7 @@ public class AlipayController {
 
     private ProjectRecode createProjectRecode(String jsonStr) throws Exception {
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+        jsonObject = null;
         String imid = jsonObject.getString("imid");
         logger.info("移动端imid=" + imid);
         Long uuid = null;

+ 3 - 1
donate-service/src/main/webapp/resources/js/pay.js

@@ -124,12 +124,14 @@ var aliPay = function (proId, amount, payWay, imid) {
         url : url,
         dataType : "html",
         //contentType : "application/json;charset=UTF-8",
+        //contentType: "application/x-www-form-urlencoded; charset=utf-8",
         async: false,
         data: {
             jsonStr : jsonStr
         },
         success : function(data) {
-            document.write(data);
+            toastr.error(data);
+            //document.write(data);
         },
         error : function() {
             toastr.error('系统异常,请联系客服!');