fix: 微信支付能够正确根据环境条件动态启用了,修复了不配置微信支付时,无法启用支付宝的问题。

1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会影响支付宝的运行。
This commit is contained in:
felord.cn
2021-01-07 21:07:48 +08:00
parent b291dbfa44
commit f1a3683bc6
7 changed files with 82 additions and 6 deletions

View File

@@ -1,3 +1,13 @@
## 1.0.3.RELEASE
- 微信支付
- feat: 完善合单支付账单
1. 增加合单支付-申请交易账单API。
2. 增加合单支付-申请资金账单API。
- fix: #I2BCMZ 合单支付url不正确的问题。
- fix: 微信支付能够正确根据环境条件动态启用了,修复了不配置微信支付时,无法启用支付宝的问题。
1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会影响支付宝的运行。
- refactor: 先享卡优化
## 1.0.2.RELEASE
- 微信支付
- feat: 接入微信支付分

View File

@@ -35,7 +35,7 @@
## 支付宝
### 证书
### 支付宝证书
请注意因为未来**SHA1withRSA**将被淘汰,因此采用最新的**SHA256withRSA**证书,旧的模式将不提供支持。步骤如下:

View File

@@ -5,11 +5,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.2.RELEASE</version>
<version>1.0.3.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-autoconfigure</artifactId>
<version>1.0.2.RELEASE</version>
<version>1.0.3.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -23,6 +23,7 @@ import cn.felord.payment.wechat.v3.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import java.util.Map;
@@ -34,6 +35,7 @@ import java.util.Map;
* @since 1.0.0.RELEASE
*/
@Configuration
@Conditional(WechatPayConfiguredCondition.class)
@EnableConfigurationProperties(WechatPayProperties.class)
public class WechatPayConfiguration {
/**

View File

@@ -0,0 +1,64 @@
/*
*
* Copyright 2019-2021 felord.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* Website:
* https://felord.cn
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cn.felord.payment.wechat;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;
/**
* The type Wechat pay configured condition.
*
* @author felord.cn
* @since 1.0.3.RELEASE
*/
public class WechatPayConfiguredCondition extends SpringBootCondition {
/**
* The constant STRING_WECHAT_V3_MAP.
*/
private static final Bindable<Map<String, WechatPayProperties.V3>> STRING_WECHAT_V3_MAP = Bindable
.mapOf(String.class, WechatPayProperties.V3.class);
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition("Wechat Pay V3 Configured Condition");
Map<String, WechatPayProperties.V3> v3 = getV3(context.getEnvironment());
if (!v3.isEmpty()) {
return ConditionOutcome.match(message.foundExactly("registered wechat mchIds " + v3.values().stream()
.map(WechatPayProperties.V3::getMchId).collect(Collectors.joining(", "))));
}
return ConditionOutcome.noMatch(message.notAvailable("registered wechat pay configs"));
}
private Map<String, WechatPayProperties.V3> getV3(Environment environment) {
return Binder.get(environment).bind("wechat.pay.v3", STRING_WECHAT_V3_MAP)
.orElse(Collections.emptyMap());
}
}

View File

@@ -5,11 +5,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.2.RELEASE</version>
<version>1.0.3.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.2.RELEASE</version>
<version>1.0.3.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.2.RELEASE</version>
<version>1.0.3.RELEASE</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>