Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ private void configApp(WxChannelDefaultConfigImpl config, WxChannelSinglePropert
config.setAesKey(aesKey);
}
config.setStableAccessToken(useStableAccessToken);
config.setApiHostUrl(StringUtils.trimToNull(wxChannelSingleProperties.getApiHostUrl()));
config.setAccessTokenUrl(StringUtils.trimToNull(wxChannelSingleProperties.getAccessTokenUrl()));
}

private void configHttp(WxChannelDefaultConfigImpl config, WxChannelMultiProperties.ConfigStorage storage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ public class WxChannelSingleProperties implements Serializable {
* 是否使用稳定版 Access Token
*/
private boolean useStableAccessToken = false;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
* 例如:http://proxy.company.com:8080/oauth/token
*/
private String accessTokenUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ protected WxChannelDefaultConfigImpl config(WxChannelDefaultConfigImpl config, W
config.setAesKey(StringUtils.trimToNull(properties.getAesKey()));
config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat()));
config.setStableAccessToken(properties.isUseStableAccessToken());
config.setApiHostUrl(StringUtils.trimToNull(properties.getApiHostUrl()));
config.setAccessTokenUrl(StringUtils.trimToNull(properties.getAccessTokenUrl()));

WxChannelProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public class WxChannelProperties {
*/
private boolean useStableAccessToken = false;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
* 例如:http://proxy.company.com:8080/oauth/token
*/
private String accessTokenUrl;

/**
* 存储策略
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ private void configCorp(WxCpDefaultConfigImpl config, WxCpSingleProperties wxCpS
if (StringUtils.isNotBlank(msgAuditLibPath)) {
config.setMsgAuditLibPath(msgAuditLibPath);
}
if (StringUtils.isNotBlank(wxCpSingleProperties.getBaseApiUrl())) {
config.setBaseApiUrl(wxCpSingleProperties.getBaseApiUrl());
}
}

private void configHttp(WxCpDefaultConfigImpl config, WxCpMultiProperties.ConfigStorage storage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ public class WxCpSingleProperties implements Serializable {
* 微信企业号应用 会话存档类库路径
*/
private String msgAuditLibPath;

/**
* 自定义企业微信服务器baseUrl,用于替换默认的 https://qyapi.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String baseApiUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public class WxCpProperties {
*/
private String msgAuditLibPath;

/**
* 自定义企业微信服务器baseUrl,用于替换默认的 https://qyapi.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String baseApiUrl;

/**
* 配置存储策略,默认内存
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ protected WxCpDefaultConfigImpl config(WxCpDefaultConfigImpl config, WxCpPropert
if (StringUtils.isNotBlank(msgAuditLibPath)) {
config.setMsgAuditLibPath(msgAuditLibPath);
}
if (StringUtils.isNotBlank(properties.getBaseApiUrl())) {
config.setBaseApiUrl(properties.getBaseApiUrl());
}

WxCpProperties.ConfigStorage storage = properties.getConfigStorage();
String httpProxyHost = storage.getHttpProxyHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private void configApp(WxMaDefaultConfigImpl config, WxMaSingleProperties proper
}
config.setMsgDataFormat(properties.getMsgDataFormat());
config.useStableAccessToken(useStableAccessToken);
config.setApiHostUrl(StringUtils.trimToNull(properties.getApiHostUrl()));
config.setAccessTokenUrl(StringUtils.trimToNull(properties.getAccessTokenUrl()));
}

private void configHttp(WxMaDefaultConfigImpl config, WxMaMultiProperties.ConfigStorage storage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@ public class WxMaSingleProperties implements Serializable {
* 是否使用稳定版 Access Token
*/
private boolean useStableAccessToken = false;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
* 例如:http://proxy.company.com:8080/oauth/token
*/
private String accessTokenUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ protected WxMaDefaultConfigImpl config(WxMaDefaultConfigImpl config, WxMaPropert
config.setAesKey(StringUtils.trimToNull(properties.getAesKey()));
config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat()));
config.useStableAccessToken(properties.isUseStableAccessToken());
config.setApiHostUrl(StringUtils.trimToNull(properties.getApiHostUrl()));
config.setAccessTokenUrl(StringUtils.trimToNull(properties.getAccessTokenUrl()));

WxMaProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ public class WxMaProperties {
*/
private boolean useStableAccessToken = false;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
* 例如:http://proxy.company.com:8080/oauth/token
*/
private String accessTokenUrl;

/**
* 存储策略
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
import org.apache.commons.lang3.StringUtils;

/**
* @author yl
Expand Down Expand Up @@ -31,6 +32,10 @@ protected WxOpenInMemoryConfigStorage config(WxOpenInMemoryConfigStorage config,
config.setRetrySleepMillis(retrySleepMillis);
config.setMaxRetryTimes(maxRetryTimes);

// 设置URL配置
config.setApiHostUrl(StringUtils.trimToNull(properties.getApiHostUrl()));
config.setAccessTokenUrl(StringUtils.trimToNull(properties.getAccessTokenUrl()));

// 设置自定义的HttpClient超时配置
ApacheHttpClientBuilder clientBuilder = config.getApacheHttpClientBuilder();
if (clientBuilder == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public class WxOpenProperties {
*/
private String aesKey;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
* 例如:http://proxy.company.com:8080/oauth/token
*/
private String accessTokenUrl;

/**
* 存储策略.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ public WxPayService wxPayService() {
payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
//以下是apiv3以及支付分相关
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
payConfig.setPayScorePermissionNotifyUrl(StringUtils.trimToNull(this.properties.getPayScorePermissionNotifyUrl()));
payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
payConfig.setCertSerialNo(StringUtils.trimToNull(this.properties.getCertSerialNo()));
payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiv3Key()));
payConfig.setPublicKeyId(StringUtils.trimToNull(this.properties.getPublicKeyId()));
payConfig.setPublicKeyPath(StringUtils.trimToNull(this.properties.getPublicKeyPath()));
payConfig.setApiHostUrl(StringUtils.trimToNull(this.properties.getApiHostUrl()));

wxPayService.setConfig(payConfig);
return wxPayService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ public class WxPayProperties {
*/
private String apiv3Key;

/**
* 微信支付异步回调地址,通知url必须为直接可访问的url,不能携带参数
*/
private String notifyUrl;

/**
* 微信支付分回调地址
*/
private String payScoreNotifyUrl;

/**
* 微信支付分授权回调地址
*/
private String payScorePermissionNotifyUrl;

/**
* apiv3 商户apiclient_key.pem
*/
Expand All @@ -90,4 +100,10 @@ public class WxPayProperties {
*/
private boolean useSandboxEnv;

/**
* 自定义API主机地址,用于替换默认的 https://api.mch.weixin.qq.com
* 例如:http://proxy.company.com:8080
*/
private String apiHostUrl;

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
*/
private int maxRetryTimes = 5;

/**
* 自定义API主机地址,用于替换默认的 https://api.weixin.qq.com
*/
private String apiHostUrl;

/**
* 自定义获取AccessToken地址,用于向自定义统一服务获取AccessToken
*/
private String accessTokenUrl;

private ApacheHttpClientBuilder apacheHttpClientBuilder;

private Map<String, Token> authorizerRefreshTokens = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -290,6 +300,13 @@ private WxOpenInnerConfigStorage(WxOpenConfigStorage wxOpenConfigStorage, String
this.accessTokenLock = wxOpenConfigStorage.getLockByKey(appId + ":accessTokenLock");
this.jsapiTicketLock = wxOpenConfigStorage.getLockByKey(appId + ":jsapiTicketLock");
this.cardApiTicketLock = wxOpenConfigStorage.getLockByKey(appId + ":cardApiTicketLock");

// 自动获取外层配置的URL设置
if (wxOpenConfigStorage instanceof WxOpenInMemoryConfigStorage) {
WxOpenInMemoryConfigStorage parentConfig = (WxOpenInMemoryConfigStorage) wxOpenConfigStorage;
this.apiHostUrl = parentConfig.getApiHostUrl();
this.accessTokenUrl = parentConfig.getAccessTokenUrl();
}
}

@Override
Expand Down Expand Up @@ -637,5 +654,25 @@ public WxMpHostConfig getHostConfig() {
public void setHostConfig(WxMpHostConfig hostConfig) {
this.hostConfig = hostConfig;
}

@Override
public String getApiHostUrl() {
return this.apiHostUrl;
}

@Override
public void setApiHostUrl(String apiHostUrl) {
this.apiHostUrl = apiHostUrl;
}

@Override
public String getAccessTokenUrl() {
return this.accessTokenUrl;
}

@Override
public void setAccessTokenUrl(String accessTokenUrl) {
this.accessTokenUrl = accessTokenUrl;
}
}
}
Loading