Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
IJPay
提交
9f7596a1
I
IJPay
项目概览
int
/
IJPay
9 个月 前同步成功
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
IJPay
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9f7596a1
编写于
4月 01, 2023
作者:
J
Javen205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🏗
调整微信支付 v3 接口授权认证类型为枚举
上级
de53d0a2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
30 deletion
+86
-30
IJPay-Core/src/main/java/com/ijpay/core/enums/AuthTypeEnum.java
...Core/src/main/java/com/ijpay/core/enums/AuthTypeEnum.java
+54
-0
IJPay-Core/src/main/java/com/ijpay/core/kit/PayKit.java
IJPay-Core/src/main/java/com/ijpay/core/kit/PayKit.java
+1
-1
IJPay-Core/src/main/java/com/ijpay/core/kit/WxPayKit.java
IJPay-Core/src/main/java/com/ijpay/core/kit/WxPayKit.java
+3
-2
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
+28
-27
未找到文件。
IJPay-Core/src/main/java/com/ijpay/core/enums/AuthTypeEnum.java
0 → 100644
浏览文件 @
9f7596a1
package
com.ijpay.core.enums
;
/**
* <p>IJPay 让支付触手可及,封装了微信支付、支付宝支付、银联支付等常用的支付方式以及各种常用的接口。</p>
*
* <p>不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。 </p>
*
* <p>IJPay 交流群: 723992875、864988890</p>
*
* <p>Node.js 版: <a href="https://gitee.com/javen205/TNWX">https://gitee.com/javen205/TNWX</a></p>
*
* <p>微信支付 v3 接口授权认证类型枚举</p>
*
* @author Javen
*/
public
enum
AuthTypeEnum
{
/**
* 国密
*/
SM
(
"WECHATPAY2-SM2-WITH-SM3"
,
"国密算法"
),
/**
* RSA
*/
RSA
(
"WECHATPAY2-SHA256-RSA2048"
,
"RSA算法"
),
;
private
final
String
url
;
private
final
String
desc
;
AuthTypeEnum
(
String
url
,
String
desc
)
{
this
.
url
=
url
;
this
.
desc
=
desc
;
}
/**
* 获取枚举URL
*
* @return 枚举编码
*/
public
String
getUrl
()
{
return
url
;
}
/**
* 获取详细的描述信息
*
* @return 描述信息
*/
public
String
getDesc
()
{
return
desc
;
}
}
IJPay-Core/src/main/java/com/ijpay/core/kit/PayKit.java
浏览文件 @
9f7596a1
...
...
@@ -398,7 +398,7 @@ public class PayKit {
* @param nonceStr 请求随机串
* @param timestamp 时间戳
* @param signature 签名值
* @param authType 认证类型
,目前为WECHATPAY2-SHA256-RSA2048
* @param authType 认证类型
* @return 请求头 Authorization
*/
public
static
String
getAuthorization
(
String
mchId
,
String
serialNo
,
String
nonceStr
,
String
timestamp
,
String
signature
,
String
authType
)
{
...
...
IJPay-Core/src/main/java/com/ijpay/core/kit/WxPayKit.java
浏览文件 @
9f7596a1
...
...
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.ijpay.core.IJPayHttpResponse
;
import
com.ijpay.core.enums.AuthTypeEnum
;
import
com.ijpay.core.enums.RequestMethodEnum
;
import
com.ijpay.core.enums.SignType
;
...
...
@@ -578,7 +579,7 @@ public class WxPayKit {
String
serialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
PayKit
.
generateStr
();
return
buildAuthorization
(
method
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
);
...
...
@@ -600,7 +601,7 @@ public class WxPayKit {
String
serialNo
,
PrivateKey
privateKey
,
String
body
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
PayKit
.
generateStr
();
return
buildAuthorization
(
method
,
urlSuffix
,
mchId
,
serialNo
,
privateKey
,
body
,
nonceStr
,
timestamp
,
authType
);
...
...
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
浏览文件 @
9f7596a1
...
...
@@ -20,6 +20,7 @@ import com.ijpay.wxpay.enums.v2.PayApiEnum;
import
com.ijpay.wxpay.enums.v2.ProfitSharingApiEnum
;
import
com.ijpay.wxpay.enums.v2.RedPackApiEnum
;
import
com.ijpay.wxpay.enums.v2.TransferApiEnum
;
import
com.ijpay.core.enums.AuthTypeEnum
;
import
java.io.File
;
import
java.io.InputStream
;
...
...
@@ -255,9 +256,9 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
// 构建 Authorization
String
authorization
=
WxPayKit
.
buildAuthorization
(
method
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
);
...
...
@@ -299,9 +300,9 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
// 构建 Authorization
String
authorization
=
WxPayKit
.
buildAuthorization
(
method
,
urlSuffix
,
mchId
,
serialNo
,
privateKey
,
body
,
nonceStr
,
timestamp
,
authType
);
...
...
@@ -339,9 +340,9 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
return
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
null
);
}
...
...
@@ -361,9 +362,9 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
String
body
)
throws
Exception
{
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
String
body
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
return
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
privateKey
,
body
,
nonceStr
,
timestamp
,
authType
,
null
);
}
...
...
@@ -383,10 +384,10 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
if
(
null
!=
params
&&
!
params
.
keySet
().
isEmpty
())
{
urlSuffix
=
urlSuffix
.
concat
(
"?"
).
concat
(
PayKit
.
createLinkString
(
params
,
true
));
...
...
@@ -409,10 +410,10 @@ public class WxPayApi {
* @throws Exception 接口执行异常
*/
public
static
IJPayHttpResponse
v3
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
Map
<
String
,
String
>
params
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
Map
<
String
,
String
>
params
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
if
(
null
!=
params
&&
!
params
.
keySet
().
isEmpty
())
{
urlSuffix
=
urlSuffix
.
concat
(
"?"
).
concat
(
PayKit
.
createLinkString
(
params
,
true
));
...
...
@@ -436,7 +437,7 @@ public class WxPayApi {
*/
public
static
IJPayHttpResponse
v3
(
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
,
File
file
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
return
v3
(
RequestMethodEnum
.
UPLOAD
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
file
);
}
...
...
@@ -458,7 +459,7 @@ public class WxPayApi {
public
static
IJPayHttpResponse
v3
(
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
PrivateKey
privateKey
,
String
body
,
File
file
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
authType
=
AuthTypeEnum
.
RSA
.
getUrl
()
;
String
nonceStr
=
WxPayKit
.
generateStr
();
return
v3
(
RequestMethodEnum
.
UPLOAD
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
privateKey
,
body
,
nonceStr
,
timestamp
,
authType
,
file
);
}
...
...
@@ -483,9 +484,9 @@ public class WxPayApi {
*/
@Deprecated
public
static
Map
<
String
,
Object
>
v3Execution
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
IJPayHttpResponse
response
=
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
file
);
return
buildResMap
(
response
);
}
...
...
@@ -505,7 +506,7 @@ public class WxPayApi {
*/
@Deprecated
public
static
Map
<
String
,
Object
>
v3Execution
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
String
serialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
IJPayHttpResponse
response
=
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
null
,
keyPath
,
body
);
return
buildResMap
(
response
);
}
...
...
@@ -526,7 +527,7 @@ public class WxPayApi {
*/
@Deprecated
public
static
Map
<
String
,
Object
>
v3Execution
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
String
body
)
throws
Exception
{
IJPayHttpResponse
response
=
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
keyPath
,
body
);
return
buildResMap
(
response
);
}
...
...
@@ -547,8 +548,8 @@ public class WxPayApi {
*/
@Deprecated
public
static
Map
<
String
,
Object
>
v3Execution
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
platSerialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
IJPayHttpResponse
response
=
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
platSerialNo
,
keyPath
,
params
);
return
buildResMap
(
response
);
}
...
...
@@ -568,8 +569,8 @@ public class WxPayApi {
*/
@Deprecated
public
static
Map
<
String
,
Object
>
v3Execution
(
RequestMethodEnum
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
String
mchId
,
String
serialNo
,
String
keyPath
,
Map
<
String
,
String
>
params
)
throws
Exception
{
IJPayHttpResponse
response
=
v3
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
null
,
keyPath
,
params
);
return
buildResMap
(
response
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录