mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-05-04 20:13:58 +00:00
Compare commits
42 Commits
1.0.14.REL
...
1.0.16.REL
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
402fda7cf9 | ||
|
|
9cc3e96dff | ||
|
|
9ccbe1e977 | ||
|
|
6b78b30b75 | ||
|
|
bd782503ea | ||
|
|
110b8b5cfc | ||
|
|
55440b1275 | ||
|
|
59be1e96ad | ||
|
|
6534d4c0f6 | ||
|
|
0faa855f90 | ||
|
|
4fc6aad767 | ||
|
|
c55df6f576 | ||
|
|
3398f7e2b7 | ||
|
|
c5d19c68c0 | ||
|
|
4dea6b0afe | ||
|
|
379d007bb4 | ||
|
|
de3cf3d2ae | ||
|
|
9d2f8a7d72 | ||
|
|
e1ec5f1b7c | ||
|
|
d8288cdd3a | ||
|
|
113e531eae | ||
|
|
d91b52ba2b | ||
|
|
1742437c2c | ||
|
|
2f391cc14c | ||
|
|
31bef5bfac | ||
|
|
5d1fd73f2b | ||
|
|
18b6615c44 | ||
|
|
0ebe58ae09 | ||
|
|
2f69023ffd | ||
|
|
2c28113ee7 | ||
|
|
05a3e83e3e | ||
|
|
2f7e6c6b22 | ||
|
|
9b4193a4f9 | ||
|
|
6e4bfd2192 | ||
|
|
02867baa2c | ||
|
|
4c21329ceb | ||
|
|
e1616c5606 | ||
|
|
34d0bed373 | ||
|
|
575bf6e8a2 | ||
|
|
f73be6452e | ||
|
|
a9ab004a96 | ||
|
|
24f270acd6 |
31
README.md
31
README.md
@@ -1,9 +1,15 @@
|
|||||||
# 最好用的微信支付V3 Spring Boot 组件
|
[](https://github.com/NotFound403/payment-spring-boot/blob/release/LICENSE)
|
||||||
|
[]()
|
||||||
|
[]()
|
||||||
|
[](https://mvnrepository.com/artifact/cn.felord/payment-spring-boot)
|
||||||
|
[](https://github.com/NotFound403/payment-spring-boot)
|
||||||
|
[](https://github.com/NotFound403/payment-spring-boot)
|
||||||
|
|
||||||
为了满足业务中出现app支付、公众号支付、小程序支付等多appid并存的场景,对原有的进行了增强开发出了多租户版本。
|
如果你感觉这个项目不错,请给**Star**以鼓励,谢谢。
|
||||||
|
|
||||||
请给[Payment Spring Boot](https://github.com/NotFound403/payment-spring-boot) **Star**以鼓励,谢谢。
|
# 最全最好用的微信支付V3 Spring Boot 组件
|
||||||
|
|
||||||
|
微信支付V3支付,支持微信优惠券,代金券、商家券、智慧商圈、商家转账到零钱、公众号支付、微信小程序支付、分账、支付分、商家券、合单支付、先享卡、电商收付通等全部微信支付功能API,同时满足多个服务商、多个商户开发需求。一键集成,API友好,上手快,欢迎star。
|
||||||
|
|
||||||
## Maven 最新中央仓库坐标
|
## Maven 最新中央仓库坐标
|
||||||
|
|
||||||
@@ -11,9 +17,17 @@
|
|||||||
<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.14.RELEASE</version>
|
<version>1.0.16.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
## JDK问题
|
||||||
|
|
||||||
|
**推荐使用Open JDK**,原因参见[FBI Warning](https://github.com/NotFound403/payment-spring-boot/issues/5)
|
||||||
|
|
||||||
|
## 文档地址
|
||||||
|
- [payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
|
||||||
|
- [payment-spring-boot Gitee文档](https://felord.gitee.io/payment-spring-boot)
|
||||||
|
|
||||||
|
|
||||||
## 目前已经实现所有服务商和直连商户接口
|
## 目前已经实现所有服务商和直连商户接口
|
||||||
|
|
||||||
@@ -27,12 +41,13 @@
|
|||||||
- 实现微信支付V3 商家券
|
- 实现微信支付V3 商家券
|
||||||
- 实现微信支付V3 批量转账到零钱
|
- 实现微信支付V3 批量转账到零钱
|
||||||
|
|
||||||
更多参考[changelog](https://notfound403.github.io/payment-spring-boot/#/changelog)
|
更新日志参考[changelog](https://notfound403.github.io/payment-spring-boot/#/changelog)
|
||||||
|
|
||||||
## 核心API结构
|
## 核心API结构
|
||||||

|

|
||||||
|
|
||||||
- `WechatPartnerProfitsharingApi` 微信支付服务商V3分账
|
- `WechatPartnerProfitsharingApi` 微信支付服务商V3分账
|
||||||
|
- `WechatBrandProfitsharingApi` 微信支付服务商V3连锁品牌分账
|
||||||
- `WechatPayCallback` 微信支付V3回调通知工具封装
|
- `WechatPayCallback` 微信支付V3回调通知工具封装
|
||||||
- `WechatAllocationApi` 微信支付V2分账(未来会移除)
|
- `WechatAllocationApi` 微信支付V2分账(未来会移除)
|
||||||
- `WechatMarketingFavorApi` 微信支付代金券V3
|
- `WechatMarketingFavorApi` 微信支付代金券V3
|
||||||
@@ -53,7 +68,7 @@
|
|||||||
- `WechatSmartGuideApi` 服务商或者直连商户-经营能力-支付即服务
|
- `WechatSmartGuideApi` 服务商或者直连商户-经营能力-支付即服务
|
||||||
- `WechatGoldPlanApi` 服务商-经营能力-点金计划
|
- `WechatGoldPlanApi` 服务商-经营能力-点金计划
|
||||||
|
|
||||||
> 随着版本迭代功能会增加。
|
> 随着版本迭代功能会增加,可通过API注册表类`WechatPayV3Type`进行API接口检索。
|
||||||
|
|
||||||
## 开源协议
|
## 开源协议
|
||||||
**Apache 2.0**
|
**Apache 2.0**
|
||||||
@@ -62,10 +77,6 @@
|
|||||||
- [GitHub](https://github.com/NotFound403/payment-spring-boot)
|
- [GitHub](https://github.com/NotFound403/payment-spring-boot)
|
||||||
- [Gitee](https://gitee.com/felord/payment-spring-boot)
|
- [Gitee](https://gitee.com/felord/payment-spring-boot)
|
||||||
|
|
||||||
## 文档地址
|
|
||||||
- [payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
|
|
||||||
- [payment-spring-boot Gitee文档](https://felord.gitee.io/payment-spring-boot)
|
|
||||||
|
|
||||||
## QQ交流群
|
## QQ交流群
|
||||||
为了交流解惑,新建QQ群,可通过扫码进入。
|
为了交流解惑,新建QQ群,可通过扫码进入。
|
||||||
|
|
||||||
|
|||||||
@@ -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.14.RELEASE</version>
|
<version>1.0.16.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
## 采用技术
|
## 采用技术
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
|
## 1.0.15.RELEASE
|
||||||
|
### 微信支付
|
||||||
|
- feat: 增加服务商退款API
|
||||||
|
- feat: 微信服务商分账-连锁品牌分账 [#82](https://github.com/NotFound403/payment-spring-boot/issues/82)
|
||||||
|
- fix: 多租户证书无法复用的问题,刷新时正确移除证书 [#77](https://github.com/NotFound403/payment-spring-boot/issues/77)
|
||||||
|
- fix: 批量转账到零钱API入参NPE问题修复 [#85](https://github.com/NotFound403/payment-spring-boot/issues/85)
|
||||||
|
- fix: 商家券-修改批次预算API请求方法应该为Patch [#79](https://github.com/NotFound403/payment-spring-boot/issues/79)
|
||||||
|
- enhance: 部分时间格式优化,更好地兼容Java Time API
|
||||||
|
- enhance: 微信代金券样式的背景颜色枚举更新 [#84](https://github.com/NotFound403/payment-spring-boot/issues/84)
|
||||||
|
- upgrade: Spring Boot 版本升级到2.7.7
|
||||||
|
|
||||||
## 1.0.14.RELEASE
|
## 1.0.14.RELEASE
|
||||||
### 微信支付
|
### 微信支付
|
||||||
- fix: 批量转账到零钱查询BUG [#I5E2X7](https://gitee.com/felord/payment-spring-boot/issues/I5E2X7)
|
- fix: 批量转账到零钱查询BUG [#I5E2X7](https://gitee.com/felord/payment-spring-boot/issues/I5E2X7)
|
||||||
- feat: 移除了被标记过期的API,包括基于微信支付V2版本的分账实现,使用相关接口的同学需要针对性的进行迁移
|
- feat: 移除了被标记过期的API,包括基于微信支付V2版本的分账实现,使用相关接口的同学需要针对性的进行迁移
|
||||||
- feat: 增加证书绝对路径实现
|
- feat: 增加证书绝对路径实现
|
||||||
- 配置项增加`certAbsolutePath`字段用来定义证书的绝对路径,优先级高于`certPath`,当这两个路径都不配置时采用classpath路径`wechat/apiclient_cert.p12`
|
- 配置项增加`certAbsolutePath`字段用来定义证书的绝对路径,优先级高于`certPath`,当这两个路径都不配置时采用classpath路径`wechat/apiclient_cert.p12` [#73](https://github.com/NotFound403/payment-spring-boot/issues/73)
|
||||||
#### 服务商
|
#### 服务商
|
||||||
- feat: 实现服务商商户进件-特约商户进件相关API
|
- feat: 实现服务商商户进件-特约商户进件相关API
|
||||||
- feat: 实现点金计划,适用于服务商
|
- feat: 实现点金计划,适用于服务商
|
||||||
- feat: 实现行业方案-电商收付通
|
- feat: 实现行业方案-电商收付通
|
||||||
- feat: 实现行业方案-智慧商圈
|
- feat: 实现行业方案-智慧商圈
|
||||||
feat: 实现其它能力-银行组件(服务商)
|
- feat: 实现其它能力-银行组件(服务商)
|
||||||
- enhance: 服务商分账新增下载账单接口
|
- enhance: 服务商分账新增下载账单接口
|
||||||
- enhance: 新增服务商退款回调接口
|
- enhance: 新增服务商退款回调接口
|
||||||
#### 通用能力
|
#### 通用能力
|
||||||
|
|||||||
@@ -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.14.RELEASE</version>
|
<version>1.0.16.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
> 基于 **Spring Boot 2.x**
|
> 基于 **Spring Boot 2.x**
|
||||||
|
|||||||
@@ -1,15 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
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">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.felord</groupId>
|
<groupId>cn.felord</groupId>
|
||||||
<artifactId>payment-spring-boot</artifactId>
|
<artifactId>payment-spring-boot</artifactId>
|
||||||
<version>1.0.14.RELEASE</version>
|
<version>1.0.16.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
||||||
<version>1.0.14.RELEASE</version>
|
<version>1.0.16.RELEASE</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment;
|
package cn.felord.payment;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.alipay;
|
package cn.felord.payment.alipay;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.alipay;
|
package cn.felord.payment.alipay;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.autoconfigure;
|
package cn.felord.payment.autoconfigure;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,12 +13,12 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.autoconfigure;
|
package cn.felord.payment.autoconfigure;
|
||||||
|
|
||||||
import cn.felord.payment.alipay.AliPayConfiguration;
|
import cn.felord.payment.alipay.AliPayConfiguration;
|
||||||
import cn.felord.payment.wechat.WechatPayConfiguration;
|
import cn.felord.payment.wechat.WechatPayConfiguration;
|
||||||
|
import cn.felord.payment.wechat.WechatTenantServiceConfiguration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
@@ -28,6 +27,6 @@ import org.springframework.context.annotation.Import;
|
|||||||
* @since 1.0.0.RELEASE
|
* @since 1.0.0.RELEASE
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({WechatPayConfiguration.class, AliPayConfiguration.class})
|
@Import({WechatPayConfiguration.class, WechatTenantServiceConfiguration.class, AliPayConfiguration.class})
|
||||||
public class PayConfiguration {
|
public class PayConfiguration {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
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 java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从配置文件中加载租户信息,默认实现,可被覆盖
|
||||||
|
*
|
||||||
|
* @author xiafang
|
||||||
|
* @since 2023/2/3 11:40
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class InMemoryWechatTenantService implements WechatTenantService {
|
||||||
|
private final WechatPayProperties wechatPayProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<WechatMetaBean> loadTenants() {
|
||||||
|
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
||||||
|
KeyPairFactory keyPairFactory = new KeyPairFactory();
|
||||||
|
return v3Map.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(entry -> {
|
||||||
|
WechatPayProperties.V3 v3 = entry.getValue();
|
||||||
|
String tenantId = entry.getKey();
|
||||||
|
String certPath = v3.getCertPath();
|
||||||
|
String certAbsolutePath = v3.getCertAbsolutePath();
|
||||||
|
String mchId = v3.getMchId();
|
||||||
|
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
||||||
|
new ClassPathResource(certPath == null ? "wechat/apiclient_cert.p12" : certPath);
|
||||||
|
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, mchId);
|
||||||
|
wechatMetaBean.setV3(v3);
|
||||||
|
wechatMetaBean.setTenantId(tenantId);
|
||||||
|
return wechatMetaBean;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,22 +13,17 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat;
|
package cn.felord.payment.wechat;
|
||||||
|
|
||||||
|
|
||||||
import cn.felord.payment.wechat.v3.*;
|
import cn.felord.payment.wechat.v3.SignatureProvider;
|
||||||
|
import cn.felord.payment.wechat.v3.WechatApiProvider;
|
||||||
|
import cn.felord.payment.wechat.v3.WechatMetaContainer;
|
||||||
|
import cn.felord.payment.wechat.v3.WechatPayClient;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
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.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.FileSystemResource;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Wechat pay configuration.
|
* The type Wechat pay configuration.
|
||||||
@@ -38,39 +32,19 @@ import java.util.Map;
|
|||||||
* @since 1.0.0.RELEASE
|
* @since 1.0.0.RELEASE
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@Conditional(WechatPayConfiguredCondition.class)
|
|
||||||
@EnableConfigurationProperties(WechatPayProperties.class)
|
|
||||||
public class WechatPayConfiguration {
|
public class WechatPayConfiguration {
|
||||||
/**
|
|
||||||
* The constant CERT_ALIAS.
|
|
||||||
*/
|
|
||||||
private static final String CERT_ALIAS = "Tenpay Certificate";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付公私钥 以及序列号等元数据.
|
* 微信支付公私钥 以及序列号等元数据.
|
||||||
*
|
*
|
||||||
* @param wechatPayProperties the wechat pay properties
|
* @param wechatTenantService the wechat tenant service
|
||||||
* @return the wechat cert bean
|
* @return the wechat cert bean
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
WechatMetaContainer wechatMetaContainer(WechatPayProperties wechatPayProperties) {
|
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
|
||||||
|
|
||||||
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
|
||||||
WechatMetaContainer container = new WechatMetaContainer();
|
WechatMetaContainer container = new WechatMetaContainer();
|
||||||
KeyPairFactory keyPairFactory = new KeyPairFactory();
|
container.addWechatMetas(wechatTenantService.loadTenants());
|
||||||
v3Map.keySet().forEach(tenantId -> {
|
|
||||||
WechatPayProperties.V3 v3 = v3Map.get(tenantId);
|
|
||||||
String certPath = v3.getCertPath();
|
|
||||||
String certAbsolutePath = v3.getCertAbsolutePath();
|
|
||||||
String mchId = v3.getMchId();
|
|
||||||
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
|
||||||
new ClassPathResource(certPath == null ? "wechat/apiclient_cert.p12" : certPath);
|
|
||||||
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, CERT_ALIAS, mchId);
|
|
||||||
wechatMetaBean.setV3(v3);
|
|
||||||
wechatMetaBean.setTenantId(tenantId);
|
|
||||||
container.addWechatMeta(tenantId, wechatMetaBean);
|
|
||||||
});
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat;
|
package cn.felord.payment.wechat;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat;
|
package cn.felord.payment.wechat;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat;
|
package cn.felord.payment.wechat;
|
||||||
|
|
||||||
|
|||||||
@@ -15,17 +15,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.felord.payment.wechat.v3.model.specmch;
|
package cn.felord.payment.wechat;
|
||||||
|
|
||||||
import java.util.List;
|
import cn.felord.payment.wechat.v3.WechatMetaBean;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 加载租户信息服务
|
||||||
|
*
|
||||||
* @author felord.cn
|
* @author felord.cn
|
||||||
* @since 1.0.14.RELEASE
|
* @since 1.0.16.RELEASE
|
||||||
*/
|
*/
|
||||||
public class AdditionInfo {
|
@FunctionalInterface
|
||||||
private String legalPersonCommitment;
|
public interface WechatTenantService {
|
||||||
private String legalPersonVideo;
|
Set<WechatMetaBean> loadTenants();
|
||||||
private List<String> businessAdditionPics;
|
|
||||||
private String businessAdditionMsg;
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Wechat tenant service configuration.
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.16.RELEASE
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@Conditional(WechatPayConfiguredCondition.class)
|
||||||
|
@EnableConfigurationProperties(WechatPayProperties.class)
|
||||||
|
public class WechatTenantServiceConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wechat tenant service wechat tenant service.
|
||||||
|
*
|
||||||
|
* @param wechatPayProperties the wechat pay properties
|
||||||
|
* @return the wechat tenant service
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties) {
|
||||||
|
return new InMemoryWechatTenantService(wechatPayProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.enumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum Business type.
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.16.RELEASE
|
||||||
|
*/
|
||||||
|
public enum BusinessType {
|
||||||
|
/**
|
||||||
|
* 代金券批次(暂不支持合作方为商户的场景)
|
||||||
|
*/
|
||||||
|
FAVOR_STOCK,
|
||||||
|
/**
|
||||||
|
* 商家券批次
|
||||||
|
*/
|
||||||
|
BUSIFAVOR_STOCK
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ package cn.felord.payment.wechat.enumeration;
|
|||||||
/**
|
/**
|
||||||
* 超级管理员类型
|
* 超级管理员类型
|
||||||
*
|
*
|
||||||
* @since
|
* @since 1.0.14.RELEASE
|
||||||
*/
|
*/
|
||||||
public enum ContactType {
|
public enum ContactType {
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +31,7 @@ public enum ContactType {
|
|||||||
LEGAL,
|
LEGAL,
|
||||||
/**
|
/**
|
||||||
* 经办人
|
* 经办人
|
||||||
*
|
* <p>
|
||||||
* 经商户授权办理微信支付业务的人员
|
* 经商户授权办理微信支付业务的人员
|
||||||
*/
|
*/
|
||||||
SUPER
|
SUPER
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -29,42 +28,41 @@ public enum CouponBgColor {
|
|||||||
/**
|
/**
|
||||||
* Color 010 coupon bg color.
|
* Color 010 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color010,
|
COLOR010,
|
||||||
/**
|
/**
|
||||||
* Color 020 coupon bg color.
|
* COLOR 020 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color020,
|
COLOR020,
|
||||||
/**
|
/**
|
||||||
* Color 030 coupon bg color.
|
* COLOR 030 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color030,
|
COLOR030,
|
||||||
/**
|
/**
|
||||||
* Color 040 coupon bg color.
|
* COLOR 040 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color040,
|
COLOR040,
|
||||||
/**
|
/**
|
||||||
* Color 050 coupon bg color.
|
* COLOR 050 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color050,
|
COLOR050,
|
||||||
/**
|
/**
|
||||||
* Color 060 coupon bg color.
|
* COLOR 060 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color060,
|
COLOR060,
|
||||||
/**
|
/**
|
||||||
* Color 070 coupon bg color.
|
* COLOR 070 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color070,
|
COLOR070,
|
||||||
/**
|
/**
|
||||||
* Color 080 coupon bg color.
|
* COLOR 080 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color080,
|
COLOR080,
|
||||||
/**
|
/**
|
||||||
* Color 090 coupon bg color.
|
* COLOR 090 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color090,
|
COLOR090,
|
||||||
/**
|
/**
|
||||||
* Color 100 coupon bg color.
|
* COLOR 100 coupon bg color.
|
||||||
*/
|
*/
|
||||||
Color100
|
COLOR100
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.enumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum Partner type.
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.16.RELEASE
|
||||||
|
*/
|
||||||
|
public enum PartnerType {
|
||||||
|
/**
|
||||||
|
* 合作方为APPID
|
||||||
|
*/
|
||||||
|
APPID,
|
||||||
|
/**
|
||||||
|
* 合作方为商户
|
||||||
|
*/
|
||||||
|
MERCHANT
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.enumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合作状态
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.16.RELEASE
|
||||||
|
*/
|
||||||
|
public enum PartnershipState {
|
||||||
|
/**
|
||||||
|
* 已建立合作状态
|
||||||
|
*/
|
||||||
|
ESTABLISHED,
|
||||||
|
/**
|
||||||
|
* 已终止合作状态
|
||||||
|
*/
|
||||||
|
TERMINATED
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public enum SubjectType {
|
|||||||
* 营业执照上的主体类型一般为个体户、个体工商户、个体经营;
|
* 营业执照上的主体类型一般为个体户、个体工商户、个体经营;
|
||||||
*/
|
*/
|
||||||
SUBJECT_TYPE_INDIVIDUAL,
|
SUBJECT_TYPE_INDIVIDUAL,
|
||||||
|
/**
|
||||||
|
* 小微商户
|
||||||
|
*/
|
||||||
|
SUBJECT_TYPE_MICRO,
|
||||||
/**
|
/**
|
||||||
* 企业
|
* 企业
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.enumeration;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiafang
|
||||||
|
* @since 2023/2/1 8:59
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum WechatPayAlgorithms {
|
||||||
|
RSA("WECHATPAY2-SHA256-RSA2048"),
|
||||||
|
SM3("WECHATPAY2-SM2-WITH-SM3");
|
||||||
|
|
||||||
|
private final String algorithm;
|
||||||
|
|
||||||
|
WechatPayAlgorithms(String algorithm) {
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.enumeration;
|
package cn.felord.payment.wechat.enumeration;
|
||||||
|
|
||||||
@@ -460,11 +458,11 @@ public enum WechatPayV3Type {
|
|||||||
*/
|
*/
|
||||||
MARKETING_BUSI_FAVOR_DISASSOCIATE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/disassociate"),
|
MARKETING_BUSI_FAVOR_DISASSOCIATE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/disassociate"),
|
||||||
/**
|
/**
|
||||||
* 取消关联订单信息API.
|
* 修改批次预算API.
|
||||||
*
|
*
|
||||||
* @since 1.0.4.RELEASES
|
* @since 1.0.4.RELEASES
|
||||||
*/
|
*/
|
||||||
MARKETING_BUSI_FAVOR_BUDGET(HttpMethod.POST, "%s/v3/marketing/busifavor/stocks/{stock_id}/budget"),
|
MARKETING_BUSI_FAVOR_BUDGET(HttpMethod.PATCH, "%s/v3/marketing/busifavor/stocks/{stock_id}/budget"),
|
||||||
/**
|
/**
|
||||||
* 修改商家券基本信息API.
|
* 修改商家券基本信息API.
|
||||||
*
|
*
|
||||||
@@ -495,6 +493,20 @@ public enum WechatPayV3Type {
|
|||||||
* @since 1.0.13.RELEASES
|
* @since 1.0.13.RELEASES
|
||||||
*/
|
*/
|
||||||
MARKETING_BUSI_FAVOR_SUBSIDY_QUERY(HttpMethod.GET, "%s/v3/marketing/busifavor/subsidy/pay-receipts/{subsidy_receipt_id}"),
|
MARKETING_BUSI_FAVOR_SUBSIDY_QUERY(HttpMethod.GET, "%s/v3/marketing/busifavor/subsidy/pay-receipts/{subsidy_receipt_id}"),
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
/**
|
||||||
|
* 建立合作关系API.
|
||||||
|
*
|
||||||
|
* @since 1.0.16.RELEASES
|
||||||
|
*/
|
||||||
|
MARKETING_PARTNERSHIPS_BUILD(HttpMethod.POST, "%s/v3/marketing/partnerships/build"),
|
||||||
|
/**
|
||||||
|
* 查询合作关系列表API.
|
||||||
|
*
|
||||||
|
* @since 1.0.16.RELEASES
|
||||||
|
*/
|
||||||
|
MARKETING_PARTNERSHIPS_GET(HttpMethod.GET, "%s/v3/marketing/partnerships"),
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
/**
|
/**
|
||||||
* 发起批量转账API.
|
* 发起批量转账API.
|
||||||
@@ -680,6 +692,62 @@ public enum WechatPayV3Type {
|
|||||||
* @since 1.0.13.RELEASE
|
* @since 1.0.13.RELEASE
|
||||||
*/
|
*/
|
||||||
PROFITSHARING_BILLS(HttpMethod.GET, "%s/v3/profitsharing/bills"),
|
PROFITSHARING_BILLS(HttpMethod.GET, "%s/v3/profitsharing/bills"),
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
/**
|
||||||
|
* 请求品牌分账API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_ORDERS(HttpMethod.POST, "%s/v3/brand/profitsharing/orders"),
|
||||||
|
/**
|
||||||
|
* 查询品牌分账结果API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_RESULT(HttpMethod.GET, "%s/v3/brand/profitsharing/orders"),
|
||||||
|
/**
|
||||||
|
* 请求品牌分账回退API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_RETURN_ORDERS(HttpMethod.POST, "%s/v3/brand/profitsharing/returnorders"),
|
||||||
|
/**
|
||||||
|
* 查询品牌分账回退结果API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_RETURN_ORDERS_RESULT(HttpMethod.GET, "%s/v3/brand/profitsharing/returnorders"),
|
||||||
|
/**
|
||||||
|
* 完结品牌分账API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_FINISH_ORDER(HttpMethod.POST, "%s/v3/brand/profitsharing/finish-order"),
|
||||||
|
/**
|
||||||
|
* 查询订单剩余待分金额API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_ORDER_AMOUNTS(HttpMethod.GET, "%s/v3/brand/profitsharing/orders/{transaction_id}/amounts"),
|
||||||
|
/**
|
||||||
|
* 查询最大分账比例API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_CONFIGS(HttpMethod.GET, "%s/v3/brand/profitsharing/brand-configs/{brand_mchid}"),
|
||||||
|
/**
|
||||||
|
* 添加品牌分账接收方API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_RECEIVERS_ADD(HttpMethod.POST, "%s/v3/brand/profitsharing/receivers/add"),
|
||||||
|
/**
|
||||||
|
* 删除分账接收方API.
|
||||||
|
*
|
||||||
|
* @since 1.0.15.RELEASE
|
||||||
|
*/
|
||||||
|
BRAND_PROFITSHARING_RECEIVERS_DELETE(HttpMethod.POST, "%s/v3/brand/profitsharing/receivers/delete"),
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
/**
|
/**
|
||||||
* 服务商-商户进件-特约商户进件-提交申请单API.
|
* 服务商-商户进件-特约商户进件-提交申请单API.
|
||||||
@@ -830,7 +898,7 @@ public enum WechatPayV3Type {
|
|||||||
*/
|
*/
|
||||||
ECOMMERCE_PROFITSHARING_RECEIVERS_ADD(HttpMethod.POST, "%s/v3/ecommerce/profitsharing/receivers/add"),
|
ECOMMERCE_PROFITSHARING_RECEIVERS_ADD(HttpMethod.POST, "%s/v3/ecommerce/profitsharing/receivers/add"),
|
||||||
/**
|
/**
|
||||||
* 行业方案-电商收付通-分账-添加分账接收方API.
|
* 行业方案-电商收付通-分账-删除分账接收方API.
|
||||||
*
|
*
|
||||||
* @since 1.0.14.RELEASE
|
* @since 1.0.14.RELEASE
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
@@ -94,8 +92,7 @@ public abstract class AbstractApi {
|
|||||||
* @param mapper the mapper
|
* @param mapper the mapper
|
||||||
*/
|
*/
|
||||||
private void applyObjectMapper(ObjectMapper mapper) {
|
private void applyObjectMapper(ObjectMapper mapper) {
|
||||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
|
||||||
)
|
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
// empty string error
|
// empty string error
|
||||||
.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
|
.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
import cn.felord.payment.wechat.v3.model.PageParams;
|
import cn.felord.payment.wechat.v3.model.PageParams;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,17 +13,18 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
|
|
||||||
import cn.felord.payment.PayException;
|
import cn.felord.payment.PayException;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.FileSystemResource;
|
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
import java.security.*;
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.KeyStoreException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,17 +34,20 @@ import java.security.cert.X509Certificate;
|
|||||||
* @since 1.0.0.RELEASE
|
* @since 1.0.0.RELEASE
|
||||||
*/
|
*/
|
||||||
public class KeyPairFactory {
|
public class KeyPairFactory {
|
||||||
|
private static final String CERT_ALIAS = "Tenpay Certificate";
|
||||||
private static final KeyStore PKCS12_KEY_STORE;
|
private static final KeyStore PKCS12_KEY_STORE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
PKCS12_KEY_STORE = KeyStore.getInstance("PKCS12");
|
PKCS12_KEY_STORE = KeyStore.getInstance("PKCS12");
|
||||||
} catch (KeyStoreException e) {
|
} catch (KeyStoreException e) {
|
||||||
throw new PayException(" wechat pay keystore initialization failed");
|
throw new PayException(" wechat pay keystore initialization failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WechatMetaBean initWechatMetaBean(Resource resource, String keyPass) {
|
||||||
|
return this.initWechatMetaBean(resource, CERT_ALIAS, keyPass);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公私钥.
|
* 获取公私钥.
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
@@ -58,12 +56,7 @@ import java.security.cert.CertificateFactory;
|
|||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +89,7 @@ public class SignatureProvider {
|
|||||||
/**
|
/**
|
||||||
* 微信平台证书容器 key = 序列号 value = 证书对象
|
* 微信平台证书容器 key = 序列号 value = 证书对象
|
||||||
*/
|
*/
|
||||||
private static final Map<String, X509WechatCertificateInfo> CERTIFICATE_MAP = new ConcurrentHashMap<>();
|
private static final Set<X509WechatCertificateInfo> CERTIFICATE_SET = Collections.synchronizedSet(new HashSet<>());
|
||||||
/**
|
/**
|
||||||
* 加密算法提供方 - BouncyCastle
|
* 加密算法提供方 - BouncyCastle
|
||||||
*/
|
*/
|
||||||
@@ -186,14 +179,21 @@ public class SignatureProvider {
|
|||||||
public boolean responseSignVerify(ResponseSignVerifyParams params) {
|
public boolean responseSignVerify(ResponseSignVerifyParams params) {
|
||||||
|
|
||||||
String wechatpaySerial = params.getWechatpaySerial();
|
String wechatpaySerial = params.getWechatpaySerial();
|
||||||
if (CERTIFICATE_MAP.isEmpty() || !CERTIFICATE_MAP.containsKey(wechatpaySerial)) {
|
X509WechatCertificateInfo certificate = CERTIFICATE_SET.stream()
|
||||||
wechatMetaContainer.getTenantIds().forEach(this::refreshCertificate);
|
.filter(cert -> Objects.equals(wechatpaySerial, cert.getWechatPaySerial()))
|
||||||
}
|
.findAny()
|
||||||
Certificate certificate = CERTIFICATE_MAP.get(wechatpaySerial).getX509Certificate();
|
.orElseGet(() -> {
|
||||||
|
wechatMetaContainer.getTenantIds().forEach(this::refreshCertificate);
|
||||||
|
return CERTIFICATE_SET.stream()
|
||||||
|
.filter(cert -> Objects.equals(wechatpaySerial, cert.getWechatPaySerial()))
|
||||||
|
.findAny()
|
||||||
|
.orElseThrow(() -> new PayException("cannot obtain the certificate"));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody());
|
final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody());
|
||||||
Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER);
|
Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER);
|
||||||
signer.initVerify(certificate);
|
signer.initVerify(certificate.getX509Certificate());
|
||||||
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature()));
|
return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature()));
|
||||||
@@ -235,7 +235,11 @@ public class SignatureProvider {
|
|||||||
}
|
}
|
||||||
ArrayNode certificates = bodyObjectNode.withArray("data");
|
ArrayNode certificates = bodyObjectNode.withArray("data");
|
||||||
if (certificates.isArray() && certificates.size() > 0) {
|
if (certificates.isArray() && certificates.size() > 0) {
|
||||||
CERTIFICATE_MAP.remove(tenantId);
|
CERTIFICATE_SET.forEach(x509WechatCertificateInfo -> {
|
||||||
|
if (Objects.equals(tenantId, x509WechatCertificateInfo.getTenantId())) {
|
||||||
|
CERTIFICATE_SET.remove(x509WechatCertificateInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509", BC_PROVIDER);
|
final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509", BC_PROVIDER);
|
||||||
certificates.forEach(objectNode -> {
|
certificates.forEach(objectNode -> {
|
||||||
JsonNode encryptCertificate = objectNode.get("encrypt_certificate");
|
JsonNode encryptCertificate = objectNode.get("encrypt_certificate");
|
||||||
@@ -253,7 +257,7 @@ public class SignatureProvider {
|
|||||||
x509WechatCertificateInfo.setWechatPaySerial(responseSerialNo);
|
x509WechatCertificateInfo.setWechatPaySerial(responseSerialNo);
|
||||||
x509WechatCertificateInfo.setTenantId(tenantId);
|
x509WechatCertificateInfo.setTenantId(tenantId);
|
||||||
x509WechatCertificateInfo.setX509Certificate((X509Certificate) certificate);
|
x509WechatCertificateInfo.setX509Certificate((X509Certificate) certificate);
|
||||||
CERTIFICATE_MAP.put(responseSerialNo, x509WechatCertificateInfo);
|
CERTIFICATE_SET.add(x509WechatCertificateInfo);
|
||||||
} catch (CertificateException e) {
|
} catch (CertificateException e) {
|
||||||
throw new PayException("An error occurred while generating the wechat v3 certificate, reason : " + e.getMessage());
|
throw new PayException("An error occurred while generating the wechat v3 certificate, reason : " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -296,7 +300,8 @@ public class SignatureProvider {
|
|||||||
throw new PayException(e);
|
throw new PayException(e);
|
||||||
}
|
}
|
||||||
return new String(bytes, StandardCharsets.UTF_8);
|
return new String(bytes, StandardCharsets.UTF_8);
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | NoSuchProviderException e) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException |
|
||||||
|
InvalidAlgorithmParameterException | NoSuchProviderException e) {
|
||||||
throw new PayException(e);
|
throw new PayException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,10 +341,10 @@ public class SignatureProvider {
|
|||||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId);
|
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId);
|
||||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||||
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", BC_PROVIDER);
|
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", BC_PROVIDER);
|
||||||
cipher.init(Cipher.DECRYPT_MODE,privateKey);
|
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
byte[] data = Base64Utils.decodeFromString(message);
|
byte[] data = Base64Utils.decodeFromString(message);
|
||||||
byte[] cipherData = cipher.doFinal(data);
|
byte[] cipherData = cipher.doFinal(data);
|
||||||
return new String(cipherData,StandardCharsets.UTF_8);
|
return new String(cipherData, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new PayException(e);
|
throw new PayException(e);
|
||||||
@@ -353,22 +358,17 @@ public class SignatureProvider {
|
|||||||
* @return the x 509 wechat certificate info
|
* @return the x 509 wechat certificate info
|
||||||
*/
|
*/
|
||||||
public X509WechatCertificateInfo getCertificate(String tenantId) {
|
public X509WechatCertificateInfo getCertificate(String tenantId) {
|
||||||
for (String serial : CERTIFICATE_MAP.keySet()) {
|
|
||||||
X509WechatCertificateInfo wechatCertificateInfo = CERTIFICATE_MAP.get(serial);
|
|
||||||
X509Certificate x509Cert = wechatCertificateInfo.getX509Certificate();
|
|
||||||
if (wechatCertificateInfo.getTenantId().equals(tenantId)){
|
|
||||||
try {
|
|
||||||
x509Cert.checkValidity();
|
|
||||||
|
|
||||||
return wechatCertificateInfo;
|
return CERTIFICATE_SET.stream()
|
||||||
} catch (Exception e) {
|
.filter(cert -> Objects.equals(tenantId, cert.getTenantId()))
|
||||||
log.warn("the wechat certificate is invalid , {}", e.getMessage());
|
.findAny()
|
||||||
// Async?
|
.orElseGet(() -> {
|
||||||
wechatMetaContainer.getTenantIds().forEach(this::refreshCertificate);
|
wechatMetaContainer.getTenantIds().forEach(this::refreshCertificate);
|
||||||
}
|
return CERTIFICATE_SET.stream()
|
||||||
}
|
.filter(cert -> Objects.equals(tenantId, cert.getTenantId()))
|
||||||
}
|
.findAny()
|
||||||
throw new PayException("failed to obtain wechat pay x509Certificate ");
|
.orElseThrow(() -> new PayException("cannot obtain the certificate"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
@@ -44,17 +42,6 @@ public class WechatApiProvider {
|
|||||||
this.wechatPayClient = wechatPayClient;
|
this.wechatPayClient = wechatPayClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 代金券.
|
|
||||||
*
|
|
||||||
* @param tenantId the tenant id
|
|
||||||
* @return the wechat marketing favor api
|
|
||||||
* @since 1.0.0.RELEASE
|
|
||||||
*/
|
|
||||||
public WechatMarketingFavorApi favorApi(String tenantId) {
|
|
||||||
return new WechatMarketingFavorApi(this.wechatPayClient, tenantId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通支付-直连模式.
|
* 普通支付-直连模式.
|
||||||
*
|
*
|
||||||
@@ -66,7 +53,6 @@ public class WechatApiProvider {
|
|||||||
return new WechatDirectPayApi(wechatPayClient, tenantId);
|
return new WechatDirectPayApi(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通支付-服务商模式.
|
* 普通支付-服务商模式.
|
||||||
*
|
*
|
||||||
@@ -122,6 +108,17 @@ public class WechatApiProvider {
|
|||||||
return new WechatDiscountCardApi(wechatPayClient, tenantId);
|
return new WechatDiscountCardApi(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代金券.
|
||||||
|
*
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
* @return the wechat marketing favor api
|
||||||
|
* @since 1.0.0.RELEASE
|
||||||
|
*/
|
||||||
|
public WechatMarketingFavorApi favorApi(String tenantId) {
|
||||||
|
return new WechatMarketingFavorApi(this.wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付商家券.
|
* 微信支付商家券.
|
||||||
*
|
*
|
||||||
@@ -133,6 +130,16 @@ public class WechatApiProvider {
|
|||||||
return new WechatMarketingBusiFavorApi(wechatPayClient, tenantId);
|
return new WechatMarketingBusiFavorApi(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 委托营销-直连商户
|
||||||
|
*
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
* @return the wechat marketing partnership api
|
||||||
|
*/
|
||||||
|
public WechatMarketingPartnershipApi marketingshipApi(String tenantId) {
|
||||||
|
return new WechatMarketingPartnershipApi(this.wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量转账到零钱.
|
* 批量转账到零钱.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -200,7 +207,7 @@ public class WechatApiProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务商微信支付分账,基于V3
|
* 服务商-微信支付分账,基于V3
|
||||||
*
|
*
|
||||||
* @param tenantId the tenant id
|
* @param tenantId the tenant id
|
||||||
* @return the wechat partner profitsharing api
|
* @return the wechat partner profitsharing api
|
||||||
@@ -209,6 +216,16 @@ public class WechatApiProvider {
|
|||||||
return new WechatPartnerProfitsharingApi(wechatPayClient, tenantId);
|
return new WechatPartnerProfitsharingApi(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商-品牌分账
|
||||||
|
*
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
* @return the wechat brand profitsharing api
|
||||||
|
*/
|
||||||
|
public WechatBrandProfitsharingApi brandProfitsharingApi(String tenantId) {
|
||||||
|
return new WechatBrandProfitsharingApi(wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信V3服务商-商户进件-特约商户进件
|
* 微信V3服务商-商户进件-特约商户进件
|
||||||
*
|
*
|
||||||
@@ -254,7 +271,7 @@ public class WechatApiProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务商智慧商圈
|
* 服务商-智慧商圈
|
||||||
*
|
*
|
||||||
* @param tenantId the tenant id
|
* @param tenantId the tenant id
|
||||||
* @return the wechat business circle api
|
* @return the wechat business circle api
|
||||||
@@ -265,7 +282,7 @@ public class WechatApiProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直连商户智慧商圈
|
* 直连商户-智慧商圈
|
||||||
*
|
*
|
||||||
* @param tenantId the tenant id
|
* @param tenantId the tenant id
|
||||||
* @return the wechat business circle api
|
* @return the wechat business circle api
|
||||||
@@ -297,4 +314,13 @@ public class WechatApiProvider {
|
|||||||
return new WechatCapitalApi(wechatPayClient, tenantId);
|
return new WechatCapitalApi(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险合规-消费者投诉2.0
|
||||||
|
*
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
* @return the wechat complaints api
|
||||||
|
*/
|
||||||
|
public WechatComplaintsApi complaintsApi(String tenantId) {
|
||||||
|
return new WechatComplaintsApi(wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class WechatBatchTransferApi extends AbstractApi {
|
|||||||
List<CreateBatchTransferParams.TransferDetailListItem> encrypted = transferDetailList.stream()
|
List<CreateBatchTransferParams.TransferDetailListItem> encrypted = transferDetailList.stream()
|
||||||
.peek(transferDetailListItem -> {
|
.peek(transferDetailListItem -> {
|
||||||
String userName = transferDetailListItem.getUserName();
|
String userName = transferDetailListItem.getUserName();
|
||||||
if(StringUtils.hasText(userName)){
|
if (StringUtils.hasText(userName)) {
|
||||||
String encryptedUserName = signatureProvider.encryptRequestMessage(userName, x509Certificate);
|
String encryptedUserName = signatureProvider.encryptRequestMessage(userName, x509Certificate);
|
||||||
transferDetailListItem.setUserName(encryptedUserName);
|
transferDetailListItem.setUserName(encryptedUserName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,327 @@
|
|||||||
|
/*
|
||||||
|
* 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.v3;
|
||||||
|
|
||||||
|
import cn.felord.payment.wechat.WechatPayProperties;
|
||||||
|
import cn.felord.payment.wechat.enumeration.TarType;
|
||||||
|
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||||
|
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||||
|
import cn.felord.payment.wechat.v3.model.ecommerce.BrandReceiver;
|
||||||
|
import cn.felord.payment.wechat.v3.model.ecommerce.BrandReceiverDeleteParams;
|
||||||
|
import cn.felord.payment.wechat.v3.model.ecommerce.EcommerceFinishOrder;
|
||||||
|
import cn.felord.payment.wechat.v3.model.ecommerce.EcommerceReturnOrderParams;
|
||||||
|
import cn.felord.payment.wechat.v3.model.profitsharing.BrandProfitsharingOrder;
|
||||||
|
import cn.felord.payment.wechat.v3.model.profitsharing.PartnerProfitsharingBillParams;
|
||||||
|
import cn.felord.payment.wechat.v3.model.profitsharing.PartnerQueryOrderParams;
|
||||||
|
import cn.felord.payment.wechat.v3.model.profitsharing.PartnerReturnOrdersParams;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商-资金应用-连锁品牌分账
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.15
|
||||||
|
*/
|
||||||
|
public class WechatBrandProfitsharingApi extends AbstractApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new Abstract api.
|
||||||
|
*
|
||||||
|
* @param wechatPayClient the wechat pay client
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
*/
|
||||||
|
public WechatBrandProfitsharingApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||||
|
super(wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求分账API
|
||||||
|
*
|
||||||
|
* @param brandProfitsharingOrder the brand profitsharing order
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> profitsharingOrders(BrandProfitsharingOrder brandProfitsharingOrder) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_ORDERS, brandProfitsharingOrder)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
params.setAppid(this.wechatMetaBean().getV3().getAppId());
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Post(uri, params);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询分账结果API
|
||||||
|
* <p>
|
||||||
|
* 发起分账请求后,可调用此接口查询分账结果
|
||||||
|
* <p>
|
||||||
|
* 注意:
|
||||||
|
* <ul>
|
||||||
|
* <li>发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param queryOrderParams the query order params
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> queryProfitsharingOrder(PartnerQueryOrderParams queryOrderParams) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_RESULT, queryOrderParams)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||||
|
queryParams.add("sub_mchid", params.getSubMchid());
|
||||||
|
queryParams.add("transaction_id", params.getTransactionId());
|
||||||
|
queryParams.add("out_order_no", params.getOutOrderNo());
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.queryParams(queryParams)
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Get(uri);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求分账回退API
|
||||||
|
* <p>
|
||||||
|
* 如果订单已经分账,在退款时,可以先调此接口,将已分账的资金从分账接收方的账户回退给分账方,再发起退款
|
||||||
|
*
|
||||||
|
* @param returnOrdersParams the return orders params
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> returnOrders(PartnerReturnOrdersParams returnOrdersParams) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_RETURN_ORDERS, returnOrdersParams)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Post(uri, params);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询分账回退结果API
|
||||||
|
* <p>
|
||||||
|
* 商户需要核实回退结果,可调用此接口查询回退结果
|
||||||
|
* <p>
|
||||||
|
* 注意:
|
||||||
|
* <ul>
|
||||||
|
* <li>如果分账回退接口返回状态为处理中,可调用此接口查询回退结果</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param queryReturnOrderParams the query return order params
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> queryReturnOrders(EcommerceReturnOrderParams queryReturnOrderParams) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_RETURN_ORDERS_RESULT, queryReturnOrderParams)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||||
|
queryParams.add("sub_mchid", params.getSubMchid());
|
||||||
|
String orderId = params.getOrderId();
|
||||||
|
if (orderId != null) {
|
||||||
|
queryParams.add("order_id", orderId);
|
||||||
|
}
|
||||||
|
String outOrderNo = params.getOutOrderNo();
|
||||||
|
if (outOrderNo != null) {
|
||||||
|
queryParams.add("out_order_no", outOrderNo);
|
||||||
|
}
|
||||||
|
queryParams.add("out_return_no", params.getOutReturnNo());
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.queryParams(queryParams)
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Get(uri);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完结分账API
|
||||||
|
* <p>
|
||||||
|
* 不需要进行分账的订单,可直接调用本接口将订单的金额全部解冻给二级商户。
|
||||||
|
*
|
||||||
|
* @param finishOrder the finish order
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> finishOrder(EcommerceFinishOrder finishOrder) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_FINISH_ORDER, finishOrder)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Post(uri, params);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单剩余待分金额API
|
||||||
|
* <p>
|
||||||
|
* 可调用此接口查询订单剩余待分金额
|
||||||
|
*
|
||||||
|
* @param transactionId the transaction id
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> queryOrderAmounts(String transactionId) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_ORDER_AMOUNTS, transactionId)
|
||||||
|
.function((wechatPayV3Type, id) -> {
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.expand(id)
|
||||||
|
.toUri();
|
||||||
|
return Get(uri);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最大分账比例API
|
||||||
|
*
|
||||||
|
* @param brandMchid the brandMchid
|
||||||
|
* @return wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> brandConfigs(String brandMchid) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_CONFIGS, brandMchid)
|
||||||
|
.function((wechatPayV3Type, id) -> {
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.expand(id)
|
||||||
|
.toUri();
|
||||||
|
return Get(uri);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加分账接收方API
|
||||||
|
* <p>
|
||||||
|
* 商户发起添加分账接收方请求,建立分账接收方列表。后续可通过发起分账请求,将分账方商户结算后的资金,分到该分账接收方
|
||||||
|
*
|
||||||
|
* @param brandReceiver the brandReceiver
|
||||||
|
* @return wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> addReceivers(BrandReceiver brandReceiver) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_RECEIVERS_ADD, brandReceiver)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||||
|
params.setAppid(v3.getAppId());
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Post(uri, params);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分账接收方API
|
||||||
|
* <p>
|
||||||
|
* 商户发起删除分账接收方请求。删除后,不支持将分账方商户结算后的资金,分到该分账接收方
|
||||||
|
*
|
||||||
|
* @param delReceiversParams the del receivers params
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
|
public WechatResponseEntity<ObjectNode> deleteReceivers(BrandReceiverDeleteParams delReceiversParams) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.BRAND_PROFITSHARING_RECEIVERS_DELETE, delReceiversParams)
|
||||||
|
.function((wechatPayV3Type, params) -> {
|
||||||
|
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||||
|
params.setAppid(v3.getAppId());
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Post(uri, params);
|
||||||
|
})
|
||||||
|
.consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
return wechatResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请分账账单API
|
||||||
|
*
|
||||||
|
* @param billParams the bill params
|
||||||
|
* @return the response entity
|
||||||
|
*/
|
||||||
|
public ResponseEntity<Resource> downloadMerchantBills(PartnerProfitsharingBillParams billParams) {
|
||||||
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
|
this.client().withType(WechatPayV3Type.PROFITSHARING_BILLS, billParams)
|
||||||
|
.function(((wechatPayV3Type, params) -> {
|
||||||
|
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||||
|
String subMchid = params.getSubMchid();
|
||||||
|
if (subMchid != null) {
|
||||||
|
queryParams.add("sub_mchid", subMchid);
|
||||||
|
}
|
||||||
|
LocalDate billDate = params.getBillDate();
|
||||||
|
queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE));
|
||||||
|
TarType tarType = params.getTarType();
|
||||||
|
if (Objects.nonNull(tarType)) {
|
||||||
|
queryParams.add("tar_type", tarType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||||
|
.queryParams(queryParams)
|
||||||
|
.build()
|
||||||
|
.toUri();
|
||||||
|
return Get(uri);
|
||||||
|
})).consumer(wechatResponseEntity::convert)
|
||||||
|
.request();
|
||||||
|
String downloadUrl = Objects.requireNonNull(wechatResponseEntity.getBody())
|
||||||
|
.get("download_url")
|
||||||
|
.asText();
|
||||||
|
|
||||||
|
String ext = Objects.equals(TarType.GZIP, billParams.getTarType()) ? ".gzip" : ".txt";
|
||||||
|
String filename = "profitsharingbill-" + billParams.getBillDate().toString() + ext;
|
||||||
|
return this.downloadBillResponse(downloadUrl, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.v3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险合规-消费者投诉2.0
|
||||||
|
*
|
||||||
|
* @author felord.cn
|
||||||
|
* @since 1.0.16.RELEASE
|
||||||
|
*/
|
||||||
|
public class WechatComplaintsApi extends AbstractApi{
|
||||||
|
/**
|
||||||
|
* Instantiates a new Abstract api.
|
||||||
|
*
|
||||||
|
* @param wechatPayClient the wechat pay client
|
||||||
|
* @param tenantId the tenant id
|
||||||
|
*/
|
||||||
|
public WechatComplaintsApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||||
|
super(wechatPayClient, tenantId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2019-2022 felord.cn
|
* Copyright 2019-2022 felord.cn
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user