exception handler

This commit is contained in:
xiafang
2020-11-04 14:27:04 +08:00
parent 71887fdc13
commit cb98993e8f
15 changed files with 157 additions and 139 deletions

View File

@@ -1,14 +0,0 @@
package com.enongm.dianji.payment.autoconfigure;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author Dax
* @since 14:35
*/
@Configuration
@EnableConfigurationProperties(AliPayProperties.class)
public class AliPayConfiguration {
}

View File

@@ -1,51 +0,0 @@
package com.enongm.dianji.payment.autoconfigure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
/**
* @author Dax
* @since 14:13
*/
@Data
@ConfigurationProperties("ali.pay")
public class AliPayProperties {
/**
* alipay api version 1.0
*/
@NestedConfigurationProperty
private V1 v1;
@Data
public static class V1{
/**
* alipay server
*/
private String serverUrl = "https://openapi.alipay.com/gateway.do";
/**
* your app ID
*/
private String appId;
/**
* your app private key
*/
private String appPrivateKey;
/**
* sign type
*/
private String signType = "md5";
/**
* alipay public cert path
*/
private String alipayPublicCertPath;
/**
* alipay root cert path
*/
private String alipayRootCertPath;
}
}

View File

@@ -1,5 +1,7 @@
package com.enongm.dianji.payment.autoconfigure;
import com.enongm.dianji.payment.alipay.AliPayConfiguration;
import com.enongm.dianji.payment.wechat.WechatPayConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@@ -8,6 +10,6 @@ import org.springframework.context.annotation.Import;
* @since 14:47
*/
@Configuration
@Import({WechatPayConfiguration.class,AliPayConfiguration.class})
@Import({WechatPayConfiguration.class, AliPayConfiguration.class})
public class PayConfiguration {
}

View File

@@ -1,73 +0,0 @@
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);
}
}

View File

@@ -1,59 +0,0 @@
package com.enongm.dianji.payment.autoconfigure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
/**
* The type Wechat pay properties.
*/
@Data
@ConfigurationProperties("wechat.pay")
public class WechatPayProperties {
/**
* wechat pay V3 properties
*/
@NestedConfigurationProperty
private V3 v3;
@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
*/
private String appId;
/**
* app secret for wechat pay is required
*/
private String appSecret;
/**
* app V3 secret is required by wechat pay V3
*/
private String appV3Secret;
/**
* mchId for wechat pay is required
*/
private String mchId;
/**
* partnerKey for wechat pay is optional
*/
private String partnerKey;
/**
* wechat pay certificate Path
*/
private String certPath;
/**
* your pay server domain
*/
private String domain;
}
}