mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-17 07:23:41 +08:00
@@ -45,7 +45,7 @@ Starter,支持微信优惠券,代金券、商家券、智慧商圈、商家
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot-starter</artifactId>
|
<artifactId>payment-spring-boot-starter</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot-starter</artifactId>
|
<artifactId>payment-spring-boot-starter</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
## 采用技术
|
## 采用技术
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
* [项目简介](README.md)
|
* [项目简介](README.md)
|
||||||
* [快速接入](quick_start.md)
|
* [快速接入](quick_start.md)
|
||||||
* [JavaDoc](apidocs/index.html ':ignore')
|
* [JavaDoc](apidocs/index.html ':ignore')
|
||||||
* [微信支付V3接口文档](wechat_v3_api.md)
|
* [Payment微信支付V3接口文档](wechat_v3_api.md)
|
||||||
* [日常踩坑](stackoverflow.md)
|
* [日常踩坑](stackoverflow.md)
|
||||||
* [更新日志](changelog.md)
|
* [更新日志](changelog.md)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot-starter</artifactId>
|
<artifactId>payment-spring-boot-starter</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
> 基于 **Spring Boot 2.x**
|
> 基于 **Spring Boot 2.x**
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#### 基础支付
|
#### 基础支付
|
||||||
|
|
||||||
- [x] `WechatDirectPayApi` 基础支付,通过`WechatApiProvider#directPayApi`初始化
|
- [x] `WechatDirectPayApi` 基础支付,通过`WechatApiProvider#directPayApi`初始化
|
||||||
- [x] `jsPay` APP下单
|
- [x] `jsPay` JSAPI/小程序下单
|
||||||
- [x] `appPay` JSAPI/小程序下单
|
- [x] `appPay` APP下单
|
||||||
- [x] `h5Pay` H5下单
|
- [x] `h5Pay` H5下单
|
||||||
- [x] `nativePay` Native下单
|
- [x] `nativePay` Native下单
|
||||||
- [x] 查询订单
|
- [x] 查询订单
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
- [x] `downloadTradeBill` 申请交易账单,直接下载为gzip或者txt文件
|
- [x] `downloadTradeBill` 申请交易账单,直接下载为gzip或者txt文件
|
||||||
- [x] `downloadFundFlowBill` 申请资金账单,直接下载为gzip或者txt文件
|
- [x] `downloadFundFlowBill` 申请资金账单,直接下载为gzip或者txt文件
|
||||||
- [x] `WechatCombinePayApi` 合单支付,通过`WechatApiProvider#combinePayApi`初始化
|
- [x] `WechatCombinePayApi` 合单支付,通过`WechatApiProvider#combinePayApi`初始化
|
||||||
- [x] `jsPay` 合单APP下单
|
- [x] `jsPay` 合单JSAPI/小程序下单
|
||||||
- [x] `appPay` 合单JSAPI/小程序下单
|
- [x] `appPay` 合单APP下单
|
||||||
- [x] `h5Pay` 合单H5下单
|
- [x] `h5Pay` 合单H5下单
|
||||||
- [x] `nativePay` 合单Native下单
|
- [x] `nativePay` 合单Native下单
|
||||||
- [x] `queryTransactionByOutTradeNo` 查询订单,**合单支付目前只支持商户订单号查询**
|
- [x] `queryTransactionByOutTradeNo` 查询订单,**合单支付目前只支持商户订单号查询**
|
||||||
|
|||||||
@@ -22,11 +22,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot</artifactId>
|
<artifactId>payment-spring-boot</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ package cn.felord.payment.wechat;
|
|||||||
import cn.felord.payment.wechat.v3.KeyPairFactory;
|
import cn.felord.payment.wechat.v3.KeyPairFactory;
|
||||||
import cn.felord.payment.wechat.v3.WechatMetaBean;
|
import cn.felord.payment.wechat.v3.WechatMetaBean;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
import org.springframework.util.ResourceUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class InMemoryWechatTenantService implements WechatTenantService {
|
public class InMemoryWechatTenantService implements WechatTenantService {
|
||||||
private final WechatPayProperties wechatPayProperties;
|
private final WechatPayProperties wechatPayProperties;
|
||||||
|
private final ResourceLoader resourceLoader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<WechatMetaBean> loadTenants() {
|
public Set<WechatMetaBean> loadTenants() {
|
||||||
@@ -51,7 +53,8 @@ public class InMemoryWechatTenantService implements WechatTenantService {
|
|||||||
String certAbsolutePath = v3.getCertAbsolutePath();
|
String certAbsolutePath = v3.getCertAbsolutePath();
|
||||||
String mchId = v3.getMchId();
|
String mchId = v3.getMchId();
|
||||||
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
||||||
new ClassPathResource(certPath == null ? "wechat/apiclient_cert.p12" : certPath);
|
resourceLoader.getResource(certPath == null ? "classpath:wechat/apiclient_cert.p12" :
|
||||||
|
certPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX) ? certPath : ResourceUtils.CLASSPATH_URL_PREFIX + certPath);
|
||||||
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, mchId);
|
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, mchId);
|
||||||
wechatMetaBean.setV3(v3);
|
wechatMetaBean.setV3(v3);
|
||||||
wechatMetaBean.setTenantId(tenantId);
|
wechatMetaBean.setTenantId(tenantId);
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ public class WechatPayConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
|
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
|
||||||
WechatMetaContainer container = new WechatMetaContainer();
|
return new WechatMetaContainer(wechatTenantService);
|
||||||
container.addWechatMetas(wechatTenantService.loadTenants());
|
|
||||||
return container;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Wechat tenant service configuration.
|
* The type Wechat tenant service configuration.
|
||||||
@@ -42,7 +43,7 @@ public class WechatTenantServiceConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties) {
|
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties, ResourceLoader resourceLoader) {
|
||||||
return new InMemoryWechatTenantService(wechatPayProperties);
|
return new InMemoryWechatTenantService(wechatPayProperties, resourceLoader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Website:
|
|
||||||
* https://felord.cn
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.felord.payment.wechat.v2.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author felord.cn
|
|
||||||
* @since 1.0.4.RELEASE
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class RefundModel extends BaseModel {
|
|
||||||
|
|
||||||
private String appid;
|
|
||||||
private String mchId;
|
|
||||||
private String signType="MD5";
|
|
||||||
private String transactionId;
|
|
||||||
private String outTradeNo;
|
|
||||||
private String outRefundNo;
|
|
||||||
private Integer totalFee;
|
|
||||||
private Integer refundFee;
|
|
||||||
private String refundFeeType="CNY";
|
|
||||||
private String refundDesc;
|
|
||||||
private String refundAccount;
|
|
||||||
private String notifyUrl;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Website:
|
|
||||||
* https://felord.cn
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package cn.felord.payment.wechat.v2.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author felord.cn
|
|
||||||
* @since 1.0.4.RELEASE
|
|
||||||
*/
|
|
||||||
public class RefundQueryModel {
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.felord.payment.wechat.WechatTenantService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
@@ -27,10 +30,11 @@ import java.util.concurrent.ConcurrentSkipListSet;
|
|||||||
* @author felord.cn
|
* @author felord.cn
|
||||||
* @since 1.0.0.RELEASE
|
* @since 1.0.0.RELEASE
|
||||||
*/
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
public class WechatMetaContainer {
|
public class WechatMetaContainer {
|
||||||
private final Map<String, WechatMetaBean> wechatMetaBeanMap = new ConcurrentHashMap<>();
|
private final Map<String, WechatMetaBean> wechatMetaBeanMap = new ConcurrentHashMap<>();
|
||||||
private final Set<String> tenantIds = new ConcurrentSkipListSet<>();
|
private final Set<String> tenantIds = new ConcurrentSkipListSet<>();
|
||||||
|
private final WechatTenantService wechatTenantService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add wechat metas.
|
* Add wechat metas.
|
||||||
@@ -66,7 +70,14 @@ public class WechatMetaContainer {
|
|||||||
* @return the wechat meta
|
* @return the wechat meta
|
||||||
*/
|
*/
|
||||||
public WechatMetaBean getWechatMeta(String tenantId) {
|
public WechatMetaBean getWechatMeta(String tenantId) {
|
||||||
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId));
|
WechatMetaBean wechatMetaBean = this.wechatMetaBeanMap.get(tenantId);
|
||||||
|
if (Objects.nonNull(wechatMetaBean)) {
|
||||||
|
return wechatMetaBean;
|
||||||
|
} else {
|
||||||
|
this.addWechatMetas(wechatTenantService.loadTenants());
|
||||||
|
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId),
|
||||||
|
"cant obtain the config with tenant: "+tenantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,11 +22,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot</artifactId>
|
<artifactId>payment-spring-boot</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>payment-spring-boot-starter</artifactId>
|
<artifactId>payment-spring-boot-starter</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@@ -21,7 +21,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot</artifactId>
|
<artifactId>payment-spring-boot</artifactId>
|
||||||
<version>1.0.17.RELEASE</version>
|
<version>1.0.18.RELEASE</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<tag>payment-spring-boot-1.0.14.RELEASE</tag>
|
<tag>payment-spring-boot-1.0.18.RELEASE</tag>
|
||||||
<url>https://github.com/NotFound403/payment-spring-boot</url>
|
<url>https://github.com/NotFound403/payment-spring-boot</url>
|
||||||
<connection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</connection>
|
<connection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</connection>
|
||||||
<developerConnection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</developerConnection>
|
<developerConnection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</developerConnection>
|
||||||
|
|||||||
Reference in New Issue
Block a user