mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 #3242 【微信支付】修改自动更新证书接口地址,使用WxPayConfig设置的payBaseUrl
This commit is contained in:
parent
b87afb64c9
commit
573f0f5e6f
@ -278,7 +278,7 @@ public class WxPayConfig {
|
|||||||
|
|
||||||
AutoUpdateCertificatesVerifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
|
AutoUpdateCertificatesVerifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
|
||||||
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||||
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(), wxPayHttpProxy);
|
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(), this.getPayBaseUrl(), wxPayHttpProxy);
|
||||||
|
|
||||||
WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create()
|
WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create()
|
||||||
.withMerchant(mchId, certSerialNo, merchantPrivateKey)
|
.withMerchant(mchId, certSerialNo, merchantPrivateKey)
|
||||||
|
@ -46,7 +46,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
|
|||||||
/**
|
/**
|
||||||
* 证书下载地址
|
* 证书下载地址
|
||||||
*/
|
*/
|
||||||
private static final String CERT_DOWNLOAD_PATH = "https://api.mch.weixin.qq.com/v3/certificates";
|
private static final String CERT_DOWNLOAD_PATH = "/v3/certificates";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上次更新时间
|
* 上次更新时间
|
||||||
@ -64,6 +64,8 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
|
|||||||
|
|
||||||
private final byte[] apiV3Key;
|
private final byte[] apiV3Key;
|
||||||
|
|
||||||
|
private String payBaseUrl ;
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,18 +95,19 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
|
|||||||
private final int minutes;
|
private final int minutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key) {
|
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, String payBaseUrl) {
|
||||||
this(credentials, apiV3Key, TimeInterval.OneHour.getMinutes());
|
this(credentials, apiV3Key, TimeInterval.OneHour.getMinutes(), payBaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval) {
|
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval, String payBaseUrl) {
|
||||||
this(credentials,apiV3Key,minutesInterval,null);
|
this(credentials, apiV3Key, minutesInterval, payBaseUrl, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval,WxPayHttpProxy wxPayHttpProxy) {
|
public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key, int minutesInterval, String payBaseUrl, WxPayHttpProxy wxPayHttpProxy) {
|
||||||
this.credentials = credentials;
|
this.credentials = credentials;
|
||||||
this.apiV3Key = apiV3Key;
|
this.apiV3Key = apiV3Key;
|
||||||
this.minutesInterval = minutesInterval;
|
this.minutesInterval = minutesInterval;
|
||||||
|
this.payBaseUrl = payBaseUrl;
|
||||||
this.wxPayHttpProxy = wxPayHttpProxy;
|
this.wxPayHttpProxy = wxPayHttpProxy;
|
||||||
//构造时更新证书
|
//构造时更新证书
|
||||||
try {
|
try {
|
||||||
@ -153,7 +156,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
|
|||||||
|
|
||||||
CloseableHttpClient httpClient = wxPayV3HttpClientBuilder.build();
|
CloseableHttpClient httpClient = wxPayV3HttpClientBuilder.build();
|
||||||
|
|
||||||
HttpGet httpGet = new HttpGet(CERT_DOWNLOAD_PATH);
|
HttpGet httpGet = new HttpGet(this.payBaseUrl + CERT_DOWNLOAD_PATH);
|
||||||
httpGet.addHeader("Accept", "application/json");
|
httpGet.addHeader("Accept", "application/json");
|
||||||
|
|
||||||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||||||
|
Loading…
Reference in New Issue
Block a user