فهرست منبع

fix(payment): testMode flag skips private key loading

User 2 ماه پیش
والد
کامیت
3bac85f835
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      cfc-backend/src/main/java/com/etotem/cfc/service/PaymentService.java

+ 7 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/PaymentService.java

@@ -76,6 +76,9 @@ public class PaymentService implements PaymentServiceInterface {
     @Value("${wechat.notify-url}")
     private String notifyUrl;
 
+    @Value("${wechat.test-mode:false}")
+    private boolean testMode;
+
     private PrivateKey privateKey;
     private final OkHttpClient httpClient;
 
@@ -89,6 +92,10 @@ public class PaymentService implements PaymentServiceInterface {
 
     @PostConstruct
     public void init() {
+        if (testMode) {
+            log.info("微信支付使用测试模式,跳过私钥加载");
+            return;
+        }
         if (privateKeyPath != null && !privateKeyPath.isEmpty()) {
             try (BufferedReader reader = new BufferedReader(new InputStreamReader(
                     new FileInputStream(privateKeyPath), StandardCharsets.UTF_8))) {