Pārlūkot izejas kodu

refactor(支付SDK): 优化支付请求处理逻辑并更新生产环境API地址

- 将生产环境API地址从vsp更新为syb域名
- 统一签名生成逻辑,根据SIGN_TYPE动态选择密钥
- 重命名响应变量以提高可读性
- 添加生产环境注释说明
- 移除冗余代码并保持与测试代码逻辑一致
skyfffire 1 nedēļu atpakaļ
vecāks
revīzija
b3fdb15936

+ 11 - 8
src/main/java/common/utils/tl/AllinpaySDK.java

@@ -35,7 +35,7 @@ public class AllinpaySDK {
             HttpConnectionUtil http = new HttpConnectionUtil(SybConstants.SYB_APIURL + "/h5unionpay/unionorder");
             http.init();
             
-            // 构建请求参数
+            // 构建请求参数 - 使用与测试代码相同的逻辑
             TreeMap<String, String> params = new TreeMap<>();
             if (!SybUtil.isEmpty(SybConstants.SYB_ORGID)) {
                 params.put("orgid", SybConstants.SYB_ORGID);
@@ -59,18 +59,21 @@ public class AllinpaySDK {
             if (!SybUtil.isEmpty(truename)) params.put("truename", truename);
             if (!SybUtil.isEmpty(idno)) params.put("idno", idno);
 
-            // 生成签名
-            String appkey = getAppKey();
+            // 生成签名 - 使用与测试代码相同的逻辑
+            String appkey = "MD5".equals(SybConstants.SIGN_TYPE) ? SybConstants.SYB_MD5_APPKEY : 
+                           "RSA".equals(SybConstants.SIGN_TYPE) ? SybConstants.SYB_RSACUSPRIKEY : 
+                           SybConstants.SYB_SM2PPRIVATEKEY;
+            
             params.put("sign", SybUtil.unionSign(params, appkey, SybConstants.SIGN_TYPE));
 
-            // 发送请求
-            byte[] responseBytes = http.postParams(params, true);
-            String response = new String(responseBytes, "UTF-8");
+            // 发送请求 - 使用与测试代码相同的逻辑
+            byte[] response = http.postParams(params, true);
+            String responseStr = new String(response, "UTF-8");
             
             http.destory();
 
             // 处理响应
-            Map<String, String> resultMap = SybPayService.handleResult(response);
+            Map<String, String> resultMap = SybPayService.handleResult(responseStr);
             
             if ("SUCCESS".equals(resultMap.get("retcode"))) {
                 String payUrl = resultMap.get("payinfo");
@@ -492,7 +495,7 @@ public class AllinpaySDK {
         } catch (Exception e) {
             System.out.println("HTTP连接测试异常: " + e.getMessage());
         }
-        
+
         */
     }
 }

+ 3 - 2
src/main/java/common/utils/tl/SybConstants.java

@@ -6,10 +6,11 @@ public class SybConstants {
     public static final String SYB_CUSID = "660222053994DLK";
     public static final String SYB_APPID = "00375513";
     public static final String SYB_MD5_APPKEY = "";
-    public static final String SYB_APIURL = "https://vsp.allinpay.com/apiweb";//生产环境
+    public static final String SYB_APIURL = "https://syb.allinpay.com/apiweb";
     public static final String SYB_RSACUSPRIKEY = "";
     public static final String SYB_RSATLPUBKEY = "";
-
+    
+    //生产环境
     public static final String VERSION = "12";
     public static final String SIGN_TYPE = "SM2";
     //	/**商户sm2私钥,用于向通联发起请求前进行签名**/