Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzpay
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzpay
提交
5a3ef6d4
提交
5a3ef6d4
编写于
9月 06, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充阿里网页支付回调业务系统
上级
133bcf31
变更
5
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
293 行增加
和
87 行删除
+293
-87
DevBootSecurityConfig.java
...rc/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
+1
-3
PayCoreService.java
...va/cn/ibizlab/core/extensions/service/PayCoreService.java
+126
-74
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+1
-3
PayCoreResource.java
.../java/cn/ibizlab/api/rest/extensions/PayCoreResource.java
+8
-7
HttpUtils.java
...-util/src/main/java/cn/ibizlab/util/helper/HttpUtils.java
+157
-0
未找到文件。
ibzpay-boot/src/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
浏览文件 @
5a3ef6d4
...
...
@@ -115,9 +115,7 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
//开放支付接口
.
antMatchers
(
"/trade/pagepay"
).
permitAll
()
.
antMatchers
(
"/trade/precreate"
).
permitAll
()
.
antMatchers
(
"/trade/query"
).
permitAll
()
.
antMatchers
(
"/pay/trade/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
.
and
().
headers
().
frameOptions
().
disable
();
...
...
ibzpay-core/src/main/java/cn/ibizlab/core/extensions/service/PayCoreService.java
浏览文件 @
5a3ef6d4
此差异已折叠。
点击以展开。
ibzpay-provider/ibzpay-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
浏览文件 @
5a3ef6d4
...
...
@@ -120,9 +120,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
//开放支付接口
.
antMatchers
(
"/trade/pagepay"
).
permitAll
()
.
antMatchers
(
"/trade/precreate"
).
permitAll
()
.
antMatchers
(
"/trade/query"
).
permitAll
()
.
antMatchers
(
"/pay/trade/**"
).
permitAll
()
// 所有请求都需要认证
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibzpay-provider/ibzpay-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/PayCoreResource.java
浏览文件 @
5a3ef6d4
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
public
class
PayCoreResource
{
...
...
@@ -27,33 +28,33 @@ public class PayCoreResource {
PayTradeMapping
payTradeMapping
;
@ApiOperation
(
value
=
"预下单获取二维码"
,
tags
=
{
"获取二维码"
},
notes
=
"预下单获取二维码"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/precreate"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
pay/
trade/precreate"
)
public
ResponseEntity
<
JSONObject
>
preCreate
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
preCreate
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"查询订单"
,
tags
=
{
"查询订单"
},
notes
=
"查询订单"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/query"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
pay/
trade/query"
)
public
ResponseEntity
<
JSONObject
>
query
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
query
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"取消订单"
,
tags
=
{
"取消订单"
},
notes
=
"取消订单"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/cancel"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
pay/
trade/cancel"
)
public
ResponseEntity
<
JSONObject
>
cancel
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
cancel
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"网页支付"
,
tags
=
{
"网页支付"
},
notes
=
"网页支付"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/pagepay"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
pay/
trade/pagepay"
)
public
ResponseEntity
<
String
>
pagePay
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
pagePay
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"网页支付回调"
,
tags
=
{
"网页支付回调"
},
notes
=
"网页支付回调"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/trade/pagepay
callback"
)
public
ResponseEntity
<
String
>
pagePayCallBack
(
@Validated
@RequestBody
PayTradeDTO
dto
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
pagePayCallBack
(
payTradeMapping
.
toDomain
(
dto
)
));
@RequestMapping
(
value
=
"/pay/trade/pagepay/
callback"
)
public
ResponseEntity
<
String
>
pagePayCallBack
(
HttpServletRequest
req
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
pagePayCallBack
(
req
));
}
}
ibzpay-util/src/main/java/cn/ibizlab/util/helper/HttpUtils.java
0 → 100644
浏览文件 @
5a3ef6d4
package
cn
.
ibizlab
.
util
.
helper
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.nio.charset.Charset
;
/**
* 请求工具类
*/
public
class
HttpUtils
{
private
final
static
String
DEFAULT_ENCODING
=
"UTF-8"
;
/**
* Post请求
*
* @return
*/
public
static
String
post
(
String
url
)
{
return
post
(
url
,
null
,
null
);
}
/**
*Post请求
* @param
* @return
*/
public
static
String
post
(
String
url
,
JSONObject
headerMap
,
JSONObject
paramMap
)
{
return
doRestRequest
(
url
,
HttpMethod
.
POST
,
headerMap
,
paramMap
);
}
/**
*put请求
* @param
* @return
*/
public
static
String
put
(
String
url
,
JSONObject
headerMap
,
JSONObject
paramMap
)
{
return
doRestRequest
(
url
,
HttpMethod
.
PUT
,
headerMap
,
paramMap
);
}
/**
* GET请求
*
* @param
* @return
*/
public
static
String
get
(
String
url
)
throws
UnsupportedEncodingException
{
return
get
(
url
,
null
,
null
);
}
/**
* GET请求
*
* @param
* @param
* @return
*/
public
static
String
get
(
String
url
,
JSONObject
headerMap
,
JSONObject
paramMap
)
throws
UnsupportedEncodingException
{
if
(
paramMap
!=
null
){
boolean
flag
=
true
;
for
(
String
key
:
paramMap
.
keySet
()){
if
(
flag
){
url
+=
"?"
;
}
else
{
url
+=
"&"
;
}
flag
=
false
;
url
=
url
+
key
+
"="
+
URLEncoder
.
encode
(
paramMap
.
getString
(
key
),
DEFAULT_ENCODING
);
}
}
return
doRestRequest
(
url
,
HttpMethod
.
GET
,
headerMap
,
paramMap
);
}
/**
* DELETE请求
*
* @param
* @return
*/
public
static
String
delete
(
String
url
)
{
return
delete
(
url
,
null
,
null
);
}
/**
* DELETE请求
*
* @param
* @param
* @return
*/
public
static
String
delete
(
String
url
,
JSONObject
headerMap
,
JSONObject
paramMap
)
{
return
doRestRequest
(
url
,
HttpMethod
.
DELETE
,
headerMap
,
paramMap
);
}
public
static
String
doRestRequest
(
String
url
,
HttpMethod
method
,
JSONObject
headerMap
,
JSONObject
paramMap
){
RestTemplate
restTemplate
=
getRestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
if
(
headerMap
!=
null
){
for
(
String
key
:
headerMap
.
keySet
()){
headers
.
add
(
key
,
headerMap
.
getString
(
key
));
}
}
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>();
HttpEntity
<
String
>
entity
;
if
(
paramMap
!=
null
){
entity
=
new
HttpEntity
<>(
paramMap
.
toString
(),
headers
);
}
else
{
entity
=
new
HttpEntity
<>(
null
,
headers
);
}
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
method
,
entity
,
String
.
class
);
return
responseEntity
.
getBody
();
}
public
static
InputStream
requestInputStream
(
String
url
,
JSONObject
headerMap
,
JSONObject
paramMap
)
throws
IOException
{
RestTemplate
restTemplate
=
getRestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
if
(
headerMap
!=
null
){
for
(
String
key
:
headerMap
.
keySet
()){
headers
.
add
(
key
,
headerMap
.
getString
(
key
));
}
}
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>();
HttpEntity
<
String
>
entity
;
if
(
paramMap
!=
null
){
entity
=
new
HttpEntity
<>(
paramMap
.
toString
(),
headers
);
}
else
{
entity
=
new
HttpEntity
<>(
null
,
headers
);
}
ResponseEntity
<
Resource
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
entity
,
Resource
.
class
);
return
responseEntity
.
getBody
().
getInputStream
();
}
public
static
RestTemplate
getRestTemplate
(){
RestTemplate
restTemplate
=
new
RestTemplate
();
for
(
HttpMessageConverter
<?>
httpMessageConverter
:
restTemplate
.
getMessageConverters
())
{
if
(
httpMessageConverter
instanceof
StringHttpMessageConverter
)
{
((
StringHttpMessageConverter
)
httpMessageConverter
).
setDefaultCharset
(
Charset
.
forName
(
"UTF-8"
));
break
;
}
}
return
restTemplate
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录