guomengjiao 1 month ago
parent
commit
bab7df3380

+ 5 - 5
renren-admin/src/main/java/io/renren/modules/qmgj/wxpayutil/NewWxPayUtil.java

@@ -1,6 +1,6 @@
 package io.renren.modules.qmgj.wxpayutil;
 
-import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+import com.wechat.pay.java.core.RSAPublicKeyConfig;
 import com.wechat.pay.java.core.notification.NotificationParser;
 import com.wechat.pay.java.core.notification.RequestParam;
 import com.wechat.pay.java.service.transferbatch.TransferBatchService;
@@ -24,8 +24,8 @@ import java.io.InputStreamReader;
 @Component
 public class NewWxPayUtil {
 
-    @Resource(name = "rsaAutoCertificateConfig")
-    private RSAAutoCertificateConfig rsaAutoCertificateConfig;
+    @Resource(name = "rsaPublicKeyConfig")
+    private RSAPublicKeyConfig rsaPublicKeyConfig;
     @Resource
     private NewWxPayProperties newWxPayProperties;
 
@@ -63,7 +63,7 @@ public class NewWxPayUtil {
                 .body(s1)
                 .build();
 
-        NotificationParser parser = new NotificationParser(rsaAutoCertificateConfig);
+        NotificationParser parser = new NotificationParser(rsaPublicKeyConfig);
         return parser.parse(requestParam, TransferNotification.class);
     }
 
@@ -84,7 +84,7 @@ public class NewWxPayUtil {
         if (StringUtils.isBlank(request.getNotifyUrl())) {
             request.setNotifyUrl(PropertiesParameter.PROP.getProperty("pay.notify.transfer.url"));
         }
-        TransferBatchService service = new TransferBatchService.Builder().config(rsaAutoCertificateConfig).build();
+        TransferBatchService service = new TransferBatchService.Builder().config(rsaPublicKeyConfig).build();
         try {
             return service.initiateBatchTransfer(request);
         } catch (Exception e) {

+ 6 - 5
renren-admin/src/main/java/io/renren/modules/wechat/config/NewWxPayConfig.java

@@ -1,7 +1,6 @@
 package io.renren.modules.wechat.config;
 
-import com.wechat.pay.java.core.Config;
-import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+import com.wechat.pay.java.core.RSAPublicKeyConfig;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -14,14 +13,16 @@ public class NewWxPayConfig {
     @Resource
     private NewWxPayProperties newWxPayProperties;
 
-    @Bean(name = "rsaAutoCertificateConfig")
+    @Bean(name = "rsaPublicKeyConfig")
     @ConditionalOnBean(NewWxPayProperties.class)
-    public RSAAutoCertificateConfig rsaPublicKeyConfig() {
-        RSAAutoCertificateConfig config = new RSAAutoCertificateConfig.Builder()
+    public RSAPublicKeyConfig rsaPublicKeyConfig() {
+        RSAPublicKeyConfig config = new RSAPublicKeyConfig.Builder()
             .merchantId(newWxPayProperties.getMchId())
             .privateKeyFromPath(newWxPayProperties.getPrivateKeyPath())
             .merchantSerialNumber(newWxPayProperties.getCertSerialNo())
             .apiV3Key(newWxPayProperties.getApiv3())
+            .publicKeyFromPath(newWxPayProperties.getPublicKeyPath())
+            .publicKeyId(newWxPayProperties.getPublicKeyId())
             .build();
         return config;
     }

+ 8 - 0
renren-admin/src/main/java/io/renren/modules/wechat/config/NewWxPayProperties.java

@@ -55,5 +55,13 @@ public class NewWxPayProperties
      */
     private String privateKeyPath;
 
+    /**
+     * 公有证书ID
+     */
+    private String publicKeyId;
 
+    /**
+     * 公有证书
+     */
+    private String publicKeyPath;
 }

+ 7 - 5
renren-admin/src/main/resources/application.yml

@@ -94,11 +94,13 @@ wx:
     tokenUrl: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}
     sendUrl: https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
   pay:
-    appId: wx0ca047da2ecada85 #公司的:wxd15dbb580e6f1cd3  客户的:wx3f5fa98c5edf8718
-    mchId: 1703980824 #公司的:1640577480  客户的:1703980824
+    appId: wx0ca047da2ecada85
+    mchId: 1729991917
     mchKey: #微信支付商户密钥
     subAppId: #服务商模式下的子商户公众账号ID
     subMchId: #服务商模式下的子商户号
-    apiv3: 5Bc8eR7zQ1X9gK3lMp2vN6sD4hJ0fAqW #公司的:7f279a5423a15118e9cb1fc381631f61   客户的:5Bc8eR7zQ1X9gK3lMp2vN6sD4hJ0fAqW
-    certSerialNo: 5C8AB18A9CC11514B1343E422C0C57D620B157DC #证书序列号公司的:5DDEE5F70C50743B6B3BFC92263696D2A68AC951,客户的:5C8AB18A9CC11514B1343E422C0C57D620B157DC
-    privateKeyPath: "ruoyi-admin/src/main/resources/cert/apiclient_key.pem"
+    apiv3: 7x9Fp2QaZ5rT8yLbN3cK6mW4sV1dG0jH
+    certSerialNo: 536819F759F86C240ED3F0BA79FB0B798E6444DB
+    privateKeyPath: "renren-admin/src/main/resources/statics/wxpay/prod/apiclient_key.pem"
+    publicKeyId: PUB_KEY_ID_0117299919172025101600212054002404
+    publicKeyPath: "renren-admin/src/main/resources/statics/wxpay/prod/pub_key.pem"

+ 9 - 0
renren-admin/src/main/resources/statics/wxpay/prod/pub_key.pem

@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAscyUiUzZysATfrJ6IHjt
+8EKAzdjQSoW5MU3R7C8BNSl0Q3LfhET56tZ2lrDdfMjarXRCjq7hIvvIUwhc+qps
+LAOZmO97BOxYQNDNem7KPpW9mwpjjktkuhsTq0M3mZCay3sJq1SAoMbMnuF+1PDB
+YFxpqTMRTXEKpM+ZCIVNm8KDP9lSO9nfdf6cq8Uuj+CmtBqimgwWBvMJi3AQDJr/
+kl3t/jtYvIwplGApZuSnItfT1CcdAK11e3hPtbhGtne40pwXRPidf6ZKRuBtlL4B
+Bhm2ZAgcKSGl8UoduH5kTiJnGguMly47plfkagh3Yw/uPMbWNkB+SswXctgJQ45e
+HwIDAQAB
+-----END PUBLIC KEY-----