|
|
@@ -63,28 +63,12 @@ public class AlipayTools {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// public String pay(String tradeName, String name , Double price){
|
|
|
-// AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,appPrivateKey,format,charset,alipayPublicKey,signType);
|
|
|
-// AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
|
|
-// request.setNotifyUrl(notifyUrl);
|
|
|
-// JSONObject bizContent = new JSONObject();
|
|
|
-// bizContent.put("out_trade_no", tradeName); //订单id-优惠券id
|
|
|
-// bizContent.put("total_amount", price);
|
|
|
-// bizContent.put("subject", name);
|
|
|
-// bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
|
|
|
-// request.setBizContent(bizContent.toString());
|
|
|
-// String form;
|
|
|
-// try {
|
|
|
-// form = alipayClient.pageExecute(request).getBody();
|
|
|
-// System.out.println(form);
|
|
|
-// } catch (Exception e) {
|
|
|
-// throw BlueWhaleException.payError();
|
|
|
-// }
|
|
|
-// return form;
|
|
|
-// }
|
|
|
-
|
|
|
- public void pay(String tradeName, String name , Double price, HttpServletResponse httpResponse){
|
|
|
+ /**
|
|
|
+ * @Author: DingXiaoyu
|
|
|
+ * @Date: 11:25 2024/1/31
|
|
|
+ * 使用支付宝沙箱
|
|
|
+ */
|
|
|
+ public String pay(String tradeName, String name , Double price){
|
|
|
AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,appPrivateKey,format,charset,alipayPublicKey,signType);
|
|
|
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
|
|
request.setNotifyUrl(notifyUrl);
|
|
|
@@ -97,12 +81,9 @@ public class AlipayTools {
|
|
|
String form;
|
|
|
try {
|
|
|
form = alipayClient.pageExecute(request).getBody();
|
|
|
- httpResponse.setContentType("text/html;charset=" + charset);
|
|
|
- httpResponse.getWriter().write(form);
|
|
|
- httpResponse.getWriter().flush();
|
|
|
- httpResponse.getWriter().close();
|
|
|
} catch (Exception e) {
|
|
|
throw BlueWhaleException.payError();
|
|
|
}
|
|
|
+ return form;
|
|
|
}
|
|
|
}
|