diff --git a/README.md b/README.md index a4ddeee..1d7c7df 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ cn.felord payment-spring-boot-starter - 1.0.10.RELEASE + 1.0.11.RELEASE ``` diff --git a/docs/README.md b/docs/README.md index 302d83f..2e5d488 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,7 +35,7 @@ cn.felord payment-spring-boot-starter - 1.0.10.RELEASE + 1.0.11.RELEASE ``` ## 采用技术 diff --git a/docs/quick_start.md b/docs/quick_start.md index c251fb0..f44643c 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -4,7 +4,7 @@ cn.felord payment-spring-boot-starter - 1.0.10.RELEASE + 1.0.11.RELEASE ``` > 基于 **Spring Boot 2.x** diff --git a/payment-spring-boot-autoconfigure/pom.xml b/payment-spring-boot-autoconfigure/pom.xml index da2fb9b..83fb1c6 100644 --- a/payment-spring-boot-autoconfigure/pom.xml +++ b/payment-spring-boot-autoconfigure/pom.xml @@ -5,11 +5,11 @@ cn.felord payment-spring-boot - 1.0.10.RELEASE + 1.0.11.RELEASE payment-spring-boot-autoconfigure - 1.0.10.RELEASE + 1.0.11.RELEASE jar 4.0.0 diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayConfiguration.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayConfiguration.java index bfc50c5..38e6a86 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayConfiguration.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayConfiguration.java @@ -33,9 +33,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.function.Function; /** * @author felord.cn @@ -56,34 +56,33 @@ public class AliPayConfiguration { CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); propertyMapper.from(v1::getServerUrl).to(certAlipayRequest::setServerUrl); 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::getCharset).to(certAlipayRequest::setCharset); 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); - propertyMapper.from(v1::getAlipayRootCertPath).as(this::getContentFromClassPath).to(certAlipayRequest::setRootCertContent); + + Function certStrategyFunc = v1.isClasspathUsed()?this::loadFile:s -> s; + + 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); } - private String getContentFromClassPath(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) { + private String loadFile(String classPath) { ClassPathResource resource = new ClassPathResource(classPath); try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream())) { - try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { - return bufferedReader.readLine(); - } + return IOUtils.toString(inputStreamReader); } catch (IOException e) { log.error("ali pay app private key is required ,{}", e.getMessage()); throw new PayException("ali pay app private key is required"); diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayProperties.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayProperties.java index f19b5de..4c2b4e2 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayProperties.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/alipay/AliPayProperties.java @@ -70,6 +70,10 @@ public class AliPayProperties { * charset default utf-8 */ private String charset = "utf-8"; + /** + * use classpath or not ,default true + */ + private boolean classpathUsed = true; /** * alipay public cert path */ diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/CombineTransactionConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/CombineTransactionConsumeData.java index 38682ce..279c2f5 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/CombineTransactionConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/CombineTransactionConsumeData.java @@ -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.TradeType; +import cn.felord.payment.wechat.v3.model.PromotionDetail; import cn.felord.payment.wechat.v3.model.SceneInfo; import lombok.Data; @@ -125,6 +126,13 @@ public class CombineTransactionConsumeData { */ private String transactionId; + /** + * 优惠功能,子单有核销优惠券时有返回 + * + * @since 1.0.11.RELEASE + */ + private List promotionDetail; + } /** diff --git a/payment-spring-boot-starter/pom.xml b/payment-spring-boot-starter/pom.xml index dd4975d..6e742a5 100644 --- a/payment-spring-boot-starter/pom.xml +++ b/payment-spring-boot-starter/pom.xml @@ -5,11 +5,11 @@ cn.felord payment-spring-boot - 1.0.10.RELEASE + 1.0.11.RELEASE payment-spring-boot-starter - 1.0.10.RELEASE + 1.0.11.RELEASE jar 4.0.0 diff --git a/pom.xml b/pom.xml index 5d1a7c8..f827c72 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> cn.felord payment-spring-boot - 1.0.10.RELEASE + 1.0.11.RELEASE pom 4.0.0 @@ -76,7 +76,7 @@ 1.0.0.RELEASE 1.18.12 2.9.10 - 1.66 + 1.67 2.11.4 4.5.13