feat: 日常维护

- 支付宝增加证书路径的选择方式
- 微信支付 《支付通知API》新增优惠功能(promotion_detail)字段
This commit is contained in:
felord.cn
2021-05-09 22:13:10 +08:00
parent 5646bab7e6
commit 7470787441
9 changed files with 40 additions and 29 deletions

View File

@@ -11,7 +11,7 @@
<dependency> <dependency>
<groupId>cn.felord</groupId> <groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId> <artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
</dependency> </dependency>
``` ```

View File

@@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>cn.felord</groupId> <groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId> <artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
</dependency> </dependency>
``` ```
## 采用技术 ## 采用技术

View File

@@ -4,7 +4,7 @@
<dependency> <dependency>
<groupId>cn.felord</groupId> <groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId> <artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
</dependency> </dependency>
``` ```
> 基于 **Spring Boot 2.x** > 基于 **Spring Boot 2.x**

View File

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

View File

@@ -33,9 +33,9 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.function.Function;
/** /**
* @author felord.cn * @author felord.cn
@@ -56,34 +56,33 @@ public class AliPayConfiguration {
CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
propertyMapper.from(v1::getServerUrl).to(certAlipayRequest::setServerUrl); propertyMapper.from(v1::getServerUrl).to(certAlipayRequest::setServerUrl);
propertyMapper.from(v1::getAppId).to(certAlipayRequest::setAppId); propertyMapper.from(v1::getAppId).to(certAlipayRequest::setAppId);
propertyMapper.from(v1::getAppPrivateKeyPath).as(this::appRSAPrivateKey).to(certAlipayRequest::setPrivateKey); propertyMapper.from(v1::getAppPrivateKeyPath)
.as(this::loadFile)
.to(certAlipayRequest::setPrivateKey);
propertyMapper.from(v1::getFormat).to(certAlipayRequest::setFormat); propertyMapper.from(v1::getFormat).to(certAlipayRequest::setFormat);
propertyMapper.from(v1::getCharset).to(certAlipayRequest::setCharset); propertyMapper.from(v1::getCharset).to(certAlipayRequest::setCharset);
propertyMapper.from(v1::getSignType).to(certAlipayRequest::setSignType); propertyMapper.from(v1::getSignType).to(certAlipayRequest::setSignType);
propertyMapper.from(v1::getAppCertPublicKeyPath).as(this::getContentFromClassPath).to(certAlipayRequest::setCertContent);
propertyMapper.from(v1::getAlipayPublicCertPath).as(this::getContentFromClassPath).to(certAlipayRequest::setAlipayPublicCertContent); Function<String,String> certStrategyFunc = v1.isClasspathUsed()?this::loadFile:s -> s;
propertyMapper.from(v1::getAlipayRootCertPath).as(this::getContentFromClassPath).to(certAlipayRequest::setRootCertContent);
propertyMapper.from(v1::getAppCertPublicKeyPath)
.as(certStrategyFunc)
.to(certAlipayRequest::setCertContent);
propertyMapper.from(v1::getAlipayPublicCertPath)
.as(certStrategyFunc)
.to(certAlipayRequest::setAlipayPublicCertContent);
propertyMapper.from(v1::getAlipayRootCertPath)
.as(certStrategyFunc)
.to(certAlipayRequest::setRootCertContent);
return new DefaultAlipayClient(certAlipayRequest); return new DefaultAlipayClient(certAlipayRequest);
} }
private String getContentFromClassPath(String classPath) { private String loadFile(String classPath) {
ClassPathResource resource = new ClassPathResource(classPath);
try (InputStreamReader in = new InputStreamReader(resource.getInputStream())) {
return IOUtils.toString(in);
} catch (IOException e) {
log.error("ali pay root cert is invalid ,{}", e.getMessage());
throw new PayException("ali pay root cert path is invalid");
}
}
private String appRSAPrivateKey(String classPath) {
ClassPathResource resource = new ClassPathResource(classPath); ClassPathResource resource = new ClassPathResource(classPath);
try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream())) { try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream())) {
try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { return IOUtils.toString(inputStreamReader);
return bufferedReader.readLine();
}
} catch (IOException e) { } catch (IOException e) {
log.error("ali pay app private key is required ,{}", e.getMessage()); log.error("ali pay app private key is required ,{}", e.getMessage());
throw new PayException("ali pay app private key is required"); throw new PayException("ali pay app private key is required");

View File

@@ -70,6 +70,10 @@ public class AliPayProperties {
* charset default utf-8 * charset default utf-8
*/ */
private String charset = "utf-8"; private String charset = "utf-8";
/**
* use classpath or not ,default true
*/
private boolean classpathUsed = true;
/** /**
* alipay public cert path * alipay public cert path
*/ */

View File

@@ -19,6 +19,7 @@ package cn.felord.payment.wechat.v3.model.combine;
import cn.felord.payment.wechat.enumeration.TradeState; import cn.felord.payment.wechat.enumeration.TradeState;
import cn.felord.payment.wechat.enumeration.TradeType; import cn.felord.payment.wechat.enumeration.TradeType;
import cn.felord.payment.wechat.v3.model.PromotionDetail;
import cn.felord.payment.wechat.v3.model.SceneInfo; import cn.felord.payment.wechat.v3.model.SceneInfo;
import lombok.Data; import lombok.Data;
@@ -125,6 +126,13 @@ public class CombineTransactionConsumeData {
*/ */
private String transactionId; private String transactionId;
/**
* 优惠功能,子单有核销优惠券时有返回
*
* @since 1.0.11.RELEASE
*/
private List<PromotionDetail> promotionDetail;
} }
/** /**

View File

@@ -5,11 +5,11 @@
<parent> <parent>
<groupId>cn.felord</groupId> <groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId> <artifactId>payment-spring-boot</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
</parent> </parent>
<artifactId>payment-spring-boot-starter</artifactId> <artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion> <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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cn.felord</groupId> <groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId> <artifactId>payment-spring-boot</artifactId>
<version>1.0.10.RELEASE</version> <version>1.0.11.RELEASE</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -76,7 +76,7 @@
<oss-starter.version>1.0.0.RELEASE</oss-starter.version> <oss-starter.version>1.0.0.RELEASE</oss-starter.version>
<lombok.verison>1.18.12</lombok.verison> <lombok.verison>1.18.12</lombok.verison>
<jackson.version>2.9.10</jackson.version> <jackson.version>2.9.10</jackson.version>
<bcprov.version>1.66</bcprov.version> <bcprov.version>1.67</bcprov.version>
<jackson.version>2.11.4</jackson.version> <jackson.version>2.11.4</jackson.version>
<httpclient.version>4.5.13</httpclient.version> <httpclient.version>4.5.13</httpclient.version>
</properties> </properties>