Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TangKuPos
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王海
TangKuPos
Commits
8d3b7dfd
Commit
8d3b7dfd
authored
Mar 12, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加二维码支付;
parent
36966005
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
7 deletions
+125
-7
.idea/dictionaries/Eurus.xml
.idea/dictionaries/Eurus.xml
+1
-0
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
+21
-3
pay/src/main/java/com/xingdata/zxpay/api/Response.java
pay/src/main/java/com/xingdata/zxpay/api/Response.java
+13
-0
pay/src/main/java/com/xingdata/zxpay/pax/C.java
pay/src/main/java/com/xingdata/zxpay/pax/C.java
+17
-0
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
+30
-1
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
+14
-0
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
+14
-0
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
+15
-3
No files found.
.idea/dictionaries/Eurus.xml
View file @
8d3b7dfd
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
<w>
strs
</w>
<w>
strs
</w>
<w>
sunquan
</w>
<w>
sunquan
</w>
<w>
transclose
</w>
<w>
transclose
</w>
<w>
unionpay
</w>
<w>
unipay
</w>
<w>
unipay
</w>
<w>
unkonw
</w>
<w>
unkonw
</w>
<w>
unkonwcode
</w>
<w>
unkonwcode
</w>
...
...
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
View file @
8d3b7dfd
...
@@ -29,22 +29,40 @@ public class PayCenter {
...
@@ -29,22 +29,40 @@ public class PayCenter {
}
}
/**
/**
* 支付
*
条码
支付
*
*
* @param payChannel 支付渠道
* @param payChannel 支付渠道
* @param payCode 支付码
* @param payCode 支付码
* @param orderAmt 金额
* @param orderAmt 金额
* @return
直接
结果的Observable
* @return
支付
结果的Observable
*/
*/
public
Observable
<
Response
>
pay
(
int
payChannel
,
String
payCode
,
Long
orderAmt
)
{
public
Observable
<
Response
>
pay
(
int
payChannel
,
String
payCode
,
Long
orderAmt
)
{
switch
(
mShopppp
.
getHost
().
getHostMapId
())
{
switch
(
mShopppp
.
getHost
().
getHostMapId
())
{
case
C
.
HOST
.
PAX
:
case
C
.
HOST
.
PAX
:
return
Factory
.
p
ay
(
payChannel
,
payCode
,
Util
.
fenToYuan
(
orderAmt
));
return
Factory
.
microP
ay
(
payChannel
,
payCode
,
Util
.
fenToYuan
(
orderAmt
));
default
:
default
:
return
Observable
.
just
(
new
Response
(
C
.
PAY_STATE
.
FAIL_CUSTOM
,
"未知渠道"
));
return
Observable
.
just
(
new
Response
(
C
.
PAY_STATE
.
FAIL_CUSTOM
,
"未知渠道"
));
}
}
}
}
/**
* QR支付
*
* @param payChannel 支付渠道
* @param orderAmt 金额
* @return 支付结果的Observable
*/
public
Observable
<
Response
>
pay
(
int
payChannel
,
Long
orderAmt
)
{
switch
(
mShopppp
.
getHost
().
getHostMapId
())
{
case
C
.
HOST
.
PAX
:
return
Factory
.
qrPay
(
payChannel
,
Util
.
fenToYuan
(
orderAmt
));
default
:
return
Observable
.
just
(
new
Response
(
C
.
PAY_STATE
.
FAIL_CUSTOM
,
"未知渠道"
));
}
}
/**
/**
* 查询
* 查询
*
*
...
...
pay/src/main/java/com/xingdata/zxpay/api/Response.java
View file @
8d3b7dfd
...
@@ -5,6 +5,9 @@ package com.xingdata.zxpay.api;
...
@@ -5,6 +5,9 @@ package com.xingdata.zxpay.api;
*/
*/
public
class
Response
{
public
class
Response
{
public
Response
()
{
}
public
Response
(
int
code
,
String
msg
)
{
public
Response
(
int
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
msg
=
msg
;
...
@@ -14,6 +17,8 @@ public class Response {
...
@@ -14,6 +17,8 @@ public class Response {
private
String
msg
;
private
String
msg
;
private
String
body
;
public
int
getCode
()
{
public
int
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -29,4 +34,12 @@ public class Response {
...
@@ -29,4 +34,12 @@ public class Response {
public
void
setMsg
(
String
msg
)
{
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
public
String
getBody
()
{
return
body
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/C.java
View file @
8d3b7dfd
...
@@ -150,4 +150,21 @@ class C {
...
@@ -150,4 +150,21 @@ class C {
*/
*/
static
final
String
MD5
=
"MD5"
;
static
final
String
MD5
=
"MD5"
;
}
}
class
TRADE_TYPE
{
/**
* 微信
*/
static
final
String
WECHAT
=
"pay.weixin.native"
;
/**
* 支付宝
*/
static
final
String
ALI
=
"pay.alipay.native"
;
/**
* 银联
*/
static
final
String
UNION
=
"pay.unionpay.native"
;
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
View file @
8d3b7dfd
...
@@ -24,7 +24,7 @@ public class Factory extends com.xingdata.zxpay.api.Factory {
...
@@ -24,7 +24,7 @@ public class Factory extends com.xingdata.zxpay.api.Factory {
* @param totalAmount 总金额(单位元)
* @param totalAmount 总金额(单位元)
* @return 交易结果
* @return 交易结果
*/
*/
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
p
ay
(
int
payChannel
,
String
authCode
,
String
totalAmount
)
{
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
microP
ay
(
int
payChannel
,
String
authCode
,
String
totalAmount
)
{
Request
request
=
Request
.
create
(
C
.
METHOD
.
MICROPAY
);
Request
request
=
Request
.
create
(
C
.
METHOD
.
MICROPAY
);
request
.
setOutTransactionNo
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
());
request
.
setOutTransactionNo
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
());
request
.
setTimeStart
(
TimeUtils
.
getNowString
(
format
));
request
.
setTimeStart
(
TimeUtils
.
getNowString
(
format
));
...
@@ -47,6 +47,35 @@ public class Factory extends com.xingdata.zxpay.api.Factory {
...
@@ -47,6 +47,35 @@ public class Factory extends com.xingdata.zxpay.api.Factory {
.
doFinally
(()
->
orderMap
.
put
(
request
.
getOutTransactionNo
(),
request
.
getTimeStart
()));
.
doFinally
(()
->
orderMap
.
put
(
request
.
getOutTransactionNo
(),
request
.
getTimeStart
()));
}
}
/**
* 二维码支付
*
* @param payChannel 支付渠道
* @param totalAmount 支付金额
* @return 交易结果
*/
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
qrPay
(
int
payChannel
,
String
totalAmount
)
{
Request
request
=
Request
.
create
(
C
.
METHOD
.
QRPAY
);
request
.
setOutTransactionNo
(
PayCenter
.
getInstance
().
mShopppp
.
getPosppp
().
getHposTrace
());
request
.
setTimeStart
(
TimeUtils
.
getNowString
(
format
));
request
.
setTotalAmount
(
totalAmount
);
switch
(
payChannel
)
{
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
ALI
:
request
.
setTradeType
(
C
.
TRADE_TYPE
.
ALI
);
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
WECHAT
:
request
.
setTradeType
(
C
.
TRADE_TYPE
.
WECHAT
);
break
;
case
com
.
xingdata
.
zxpay
.
C
.
PAY_CHANNEL
.
BANK
:
request
.
setTradeType
(
C
.
TRADE_TYPE
.
UNION
);
break
;
}
request
.
sign
();
return
run
(
Api
.
getInstance
().
service
.
action
(
request
))
.
map
(
new
ResultFilter
())
.
doFinally
(()
->
orderMap
.
put
(
request
.
getOutTransactionNo
(),
request
.
getTimeStart
()));
}
/**
/**
* 查询
* 查询
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
View file @
8d3b7dfd
...
@@ -94,6 +94,12 @@ class Request {
...
@@ -94,6 +94,12 @@ class Request {
@JSONField
(
name
=
"body"
)
@JSONField
(
name
=
"body"
)
private
String
body
;
private
String
body
;
/**
* 支付类型
*/
@JSONField
(
name
=
"trade_type"
)
private
String
tradeType
;
/**
/**
* 支付授权码
* 支付授权码
*/
*/
...
@@ -216,6 +222,14 @@ class Request {
...
@@ -216,6 +222,14 @@ class Request {
this
.
body
=
body
;
this
.
body
=
body
;
}
}
String
getTradeType
()
{
return
tradeType
;
}
void
setTradeType
(
String
tradeType
)
{
this
.
tradeType
=
tradeType
;
}
String
getAuthCode
()
{
String
getAuthCode
()
{
return
authCode
;
return
authCode
;
}
}
...
...
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
View file @
8d3b7dfd
...
@@ -33,6 +33,12 @@ class Response {
...
@@ -33,6 +33,12 @@ class Response {
@JSONField
(
name
=
"msg"
)
@JSONField
(
name
=
"msg"
)
private
String
msg
;
private
String
msg
;
/**
* 二维码地址
*/
@JSONField
(
name
=
"code_url"
)
private
String
codeUrl
;
String
getMethod
()
{
String
getMethod
()
{
return
method
;
return
method
;
}
}
...
@@ -72,4 +78,12 @@ class Response {
...
@@ -72,4 +78,12 @@ class Response {
void
setMsg
(
String
msg
)
{
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
String
getCodeUrl
()
{
return
codeUrl
;
}
void
setCodeUrl
(
String
codeUrl
)
{
this
.
codeUrl
=
codeUrl
;
}
}
}
pay/src/main/java/com/xingdata/zxpay/pax/ResultFilter.java
View file @
8d3b7dfd
...
@@ -7,14 +7,26 @@ class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response
...
@@ -7,14 +7,26 @@ class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response
@Override
@Override
public
com
.
xingdata
.
zxpay
.
api
.
Response
apply
(
Response
response
)
throws
Exception
{
public
com
.
xingdata
.
zxpay
.
api
.
Response
apply
(
Response
response
)
throws
Exception
{
com
.
xingdata
.
zxpay
.
api
.
Response
r
=
new
com
.
xingdata
.
zxpay
.
api
.
Response
();
r
.
setMsg
(
response
.
getMsg
());
switch
(
response
.
getCode
())
{
switch
(
response
.
getCode
())
{
case
C
.
CODE
.
SUCCESS
:
case
C
.
CODE
.
SUCCESS
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
,
response
.
getMsg
());
r
.
setCode
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
SUCCESS
);
break
;
case
C
.
CODE
.
USINGPAY
:
case
C
.
CODE
.
USINGPAY
:
case
C
.
CODE
.
UNKONW
:
case
C
.
CODE
.
UNKONW
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
,
response
.
getMsg
());
r
.
setCode
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
ING
);
break
;
default
:
default
:
return
new
com
.
xingdata
.
zxpay
.
api
.
Response
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
FAIL
,
response
.
getMsg
());
r
.
setCode
(
com
.
xingdata
.
zxpay
.
C
.
PAY_STATE
.
FAIL
);
break
;
}
switch
(
response
.
getMethod
())
{
case
C
.
METHOD
.
QRPAY
:
r
.
setBody
(
response
.
getCodeUrl
());
break
;
}
}
return
r
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment