16 Commits

Author SHA1 Message Date
xiafang
730c15b6b8 Update pom.xml 2023-05-05 12:33:21 +08:00
xiafang
dc6e48d538 enhance: 修改了支付配置加载机制,现在可以不停机维护微信支付参数了 2023-05-05 12:20:06 +08:00
xiafang
e6e704cc28 docs: 修正文档描述错误 2023-03-24 13:43:34 +08:00
xiafang
8578300d1c docs: 修正文档描述错误 2023-03-24 13:40:32 +08:00
Fang
aef8ef9ac3 factor:移除过时的V2退款API 2023-03-10 22:32:52 +08:00
Fang
f630301bc3 docs:更新文档地址到dromara组织 2023-03-10 22:31:06 +08:00
xiafang
f7ba4dd306 1.0.18 2023-03-08 13:39:11 +08:00
Fang
997f004708 enhance: 增强资源加载器 2023-03-06 22:31:55 +08:00
xiafang
5e63779f36 1.0.18 2023-03-01 09:29:36 +08:00
xiafang
30613a2fdd enhance: 优化证书加载方式以支持Docker内读取
Closes #94
2023-03-01 09:24:51 +08:00
felord.cn
e9388f62c1 Update changelog.md 2023-02-26 14:33:38 +08:00
xiafang
685839089f README.md 2023-02-25 17:16:29 +08:00
xiafang
7b9bdd21f7 README.md 2023-02-25 16:56:37 +08:00
xiafang
8c4ecad809 README.md 2023-02-25 16:52:29 +08:00
xiafang
e24aa83ba0 README.md 2023-02-25 16:47:36 +08:00
felord.cn
d6d5e33dae Merge pull request #93 from NotFound403/1.0.17
1.0.17
2023-02-25 16:41:16 +08:00
15 changed files with 63 additions and 125 deletions

View File

@@ -1,8 +1,8 @@
<div align="center" style="margin-bottom: 10px"><h1>最全最好用的微信支付V3 Spring Boot 组件</h1></div>
<p align="center">
<a target="_blank" href="https://github.com/NotFound403/payment-spring-boot/blob/release/LICENSE">
<img alt="" src="https://img.shields.io/github/license/NotFound403/payment-spring-boot"/>
<a target="_blank" href="https://github.com/dromara/payment-spring-boot/blob/release/LICENSE">
<img alt="" src="https://img.shields.io/github/license/dromara/payment-spring-boot"/>
</a>
<a target="_blank" href="https://felord.cn">
<img alt="" src="https://img.shields.io/badge/java-8-red"/>
@@ -13,8 +13,8 @@
<a target="_blank" href="https://mvnrepository.com/artifact/cn.felord/payment-spring-boot">
<img alt="" src="https://img.shields.io/maven-central/v/cn.felord/payment-spring-boot.svg?style=flat-square"/>
</a>
<a target="_blank" href="https://github.com/NotFound403/payment-spring-boot">
<img alt="" src="https://img.shields.io/github/stars/NotFound403/payment-spring-boot?style=social"/>
<a target="_blank" href="https://github.com/dromara/payment-spring-boot">
<img alt="" src="https://img.shields.io/github/stars/dromara/payment-spring-boot?style=social"/>
</a>
<a target="_blank" href="https://gitee.com/felord/payment-spring-boot/stargazers">
<img alt="" src="https://gitee.com/felord/payment-spring-boot/badge/star.svg?theme=white"/>
@@ -42,46 +42,33 @@ Starter支持微信优惠券代金券、商家券、智慧商圈、商家
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```
## JDK问题
**推荐使用Open JDK**,原因参见[FBI Warning](https://github.com/NotFound403/payment-spring-boot/issues/5)
**推荐使用Open JDK**,原因参见[FBI Warning](https://github.com/dromara/payment-spring-boot/issues/5)
## 文档地址
- [payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
## 目前已经实现所有服务商和直连商户接口
- 实现微信支付多商户
- 集成支付宝SDK、快速接入Spring Boot
- 实现微信支付V3 基础支付
- 实现微信支付V3 合单支付
- 实现微信支付V3 代金券
- 实现微信支付V3 微信支付分
- 实现微信支付V3 先享卡
- 实现微信支付V3 商家券
- 实现微信支付V3 批量转账到零钱
更新日志参考[changelog](https://notfound403.github.io/payment-spring-boot/#/changelog)
- [payment-spring-boot GitHub文档](https://dromara.github.io/payment-spring-boot)
## API清单
API结构如下
![](https://asset.felord.cn/blog/20220613092244.png)
具体分为**直连商户**和**服务商**两个体系,请详细阅读文档说明
目前已经实现绝大部分微信支付直连商户和服务商的接口具体的API明细可查看[API清单](https://dromara.github.io/payment-spring-boot/#/wechat_v3_api)
> 随着版本迭代功能会增加也可通过API注册表类`WechatPayV3Type`进行API接口检索。
> 随着版本迭代功能会增加可通过API注册表类`WechatPayV3Type`进行API接口检索。
## CHANGELOG
更新日志[CHANGELOG](https://dromara.github.io/payment-spring-boot/#/changelog)
## 使用入门
### 集成配置
关于集成配置请详细阅读[payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
中[快速接入](https://notfound403.github.io/payment-spring-boot/#/quick_start)章节
关于集成配置请详细阅读[payment-spring-boot GitHub文档](https://dromara.github.io/payment-spring-boot)
中[快速接入](https://dromara.github.io/payment-spring-boot/#/quick_start)章节
### 调用示例
@@ -360,7 +347,7 @@ public class CallbackController {
## 仓库地址
- [GitHub](https://github.com/NotFound403/payment-spring-boot)
- [GitHub](https://github.com/dromara/payment-spring-boot)
- [Gitee](https://gitee.com/felord/payment-spring-boot)
## QQ交流群

View File

@@ -35,7 +35,7 @@
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```
## 采用技术

