From 71887fdc13410ab0959d83db573c2bb9ffde0c2d Mon Sep 17 00:00:00 2001 From: xiafang Date: Tue, 3 Nov 2020 11:26:59 +0800 Subject: [PATCH] hotfix --- payment-spring-boot-autoconfigure/pom.xml | 4 + .../autoconfigure/AliPayConfiguration.java | 2 +- .../autoconfigure/PayConfiguration.java | 71 +----------------- .../autoconfigure/WechatPayConfiguration.java | 73 +++++++++++++++++++ 4 files changed, 80 insertions(+), 70 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/WechatPayConfiguration.java diff --git a/payment-spring-boot-autoconfigure/pom.xml b/payment-spring-boot-autoconfigure/pom.xml index a561726..a662222 100644 --- a/payment-spring-boot-autoconfigure/pom.xml +++ b/payment-spring-boot-autoconfigure/pom.xml @@ -82,6 +82,10 @@ bcprov-jdk15to18 true + + com.alipay.sdk + alipay-sdk-java + \ No newline at end of file diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/AliPayConfiguration.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/AliPayConfiguration.java index c6dbeb5..8220429 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/AliPayConfiguration.java +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/AliPayConfiguration.java @@ -1,6 +1,6 @@ package com.enongm.dianji.payment.autoconfigure; -import com.enongm.dianji.payment.autoconfigure.AliPayProperties; + import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/PayConfiguration.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/PayConfiguration.java index d8deaeb..25a9c6a 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/PayConfiguration.java +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/PayConfiguration.java @@ -1,80 +1,13 @@ package com.enongm.dianji.payment.autoconfigure; -import com.enongm.dianji.payment.wechat.v2.WechatPayV2Service; -import com.enongm.dianji.payment.wechat.v3.KeyPairFactory; -import com.enongm.dianji.payment.wechat.v3.SignatureProvider; -import com.enongm.dianji.payment.wechat.v3.WechatPayV3Service; -import com.enongm.dianji.payment.wechat.v3.model.WechatMetaBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; /** * @author Dax * @since 14:47 */ @Configuration - +@Import({WechatPayConfiguration.class,AliPayConfiguration.class}) public class PayConfiguration { - /** - * The type Wechat pay configuration. - */ - @Configuration - @ConditionalOnProperty(prefix = "wechat.pay", name = "v3.app-id") - @EnableConfigurationProperties(WechatPayProperties.class) - static class WechatPayConfiguration { - private static final String CERT_ALIAS = "Tenpay Certificate"; - - /** - * 微信支付公私钥 以及序列号等元数据. - * - * @param wechatPayProperties the wechat pay properties - * @return the wechat cert bean - */ - @Bean - WechatMetaBean wechatMetaBean(WechatPayProperties wechatPayProperties) { - - String certPath = wechatPayProperties.getV3().getCertPath(); - String mchId = wechatPayProperties.getV3().getMchId(); - WechatMetaBean wechatMetaBean = new KeyPairFactory().createPKCS12(certPath, CERT_ALIAS, mchId); - wechatMetaBean.setWechatPayProperties(wechatPayProperties); - return wechatMetaBean; - } - - /** - * 微信支付V3签名工具. - * - * @param wechatMetaBean the wechat meta bean - * @return the signature provider - */ - @Bean - SignatureProvider signatureProvider(WechatMetaBean wechatMetaBean) { - return new SignatureProvider(wechatMetaBean); - } - - - /** - * 微信支付V2 只实现V3支付没有的支付业务。 - * - * @param wechatPayProperties the wechat pay properties - * @return the wechat pay v 2 service - */ - @Bean - public WechatPayV2Service wechatPayV2Service(WechatPayProperties wechatPayProperties) { - System.out.println("wechatPayProperties = " + wechatPayProperties); - return new WechatPayV2Service(wechatPayProperties); - } - - /** - * 微信支付V3 全量支持. - * - * @param signatureProvider the signature provider - * @return the wechat pay service - */ - @Bean - public WechatPayV3Service wechatPayService(SignatureProvider signatureProvider) { - return new WechatPayV3Service(signatureProvider); - } - } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/WechatPayConfiguration.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/WechatPayConfiguration.java new file mode 100644 index 0000000..9655093 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/autoconfigure/WechatPayConfiguration.java @@ -0,0 +1,73 @@ +package com.enongm.dianji.payment.autoconfigure; + + + +import com.enongm.dianji.payment.wechat.v2.WechatPayV2Service; +import com.enongm.dianji.payment.wechat.v3.KeyPairFactory; +import com.enongm.dianji.payment.wechat.v3.SignatureProvider; +import com.enongm.dianji.payment.wechat.v3.WechatPayV3Service; +import com.enongm.dianji.payment.wechat.v3.model.WechatMetaBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * The type Wechat pay configuration. + */ +@Configuration +@ConditionalOnProperty(prefix = "wechat.pay", name = "v3.app-id") +@EnableConfigurationProperties(WechatPayProperties.class) +public class WechatPayConfiguration { + private static final String CERT_ALIAS = "Tenpay Certificate"; + + /** + * 微信支付公私钥 以及序列号等元数据. + * + * @param wechatPayProperties the wechat pay properties + * @return the wechat cert bean + */ + @Bean + WechatMetaBean wechatMetaBean(WechatPayProperties wechatPayProperties) { + + String certPath = wechatPayProperties.getV3().getCertPath(); + String mchId = wechatPayProperties.getV3().getMchId(); + WechatMetaBean wechatMetaBean = new KeyPairFactory().createPKCS12(certPath, CERT_ALIAS, mchId); + wechatMetaBean.setWechatPayProperties(wechatPayProperties); + return wechatMetaBean; + } + + /** + * 微信支付V3签名工具. + * + * @param wechatMetaBean the wechat meta bean + * @return the signature provider + */ + @Bean + SignatureProvider signatureProvider(WechatMetaBean wechatMetaBean) { + return new SignatureProvider(wechatMetaBean); + } + + + /** + * 微信支付V2 只实现V3支付没有的支付业务。 + * + * @param wechatPayProperties the wechat pay properties + * @return the wechat pay v 2 service + */ + @Bean + public WechatPayV2Service wechatPayV2Service(WechatPayProperties wechatPayProperties) { + return new WechatPayV2Service(wechatPayProperties); + } + + /** + * 微信支付V3 全量支持. + * + * @param signatureProvider the signature provider + * @return the wechat pay service + */ + @Bean + public WechatPayV3Service wechatPayService(SignatureProvider signatureProvider) { + return new WechatPayV3Service(signatureProvider); + } +}