|
|
@@ -10,9 +10,6 @@ import lombok.Setter;
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
@ConfigurationProperties(prefix = "alipay")
|
|
|
@Component
|
|
|
@Getter
|
|
|
@@ -35,34 +32,6 @@ public class AlipayTools {
|
|
|
|
|
|
private static String signType="RSA2";
|
|
|
|
|
|
- /**
|
|
|
- * @Author: DingXiaoyu
|
|
|
- * @Date: 16:02 2024/1/27
|
|
|
- * 用来测试支付宝沙箱
|
|
|
- */
|
|
|
- public void testPay(String name , Double price, HttpServletResponse httpResponse){
|
|
|
- AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,appPrivateKey,format,charset,alipayPublicKey,signType);
|
|
|
- AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
|
|
- request.setNotifyUrl(notifyUrl);
|
|
|
- String replace = UUID.randomUUID().toString().replace("-", "");
|
|
|
- JSONObject bizContent = new JSONObject();
|
|
|
- bizContent.put("out_trade_no", replace);
|
|
|
- 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);
|
|
|
- httpResponse.setContentType("text/html;charset=" + charset);
|
|
|
- httpResponse.getWriter().write(form);
|
|
|
- httpResponse.getWriter().flush();
|
|
|
- httpResponse.getWriter().close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
/**
|
|
|
* @Author: DingXiaoyu
|
|
|
* @Date: 11:25 2024/1/31
|