View File

@@ -2,6 +2,6 @@
* [项目简介](README.md)
* [快速接入](quick_start.md)
* [JavaDoc](apidocs/index.html ':ignore')
* [微信支付V3接口文档](wechat_v3_api.md)
* [Payment微信支付V3接口文档](wechat_v3_api.md)
* [日常踩坑](stackoverflow.md)
* [更新日志](changelog.md)

View File

@@ -1,3 +1,11 @@
## 1.0.17.RELEASE
### 微信支付
- feat: 直连商户合单支付增加查询单笔退款
- feat: 支付分增加退款独立的API
- factor: 营销图片上传API现在由WechatMediaApi#marketingImageUpload实现以代替WechatMarketingFavorApi#marketingImageUpload,旧实现已标记为过时
- factor:时间格式优化移除时区限制为东八区由LocalDateTime改为OffsetDateTime
- docs: 现在可以通过API清单检索API了
## 1.0.16.RELEASE
### 微信支付
- feat: 直连商户-委托营销相关API实现
@@ -186,4 +194,4 @@
- 多租户
- 支付宝
- 仅仅引入支付宝SDK后续维护以支付宝SDK变动为准
- 支付宝暂时不支持多租户
- 支付宝暂时不支持多租户

View File

@@ -4,7 +4,7 @@
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```
> 基于 **Spring Boot 2.x**

View File

@@ -1,7 +1,6 @@
## 入口类
`WechatApiProvider`是本项目微信支付的入口类,已被注入**Spring IoC**,由它来初始化微信支付相关的**API**,具体分为**直连商户
**和**服务商**两个体系。
`WechatApiProvider`是本项目微信支付的入口类,已被注入**Spring IoC**,由它来初始化微信支付相关的**API**,具体分为**直连商户**和**服务商**两个体系。
> 以下清单请搭配微信支付文档使用。
@@ -10,8 +9,8 @@
#### 基础支付
- [x] `WechatDirectPayApi` 基础支付,通过`WechatApiProvider#directPayApi`初始化
- [x] `jsPay` APP下单
- [x] `appPay` JSAPI/小程序下单
- [x] `jsPay` JSAPI/小程序下单
- [x] `appPay` APP下单
- [x] `h5Pay` H5下单
- [x] `nativePay` Native下单
- [x] 查询订单
@@ -25,8 +24,8 @@
- [x] `downloadTradeBill` 申请交易账单直接下载为gzip或者txt文件
- [x] `downloadFundFlowBill` 申请资金账单直接下载为gzip或者txt文件
- [x] `WechatCombinePayApi` 合单支付,通过`WechatApiProvider#combinePayApi`初始化
- [x] `jsPay` 合单APP下单
- [x] `appPay` 合单JSAPI/小程序下单
- [x] `jsPay` 合单JSAPI/小程序下单
- [x] `appPay` 合单APP下单
- [x] `h5Pay` 合单H5下单
- [x] `nativePay` 合单Native下单
- [x] `queryTransactionByOutTradeNo` 查询订单,**合单支付目前只支持商户订单号查询**
@@ -186,9 +185,6 @@
- [x] 申请转账明细电子回单
1. `transferElectronic` 受理转账明细电子回单
2. `queryTransferElectronicResult` 查询转账账单电子回单接口
- [x] 申请转账电子回单
1. `` 转账账单电子回单申请受理接口
2. `` 查询转账账单电子回单接口
##### 分账
@@ -224,4 +220,6 @@
- [x] `mediaVideoUpload` 视频上传
- [x] `marketingImageUpload` 营销图片上传
> 通过营销**图片上传API**上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用包括商家券、代金券、支付有礼等。
> 通过营销**图片上传API**上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用包括商家券、代金券、支付有礼等。
### 服务商
施工中……

