Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
IJPay
提交
9054365f
I
IJPay
项目概览
int
/
IJPay
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
9054365f
编写于
2月 27, 2020
作者:
J
Javen205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
添加 Api-v3 接口
上级
2fb30842
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
24 deletion
+34
-24
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
+34
-24
未找到文件。
IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java
浏览文件 @
9054365f
...
...
@@ -5,7 +5,6 @@ import com.ijpay.core.enums.RequestMethod;
import
com.ijpay.core.enums.SignType
;
import
com.ijpay.core.kit.HttpKit
;
import
com.ijpay.core.kit.PayKit
;
import
com.ijpay.core.kit.RsaKit
;
import
com.ijpay.core.kit.WxPayKit
;
import
com.ijpay.wxpay.enums.WxApiType
;
import
com.ijpay.wxpay.enums.WxDomain
;
...
...
@@ -127,6 +126,10 @@ public class WxPayApi {
return
doPostSSL
(
apiUrl
,
params
,
certFile
,
certPass
);
}
public
static
String
execution
(
String
apiUrl
,
Map
<
String
,
String
>
params
,
String
certPath
,
String
certPass
,
String
filePath
)
{
return
doUploadSSL
(
apiUrl
,
params
,
certPath
,
certPass
,
filePath
);
}
/**
* V3 接口统一执行入口
*
...
...
@@ -144,22 +147,21 @@ public class WxPayApi {
* @return {@link String} 请求返回的结果
* @throws Exception 接口执行异常
*/
public
static
String
v3Execution
(
RequestMethod
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
,
String
nonceStr
,
long
timestamp
,
String
authType
,
File
file
)
throws
Exception
{
// 构建签名参数
String
buildSignMessage
=
PayKit
.
buildSignMessage
(
method
,
urlSuffix
,
timestamp
,
nonceStr
,
body
);
// 获取商户私钥
String
key
=
PayKit
.
getPrivateKey
(
keyPath
);
// 生成签名
String
signature
=
RsaKit
.
encryptByPrivateKey
(
buildSignMessage
,
key
);
// 根据平台规则生成请求头 authorization
String
authorization
=
PayKit
.
getAuthorization
(
mchId
,
serialNo
,
nonceStr
,
String
.
valueOf
(
timestamp
),
signature
,
authType
);
public
static
String
v3Execution
(
RequestMethod
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
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
);
if
(
method
==
RequestMethod
.
GET
)
{
return
doGet
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
null
);
}
else
if
(
method
==
RequestMethod
.
POST
)
{
return
doPost
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
body
);
return
doPost
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
serialNo
,
body
);
}
else
if
(
method
==
RequestMethod
.
DELETE
)
{
return
doDelete
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
serialNo
,
body
).
toString
();
}
else
if
(
method
==
RequestMethod
.
UPLOAD
)
{
return
doUpload
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
body
,
file
);
return
doUpload
(
urlPrefix
.
concat
(
urlSuffix
),
authorization
,
serialNo
,
body
,
file
);
}
return
null
;
}
...
...
@@ -187,43 +189,43 @@ public class WxPayApi {
/**
* V3 接口统一执行入口
*
* @param method {@link RequestMethod} 请求方法
* @param urlPrefix 可通过 {@link WxDomain}来获取
* @param urlSuffix 可通过 {@link WxApiType} 来获取,URL挂载参数需要自行拼接
* @param mchId 商户Id
* @param serialNo 商户 API 证书序列号
* @param keyPath apiclient_key.pem 证书路径
* @param body 接口请求参数
* @param
file 文件
* @param
params Get 接口请求参数
* @return {@link String} 请求返回的结果
* @throws Exception 接口执行异常
*/
public
static
String
v3
Upload
(
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
,
File
file
)
throws
Exception
{
public
static
String
v3
Execution
(
RequestMethod
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
,
Map
<
String
,
String
>
params
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
nonceStr
=
PayKit
.
generateStr
();
return
v3Execution
(
RequestMethod
.
UPLOAD
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
file
);
urlSuffix
=
urlSuffix
.
concat
(
"?"
).
concat
(
PayKit
.
createLinkString
(
params
,
true
));
return
v3Execution
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
null
);
}
/**
* V3 接口统一执行入口
*
* @param method {@link RequestMethod} 请求方法
* @param urlPrefix 可通过 {@link WxDomain}来获取
* @param urlSuffix 可通过 {@link WxApiType} 来获取,URL挂载参数需要自行拼接
* @param mchId 商户Id
* @param serialNo 商户 API 证书序列号
* @param keyPath apiclient_key.pem 证书路径
* @param body 接口请求参数
* @param
params Get 接口请求参数
* @param
file 文件
* @return {@link String} 请求返回的结果
* @throws Exception 接口执行异常
*/
public
static
String
v3
Execution
(
RequestMethod
method
,
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
,
Map
<
String
,
String
>
params
)
throws
Exception
{
public
static
String
v3
Upload
(
String
urlPrefix
,
String
urlSuffix
,
String
mchId
,
String
serialNo
,
String
keyPath
,
String
body
,
File
file
)
throws
Exception
{
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
String
authType
=
"WECHATPAY2-SHA256-RSA2048"
;
String
nonceStr
=
PayKit
.
generateStr
();
urlSuffix
=
urlSuffix
.
concat
(
"?"
).
concat
(
PayKit
.
createLinkString
(
params
,
true
));
return
v3Execution
(
method
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
null
);
return
v3Execution
(
RequestMethod
.
UPLOAD
,
urlPrefix
,
urlSuffix
,
mchId
,
serialNo
,
keyPath
,
body
,
nonceStr
,
timestamp
,
authType
,
file
);
}
/**
...
...
@@ -1170,12 +1172,16 @@ public class WxPayApi {
return
HttpKit
.
getDelegate
().
get
(
url
,
authorization
,
params
);
}
public
static
String
doPost
(
String
url
,
String
authorization
,
String
data
)
{
return
HttpKit
.
getDelegate
().
post
(
url
,
authorization
,
data
);
public
static
String
doPost
(
String
url
,
String
authorization
,
String
serialNumber
,
String
data
)
{
return
HttpKit
.
getDelegate
().
postBySafe
(
url
,
authorization
,
serialNumber
,
data
);
}
public
static
Integer
doDelete
(
String
url
,
String
authorization
,
String
serialNumber
,
String
data
)
{
return
HttpKit
.
getDelegate
().
delete
(
url
,
authorization
,
serialNumber
,
data
);
}
public
static
String
doUpload
(
String
url
,
String
authorization
,
String
data
,
File
file
)
{
return
HttpKit
.
getDelegate
().
upload
(
url
,
authorization
,
data
,
file
);
public
static
String
doUpload
(
String
url
,
String
authorization
,
String
serialNumber
,
String
data
,
File
file
)
{
return
HttpKit
.
getDelegate
().
upload
(
url
,
authorization
,
serialNumber
,
data
,
file
);
}
public
static
String
doPost
(
String
url
,
Map
<
String
,
String
>
params
)
{
...
...
@@ -1186,6 +1192,10 @@ public class WxPayApi {
return
HttpKit
.
getDelegate
().
post
(
url
,
WxPayKit
.
toXml
(
params
),
certPath
,
certPass
);
}
public
static
String
doUploadSSL
(
String
url
,
Map
<
String
,
String
>
params
,
String
certPath
,
String
certPass
,
String
filePath
)
{
return
HttpKit
.
getDelegate
().
upload
(
url
,
WxPayKit
.
toXml
(
params
),
certPath
,
certPass
,
filePath
);
}
public
static
String
doPostSSL
(
String
url
,
Map
<
String
,
String
>
params
,
InputStream
certFile
,
String
certPass
)
{
return
HttpKit
.
getDelegate
().
post
(
url
,
WxPayKit
.
toXml
(
params
),
certFile
,
certPass
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录