mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-19 00:23:43 +08:00
hotfix
This commit is contained in:
@@ -11,6 +11,6 @@ import java.lang.annotation.*;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Import(WechatPayConfiguration.class)
|
||||
public @interface EnableWechatPay {
|
||||
@Import(PayConfiguration.class)
|
||||
public @interface EnableMobilePay {
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dax
|
||||
* @since 14:47
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.enongm.dianji.payment.autoconfigure;
|
||||
|
||||
|
||||
import com.enongm.dianji.payment.wechat.v3.KeyPairFactory;
|
||||
import com.enongm.dianji.payment.wechat.v3.WechatPayV3Service;
|
||||
import com.enongm.dianji.payment.wechat.v2.WechatPayV2Service;
|
||||
import com.enongm.dianji.payment.wechat.v3.SignatureProvider;
|
||||
import com.enongm.dianji.payment.wechat.v3.model.WechatMetaBean;
|
||||
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
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,14 @@ public class WechatPayProperties {
|
||||
|
||||
@Data
|
||||
public static class V3 {
|
||||
/**
|
||||
* set as true in develop mode
|
||||
*/
|
||||
private boolean sandboxMode;
|
||||
/**
|
||||
* set as true in partner mode
|
||||
*/
|
||||
private boolean partnerMode;
|
||||
/**
|
||||
* app id for wechat pay is required
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user