View File

@@ -22,11 +22,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-autoconfigure</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -20,9 +20,10 @@ package cn.felord.payment.wechat;
import cn.felord.payment.wechat.v3.KeyPairFactory;
import cn.felord.payment.wechat.v3.WechatMetaBean;
import lombok.AllArgsConstructor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ResourceUtils;
import java.util.Map;
import java.util.Set;
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class InMemoryWechatTenantService implements WechatTenantService {
private final WechatPayProperties wechatPayProperties;
private final ResourceLoader resourceLoader;
@Override
public Set<WechatMetaBean> loadTenants() {
@@ -51,7 +53,8 @@ public class InMemoryWechatTenantService implements WechatTenantService {
String certAbsolutePath = v3.getCertAbsolutePath();
String mchId = v3.getMchId();
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.setV3(v3);
wechatMetaBean.setTenantId(tenantId);

View File

@@ -43,9 +43,7 @@ public class WechatPayConfiguration {
@Bean
@ConditionalOnMissingBean
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
WechatMetaContainer container = new WechatMetaContainer();
container.addWechatMetas(wechatTenantService.loadTenants());
return container;
return new WechatMetaContainer(wechatTenantService);
}
/**

View File

@@ -22,6 +22,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
/**
* The type Wechat tenant service configuration.
@@ -42,7 +43,7 @@ public class WechatTenantServiceConfiguration {
*/
@Bean
@ConditionalOnMissingBean
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties) {
return new InMemoryWechatTenantService(wechatPayProperties);
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties, ResourceLoader resourceLoader) {
return new InMemoryWechatTenantService(wechatPayProperties, resourceLoader);
}
}

View File

@@ -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;
}

View File

@@ -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 {
}

View File

@@ -17,6 +17,9 @@
package cn.felord.payment.wechat.v3;
import cn.felord.payment.wechat.WechatTenantService;
import lombok.AllArgsConstructor;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
@@ -27,10 +30,11 @@ import java.util.concurrent.ConcurrentSkipListSet;
* @author felord.cn
* @since 1.0.0.RELEASE
*/
@AllArgsConstructor
public class WechatMetaContainer {
private final Map<String, WechatMetaBean> wechatMetaBeanMap = new ConcurrentHashMap<>();
private final Set<String> tenantIds = new ConcurrentSkipListSet<>();
private final WechatTenantService wechatTenantService;
/**
* Add wechat metas.
@@ -66,7 +70,14 @@ public class WechatMetaContainer {
* @return the wechat meta
*/
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);
}
}
/**

View File

@@ -22,11 +22,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
@@ -47,7 +47,7 @@
</developers>
<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>
<connection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</connection>
<developerConnection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</developerConnection>