mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-18 07:53:41 +08:00
exception handler
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user