Pārlūkot izejas kodu

fix: 支付分回调解析时使用JsonObject接收解密数据而非String

wxNotificationParser.parse()解密后返回JSON对象{...},传入String.class
会导致Gson报错"Expected a string but was BEGIN_OBJECT"。
改为JsonObject.class接收后再toString()获取JSON字符串。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 nedēļas atpakaļ
vecāks
revīzija
8a9069fe3e

+ 4 - 2
haha-service/src/main/java/com/haha/service/payment/payscore/impl/WxPayScoreStrategy.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.gson.JsonObject;
 import com.haha.common.enums.PaymentChannel;
 import com.haha.service.payment.config.WxPayConfig;
 import com.haha.service.payment.payscore.*;
@@ -687,8 +688,9 @@ public class WxPayScoreStrategy implements PayScoreStrategy {
                     .build();
 
             // SDK 自动完成签名验证 + AES-256-GCM 解密
-            // 支付分回调数据结构与普通支付不同,使用 String.class 获取解密后的 JSON
-            String decryptedJson = wxNotificationParser.parse(requestParam, String.class);
+            // 解密后是 JSON 对象,需要用 JsonObject 接收而不能用 String
+            JsonObject decryptedData = wxNotificationParser.parse(requestParam, JsonObject.class);
+            String decryptedJson = decryptedData.toString();
             log.info("[微信支付分] 回调解密数据: {}", decryptedJson);
 
             // 解析 JSON