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
a12fc602
Commit
a12fc602
authored
Mar 08, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付;
parent
a69eed84
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
833 additions
and
32 deletions
+833
-32
.idea/dictionaries/Eurus.xml
.idea/dictionaries/Eurus.xml
+13
-0
.idea/inspectionProfiles/Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+15
-0
app/build.gradle
app/build.gradle
+1
-0
app/src/main/java/com/xingdata/zzdpos/C.java
app/src/main/java/com/xingdata/zzdpos/C.java
+17
-3
app/src/main/java/com/xingdata/zzdpos/api/ApiFactory.java
app/src/main/java/com/xingdata/zzdpos/api/ApiFactory.java
+9
-17
app/src/main/java/com/xingdata/zzdpos/api/ApiService.java
app/src/main/java/com/xingdata/zzdpos/api/ApiService.java
+3
-0
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
...n/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
+12
-1
app/src/main/java/com/xingdata/zzdpos/ui/vip/VipPresenter.java
...rc/main/java/com/xingdata/zzdpos/ui/vip/VipPresenter.java
+1
-1
pay/build.gradle
pay/build.gradle
+18
-7
pay/src/main/java/C.java
pay/src/main/java/C.java
+0
-3
pay/src/main/java/com/xingdata/zxpay/C.java
pay/src/main/java/com/xingdata/zxpay/C.java
+75
-0
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
+42
-0
pay/src/main/java/com/xingdata/zxpay/api/Api.java
pay/src/main/java/com/xingdata/zxpay/api/Api.java
+68
-0
pay/src/main/java/com/xingdata/zxpay/api/ConverterFactory.java
...rc/main/java/com/xingdata/zxpay/api/ConverterFactory.java
+64
-0
pay/src/main/java/com/xingdata/zxpay/api/Response.java
pay/src/main/java/com/xingdata/zxpay/api/Response.java
+20
-0
pay/src/main/java/com/xingdata/zxpay/base/BaseRequest.java
pay/src/main/java/com/xingdata/zxpay/base/BaseRequest.java
+5
-0
pay/src/main/java/com/xingdata/zxpay/base/BaseResponse.java
pay/src/main/java/com/xingdata/zxpay/base/BaseResponse.java
+4
-0
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
+20
-0
pay/src/main/java/com/xingdata/zxpay/pax/C.java
pay/src/main/java/com/xingdata/zxpay/pax/C.java
+66
-0
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
+34
-0
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
+260
-0
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
+75
-0
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
+11
-0
No files found.
.idea/dictionaries/Eurus.xml
View file @
a12fc602
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<words>
<words>
<w>
addr
</w>
<w>
addr
</w>
<w>
alipay
</w>
<w>
alipay
</w>
<w>
amountexceed
</w>
<w>
appid
</w>
<w>
appid
</w>
<w>
baozheng
</w>
<w>
baozheng
</w>
<w>
caocao
</w>
<w>
caocao
</w>
...
@@ -14,6 +15,9 @@
...
@@ -14,6 +15,9 @@
<w>
huanggai
</w>
<w>
huanggai
</w>
<w>
huangxin
</w>
<w>
huangxin
</w>
<w>
inputer
</w>
<w>
inputer
</w>
<w>
instrans
</w>
<w>
invalidmerno
</w>
<w>
invalidstore
</w>
<w>
jsonpay
</w>
<w>
jsonpay
</w>
<w>
kongming
</w>
<w>
kongming
</w>
<w>
kongrong
</w>
<w>
kongrong
</w>
...
@@ -22,15 +26,24 @@
...
@@ -22,15 +26,24 @@
<w>
liubei
</w>
<w>
liubei
</w>
<w>
lvzhi
</w>
<w>
lvzhi
</w>
<w>
mawu
</w>
<w>
mawu
</w>
<w>
mernoblocked
</w>
<w>
nong
</w>
<w>
nong
</w>
<w>
noti
</w>
<w>
parametererror
</w>
<w>
patt
</w>
<w>
patt
</w>
<w>
posppp
</w>
<w>
posppp
</w>
<w>
shixiu
</w>
<w>
shixiu
</w>
<w>
shopppp
</w>
<w>
signerror
</w>
<w>
skugrps
</w>
<w>
skugrps
</w>
<w>
skus
</w>
<w>
skus
</w>
<w>
strs
</w>
<w>
strs
</w>
<w>
sunquan
</w>
<w>
sunquan
</w>
<w>
transclose
</w>
<w>
unipay
</w>
<w>
unipay
</w>
<w>
unkonw
</w>
<w>
unkonwcode
</w>
<w>
usingpay
</w>
<w>
xishi
</w>
<w>
xishi
</w>
<w>
yanqing
</w>
<w>
yanqing
</w>
<w>
yuefei
</w>
<w>
yuefei
</w>
...
...
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
View file @
a12fc602
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"ClassWithMultipleLoggers"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"loggerNamesString"
value=
"java.util.logging.Logger,org.slf4j.Logger,org.apache.commons.logging.Log,org.apache.log4j.Logger"
/>
</inspection_tool>
<inspection_tool
class=
"LogStatementGuardedByLogCondition"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"LoggingConditionDisagreesWithLogStatement"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"NonStaticFinalLogger"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"loggerClassName"
value=
""
/>
</inspection_tool>
<inspection_tool
class=
"PlaceholderCountMatchesArgumentCount"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
<inspection_tool
class=
"StringConcatenationArgumentToLogCall"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
</profile>
</component>
\ No newline at end of file
app/build.gradle
View file @
a12fc602
...
@@ -86,4 +86,5 @@ dependencies {
...
@@ -86,4 +86,5 @@ dependencies {
implementation
'me.dm7.barcodescanner:zxing:1.9.8'
implementation
'me.dm7.barcodescanner:zxing:1.9.8'
implementation
'com.google.zxing:core:3.3.1'
implementation
'com.google.zxing:core:3.3.1'
implementation
(
name:
'zx_print_library-debug'
,
ext:
'aar'
)
implementation
(
name:
'zx_print_library-debug'
,
ext:
'aar'
)
implementation
project
(
':pay'
)
}
}
app/src/main/java/com/xingdata/zzdpos/C.java
View file @
a12fc602
...
@@ -62,19 +62,26 @@ public class C {
...
@@ -62,19 +62,26 @@ public class C {
* 支付服务器
* 支付服务器
*/
*/
public
static
final
String
TEMP_PAY_URL
=
"http://demo.51zzd.cn/"
;
public
static
final
String
TEMP_PAY_URL
=
"http://demo.51zzd.cn/"
;
/**
/**
* 测试环境(客户演示使用)sn:test01,设备号:AECRC10
* 测试环境(客户演示使用)sn:test01,设备号:AECRC10
*/
*/
// public static final String BASE_URL = "http://121.40.56.52:8080/";
public
static
final
String
URL_TEST
=
"http://121.40.56.52:8080/"
;
/**
/**
* 开发平台(开发人员使用)
* 开发平台(开发人员使用)
*/
*/
// public static final String BASE_URL = "http://demo.51zzd.cn:8080/";//开发测试平台
static
final
String
URL_DEMO
=
"http://demo.51zzd.cn:8080/"
;
/**
/**
* 生产平台
* 生产平台
*/
*/
public
static
final
String
BASE_URL
=
"http://tk.51zzd.com/"
;
public
static
final
String
URL_ONLINE
=
"http://tk.51zzd.com/"
;
/**
* 地址
*/
public
static
final
String
BASE_URL
=
URL_DEMO
;
private
static
final
String
PKG
=
"/tk/"
;
private
static
final
String
PKG
=
"/tk/"
;
...
@@ -437,6 +444,13 @@ public class C {
...
@@ -437,6 +444,13 @@ public class C {
public
final
class
TEMP_PAY
{
public
final
class
TEMP_PAY
{
public
static
final
String
pay
=
"pay/payc/pay"
;
public
static
final
String
pay
=
"pay/payc/pay"
;
}
}
public
final
class
SHOPPPP
{
private
static
final
String
ROOT_URL
=
PKG
+
"shopppp/"
;
public
static
final
String
getPayKey
=
ROOT_URL
+
"getPayKey"
;
}
}
}
...
...
app/src/main/java/com/xingdata/zzdpos/api/ApiFactory.java
View file @
a12fc602
...
@@ -454,14 +454,12 @@ public final class ApiFactory {
...
@@ -454,14 +454,12 @@ public final class ApiFactory {
}
}
public
static
class
Pay
{
public
static
class
Pay
{
public
static
Observable
<
List
<
com
.
xingdata
.
zzdpos
.
model
.
Pay
>>
query
()
{
public
static
Observable
<
Pager
<
com
.
xingdata
.
zzdpos
.
model
.
Pay
>>
query
()
{
return
Api
.
getInstance
().
service
.
queryPay
()
return
run
(
Api
.
getInstance
().
service
.
queryPay
());
.
onErrorReturn
(
new
ErrorFilter
<>())
}
.
map
(
new
ResultFilter
<>())
.
flatMap
(
payPager
->
Observable
.
just
(
payPager
.
getList
()))
public
static
Observable
<
String
>
getPayKey
()
{
.
subscribeOn
(
Schedulers
.
io
())
return
run
(
Api
.
getInstance
().
service
.
getPayKey
());
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
retryWhen
(
new
RetryHelper
(
3
));
}
}
}
}
...
@@ -492,14 +490,8 @@ public final class ApiFactory {
...
@@ -492,14 +490,8 @@ public final class ApiFactory {
}
}
public
static
class
Ticket
{
public
static
class
Ticket
{
public
static
Observable
<
List
<
com
.
xingdata
.
zzdpos
.
model
.
Ticket
>>
query
(
Long
vipId
)
{
public
static
Observable
<
Pager
<
com
.
xingdata
.
zzdpos
.
model
.
Ticket
>>
query
(
Long
vipId
)
{
return
Api
.
getInstance
().
service
.
queryTicket
(
vipId
)
return
run
(
Api
.
getInstance
().
service
.
queryTicket
(
vipId
));
.
onErrorReturn
(
new
ErrorFilter
<>())
.
map
(
new
ResultFilter
<>())
.
flatMap
(
ticketPager
->
Observable
.
just
(
ticketPager
.
getList
()))
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
retryWhen
(
new
RetryHelper
(
3
));
}
}
...
@@ -907,7 +899,7 @@ public final class ApiFactory {
...
@@ -907,7 +899,7 @@ public final class ApiFactory {
}
}
public
static
<
T
>
Observable
<
T
>
run
(
Observable
<
HttpMessage
<
T
>>
observable
)
{
static
<
T
>
Observable
<
T
>
run
(
Observable
<
HttpMessage
<
T
>>
observable
)
{
return
observable
.
onErrorReturn
(
new
ErrorFilter
<>())
return
observable
.
onErrorReturn
(
new
ErrorFilter
<>())
.
map
(
new
ResultFilter
<>())
.
map
(
new
ResultFilter
<>())
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
...
...
app/src/main/java/com/xingdata/zzdpos/api/ApiService.java
View file @
a12fc602
...
@@ -475,4 +475,7 @@ interface ApiService {
...
@@ -475,4 +475,7 @@ interface ApiService {
@Query
(
"pageSize"
)
int
pageSize
);
@Query
(
"pageSize"
)
int
pageSize
);
@POST
(
C
.
URL
.
SHOPPPP
.
getPayKey
)
Observable
<
HttpMessage
<
String
>>
getPayKey
();
}
}
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettlePresenter.java
View file @
a12fc602
...
@@ -2,9 +2,11 @@ package com.xingdata.zzdpos.ui.settle;
...
@@ -2,9 +2,11 @@ package com.xingdata.zzdpos.ui.settle;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.StringUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.api.print.ZX_PrintPOS
;
import
com.xingdata.zxpay.PayCenter
;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.api.ApiFactory
;
import
com.xingdata.zzdpos.api.ApiFactory
;
import
com.xingdata.zzdpos.api.JniFactory
;
import
com.xingdata.zzdpos.api.JniFactory
;
...
@@ -90,6 +92,15 @@ public class SettlePresenter extends SettleContract.Presenter {
...
@@ -90,6 +92,15 @@ public class SettlePresenter extends SettleContract.Presenter {
//这一版不作处理
//这一版不作处理
}
}
};
};
// ApiFactory.Pay.getPayKey().subscribe(LogUtils::d, throwable -> LogUtils.e(throwable.getMessage()));
PayCenter
.
getInstance
().
init
();
PayCenter
.
getInstance
().
pay
().
subscribe
(
response
->
{
LogUtils
.
e
(
response
.
getMsg
());
},
throwable
->
{
LogUtils
.
e
(
throwable
.
getMessage
());
});
}
}
/**
/**
...
@@ -174,7 +185,7 @@ public class SettlePresenter extends SettleContract.Presenter {
...
@@ -174,7 +185,7 @@ public class SettlePresenter extends SettleContract.Presenter {
// 获取订单
// 获取订单
ApiFactory
.
Ticket
.
query
(
mVip
.
getVipId
()).
subscribe
(
ApiFactory
.
Ticket
.
query
(
mVip
.
getVipId
()).
subscribe
(
tickets
->
{
tickets
->
{
this
.
mTickets
=
tickets
;
this
.
mTickets
=
tickets
.
getList
()
;
this
.
searchAvlTicket
();
this
.
searchAvlTicket
();
},
},
throwable
->
mView
.
showMsg
(
throwable
.
getMessage
()));
throwable
->
mView
.
showMsg
(
throwable
.
getMessage
()));
...
...
app/src/main/java/com/xingdata/zzdpos/ui/vip/VipPresenter.java
View file @
a12fc602
...
@@ -104,7 +104,7 @@ public class VipPresenter extends VipContract.Presenter {
...
@@ -104,7 +104,7 @@ public class VipPresenter extends VipContract.Presenter {
@Override
@Override
public
void
ticketQuery
(
Long
vipID
)
{
public
void
ticketQuery
(
Long
vipID
)
{
ApiFactory
.
Ticket
.
query
(
vipID
).
subscribe
(
ticketList
->
{
ApiFactory
.
Ticket
.
query
(
vipID
).
subscribe
(
ticketList
->
{
mView
.
ticketQuerySus
(
ticketList
);
mView
.
ticketQuerySus
(
ticketList
.
getList
()
);
},
throwable
->
{
},
throwable
->
{
ToastUtils
.
showShort
(
throwable
.
getMessage
());
ToastUtils
.
showShort
(
throwable
.
getMessage
());
});
});
...
...
pay/build.gradle
View file @
a12fc602
apply
plugin:
'com.android.library'
apply
plugin:
'com.android.library'
android
{
android
{
compileSdkVersion
26
compileSdkVersion
27
defaultConfig
{
defaultConfig
{
minSdkVersion
2
5
minSdkVersion
2
1
targetSdkVersion
2
6
targetSdkVersion
2
7
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
compileOptions
{
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
}
}
buildTypes
{
buildTypes
{
...
@@ -27,8 +28,18 @@ android {
...
@@ -27,8 +28,18 @@ android {
dependencies
{
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.android.support:appcompat-v7:2
6.1.0
'
implementation
'com.android.support:appcompat-v7:2
7.0.2
'
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'com.android.support.test:runner:1.0.1'
androidTestImplementation
'com.android.support.test:runner:1.0.1'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.1'
implementation
'com.alibaba:fastjson:1.1.67.android'
implementation
'com.blankj:utilcode:1.11.1'
implementation
'io.reactivex.rxjava2:rxjava:2.1.5'
implementation
'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation
'com.squareup.retrofit2:retrofit:2.3.0'
implementation
'com.squareup.retrofit2:converter-gson:2.3.0'
implementation
'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation
'com.squareup.okhttp3:okhttp:3.9.0'
implementation
'com.squareup.okhttp3:logging-interceptor:3.9.0'
}
}
pay/src/main/java/C.java
deleted
100644 → 0
View file @
a69eed84
public
class
C
{
}
pay/src/main/java/com/xingdata/zxpay/C.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
;
public
class
C
{
/**
* 交易状态
*/
public
final
static
class
PAY_STATE
{
/**
* 支付中 (默认状态)
*/
public
final
static
int
ING
=
0
;
/**
* 支付成功
*/
public
final
static
int
SUCCESS
=
1
;
/**
* 支付失败
*/
public
final
static
int
FAIL
=
2
;
/**
* 自定义的错误信息的标识
*/
public
final
static
int
FAIL_CUSTOM
=
-
999
;
}
/**
* 操作类型
*/
public
final
static
class
ACTION_TYPE
{
/**
* 条码支付
*/
public
final
static
int
PAY_BARCODE
=
101
;
/**
* 二维码支付
*/
public
final
static
int
PAY_QR
=
102
;
/**
* 公众号支付
*/
public
final
static
int
PAY_WOA
=
103
;
/**
* 退货
*/
public
final
static
int
REFUND
=
200
;
/**
* 撤销
*/
public
final
static
int
VOID
=
300
;
/**
* 查询
*/
public
final
static
int
QUERY
=
400
;
}
/**
* 渠道
*/
public
static
final
class
CHANNEL
{
/**
* 惠尔丰平台的渠道编号
*/
public
final
static
int
PAY_CHANNEL_PAX
=
9
;
}
/**
* 交互HEAD信息
*/
public
final
class
HEAD
{
public
static
final
String
CONTENT_TYPE
=
"application/json"
;
}
}
pay/src/main/java/com/xingdata/zxpay/PayCenter.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
;
import
com.xingdata.zxpay.api.Response
;
import
com.xingdata.zxpay.model.Shopppp
;
import
com.xingdata.zxpay.pax.Factory
;
import
io.reactivex.Observable
;
public
class
PayCenter
{
private
static
class
PayCenterHolder
{
private
static
final
PayCenter
INSTANCE
=
new
PayCenter
();
}
public
static
PayCenter
getInstance
()
{
return
PayCenter
.
PayCenterHolder
.
INSTANCE
;
}
/**
* 交易基本信息
*/
public
Shopppp
mShopppp
;
public
void
init
()
{
mShopppp
=
new
Shopppp
();
mShopppp
.
setHshopKeyUnipay
(
"http://114.55.31.38:8008"
);
}
public
Observable
<
Response
>
pay
()
{
//TODO 判断当前渠道
//TODO 返回执行结果
return
Factory
.
pay
(
"111"
,
"333"
);
}
public
Observable
query
()
{
return
Observable
.
just
(
""
);
}
}
pay/src/main/java/com/xingdata/zxpay/api/Api.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
api
;
import
android.support.annotation.NonNull
;
import
com.xingdata.zxpay.C
;
import
com.xingdata.zxpay.PayCenter
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
okhttp3.Cookie
;
import
okhttp3.CookieJar
;
import
okhttp3.HttpUrl
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
retrofit2.Retrofit
;
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
;
public
class
Api
{
protected
Retrofit
retrofit
;
protected
Api
()
{
//LOG
HttpLoggingInterceptor
logInterceptor
=
new
HttpLoggingInterceptor
();
logInterceptor
.
setLevel
(
HttpLoggingInterceptor
.
Level
.
BODY
);
//HEAD
Interceptor
headInterceptor
=
(
chain
)
->
chain
.
proceed
(
chain
.
request
().
newBuilder
()
.
addHeader
(
"Content-Type"
,
C
.
HEAD
.
CONTENT_TYPE
)
.
build
());
//COOKIE
CookieJar
cookieJar
=
new
CookieJar
()
{
private
HashMap
<
String
,
Cookie
>
cookieMap
=
new
HashMap
<>();
@Override
public
void
saveFromResponse
(
@NonNull
HttpUrl
url
,
@NonNull
List
<
Cookie
>
cookies
)
{
for
(
int
i
=
0
;
i
<
cookies
.
size
();
i
++)
{
cookieMap
.
put
(
cookies
.
get
(
i
).
name
(),
cookies
.
get
(
i
));
}
}
@Override
public
List
<
Cookie
>
loadForRequest
(
@NonNull
HttpUrl
url
)
{
return
new
ArrayList
<>(
cookieMap
.
values
());
}
};
//Client
OkHttpClient
okHttpClient
=
new
OkHttpClient
.
Builder
()
.
addInterceptor
(
headInterceptor
)
.
addInterceptor
(
logInterceptor
)
.
cookieJar
(
cookieJar
)
.
build
();
retrofit
=
new
Retrofit
.
Builder
()
.
client
(
okHttpClient
)
.
addCallAdapterFactory
(
RxJava2CallAdapterFactory
.
create
())
.
addConverterFactory
(
ConverterFactory
.
create
())
.
baseUrl
(
PayCenter
.
getInstance
().
mShopppp
.
getHshopKeyUnipay
())
.
build
();
}
}
pay/src/main/java/com/xingdata/zxpay/api/ConverterFactory.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
api
;
import
android.support.annotation.NonNull
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
java.io.IOException
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Type
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
okhttp3.ResponseBody
;
import
okio.BufferedSource
;
import
okio.Okio
;
import
retrofit2.Converter
;
import
retrofit2.Retrofit
;
public
class
ConverterFactory
extends
Converter
.
Factory
{
public
static
ConverterFactory
create
()
{
return
new
ConverterFactory
();
}
@Override
public
Converter
<
ResponseBody
,
?>
responseBodyConverter
(
Type
type
,
Annotation
[]
annotations
,
Retrofit
retrofit
)
{
return
new
FastJsonResponseBodyConverter
<>(
type
);
}
@Override
public
Converter
<?,
RequestBody
>
requestBodyConverter
(
Type
type
,
Annotation
[]
parameterAnnotations
,
Annotation
[]
methodAnnotations
,
Retrofit
retrofit
)
{
return
new
FastJsonRequestBodyConverter
<>();
}
class
FastJsonRequestBodyConverter
<
T
>
implements
Converter
<
T
,
RequestBody
>
{
private
final
MediaType
MEDIA_TYPE
=
MediaType
.
parse
(
"application/json; charset=UTF-8"
);
@Override
public
RequestBody
convert
(
@NonNull
T
value
)
throws
IOException
{
return
RequestBody
.
create
(
MEDIA_TYPE
,
JSON
.
toJSONBytes
(
value
,
SerializerFeature
.
WriteMapNullValue
));
}
}
class
FastJsonResponseBodyConverter
<
T
>
implements
Converter
<
ResponseBody
,
T
>
{
private
final
Type
type
;
FastJsonResponseBodyConverter
(
Type
type
)
{
this
.
type
=
type
;
}
@Override
public
T
convert
(
@NonNull
ResponseBody
value
)
throws
IOException
{
BufferedSource
bufferedSource
=
Okio
.
buffer
(
value
.
source
());
String
tempStr
=
bufferedSource
.
readUtf8
();
bufferedSource
.
close
();
return
JSON
.
parseObject
(
tempStr
,
type
);
}
}
}
\ No newline at end of file
pay/src/main/java/com/xingdata/zxpay/api/Response.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
api
;
/**
* 和App主体交互的回应包
*/
public
class
Response
{
public
Response
(
String
msg
)
{
this
.
msg
=
msg
;
}
private
String
msg
;
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
pay/src/main/java/com/xingdata/zxpay/base/BaseRequest.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
base
;
public
interface
BaseRequest
{
}
pay/src/main/java/com/xingdata/zxpay/base/BaseResponse.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
base
;
public
interface
BaseResponse
{
}
pay/src/main/java/com/xingdata/zxpay/pax/Api.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
public
class
Api
extends
com
.
xingdata
.
zxpay
.
api
.
Api
{
Service
service
;
private
static
class
ApiHolder
{
private
static
final
Api
INSTANCE
=
new
Api
();
}
public
static
Api
getInstance
()
{
return
ApiHolder
.
INSTANCE
;
}
Api
()
{
super
();
service
=
retrofit
.
create
(
Service
.
class
);
}
}
pay/src/main/java/com/xingdata/zxpay/pax/C.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
class
C
{
final
static
String
URL
=
"/tps/api/instrans"
;
/**
* 当前交易成功
*/
static
final
String
SUCCESS
=
"SUCCESS"
;
/**
* 交易处理中(需调查询接口获取交易状态)
*/
static
final
String
USINGPAY
=
"USINGPAY"
;
/**
* 未知状态(需调查询接口获取交易状态)
*/
static
final
String
UNKONW
=
"UNKONW"
;
/**
* 签名错误
*/
static
final
String
SIGNERROR
=
"SIGNERROR"
;
/**
* 不能识别渠道的条码
*/
static
final
String
UNKONWCODE
=
"UNKONWCODE"
;
/**
* 金额超限
*/
static
final
String
AMOUNTEXCEED
=
"AMOUNTEXCEED"
;
/**
* 交易已关闭(当支付交易被取消以后,原支付交易处于交易关闭状态)
*/
static
final
String
TRANSCLOSE
=
"TRANSCLOSE"
;
/**
* 商户号被冻结
*/
static
final
String
MERNOBLOCKED
=
"MERNOBLOCKED"
;
/**
* 无效终端号
*/
static
final
String
INVALIDSTORE
=
"INVALIDSTORE"
;
/**
* 无效商户号
*/
static
final
String
INVALIDMERNO
=
"INVALIDMERNO"
;
/**
* 参数错误或参数不完整
*/
static
final
String
PARAMETERERROR
=
"PARAMETERERROR"
;
/**
* 交易失败
*/
static
final
String
FAIL
=
"FAIL"
;
}
pay/src/main/java/com/xingdata/zxpay/pax/Factory.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
import
com.alibaba.fastjson.JSON
;
import
com.xingdata.zxpay.api.Response
;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.schedulers.Schedulers
;
public
class
Factory
{
public
static
Observable
<
com
.
xingdata
.
zxpay
.
api
.
Response
>
pay
(
String
a
,
String
b
)
{
Request
request
=
new
Request
();
request
.
setReserved
(
a
);
request
.
setMethod
(
b
);
return
run
(
Api
.
getInstance
().
service
.
query
(
request
))
.
flatMap
(
response
->
Observable
.
just
(
new
Response
(
JSON
.
toJSONString
(
response
))));
}
public
static
Observable
query
(
String
c
,
String
d
)
{
Request
request
=
new
Request
();
request
.
setAgentId
(
c
);
request
.
setExpTime
(
d
);
return
Api
.
getInstance
().
service
.
query
(
request
);
}
static
<
T
>
Observable
<
T
>
run
(
Observable
<
T
>
observable
)
{
return
observable
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
());
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Request.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
import
android.support.annotation.Nullable
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
Request
{
/**
* 版本
*/
@JSONField
(
name
=
"version"
)
@Nullable
private
String
version
;
/**
* 交易码
*/
@JSONField
(
name
=
"method"
)
private
String
method
;
/**
* 机构号
*/
@JSONField
(
name
=
"agent_id"
)
private
String
agentId
;
/**
* 商户号
*/
@JSONField
(
name
=
"mch_id"
)
private
String
mchId
;
/**
* 终端号
*/
@JSONField
(
name
=
"ter_id"
)
private
String
terId
;
/**
* 流水号
*/
@JSONField
(
name
=
"out_transaction_no"
)
private
int
outTransactionNo
;
/**
* 订单生产时间
*/
@JSONField
(
name
=
"time_start"
)
private
String
timeStart
;
/**
* 订单标题
*/
@JSONField
(
name
=
"subject"
)
@Nullable
private
String
subject
;
/**
* 商品描述
*/
@JSONField
(
name
=
"body"
)
@Nullable
private
String
body
;
/**
* 支付授权码
*/
@JSONField
(
name
=
"auth_code"
)
private
String
authCode
;
/**
* 货币种类
*/
@JSONField
(
name
=
"currency"
)
@Nullable
private
String
currency
;
/**
* 订单金额
*/
@JSONField
(
name
=
"auth_code"
)
private
String
totalAmount
;
/**
* 小费金额
*/
@JSONField
(
name
=
"fee_amount"
)
@Nullable
private
String
feeAmount
;
/**
* 商户保留域
*/
@JSONField
(
name
=
"reserved"
)
@Nullable
private
String
reserved
;
/**
* 超时等待时间(秒)
*/
@JSONField
(
name
=
"exp_time"
)
@Nullable
private
String
expTime
;
/**
* 签名类型
*/
@JSONField
(
name
=
"sign_type"
)
private
String
signType
;
/**
* 签名
*/
@JSONField
(
name
=
"sign"
)
private
String
sign
;
@Nullable
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
@Nullable
String
version
)
{
this
.
version
=
version
;
}
public
String
getMethod
()
{
return
method
;
}
public
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
}
public
String
getAgentId
()
{
return
agentId
;
}
public
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
}
public
String
getMchId
()
{
return
mchId
;
}
public
void
setMchId
(
String
mchId
)
{
this
.
mchId
=
mchId
;
}
public
String
getTerId
()
{
return
terId
;
}
public
void
setTerId
(
String
terId
)
{
this
.
terId
=
terId
;
}
public
int
getOutTransactionNo
()
{
return
outTransactionNo
;
}
public
void
setOutTransactionNo
(
int
outTransactionNo
)
{
this
.
outTransactionNo
=
outTransactionNo
;
}
public
String
getTimeStart
()
{
return
timeStart
;
}
public
void
setTimeStart
(
String
timeStart
)
{
this
.
timeStart
=
timeStart
;
}
@Nullable
public
String
getSubject
()
{
return
subject
;
}
public
void
setSubject
(
@Nullable
String
subject
)
{
this
.
subject
=
subject
;
}
@Nullable
public
String
getBody
()
{
return
body
;
}
public
void
setBody
(
@Nullable
String
body
)
{
this
.
body
=
body
;
}
public
String
getAuthCode
()
{
return
authCode
;
}
public
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
}
@Nullable
public
String
getCurrency
()
{
return
currency
;
}
public
void
setCurrency
(
@Nullable
String
currency
)
{
this
.
currency
=
currency
;
}
public
String
getTotalAmount
()
{
return
totalAmount
;
}
public
void
setTotalAmount
(
String
totalAmount
)
{
this
.
totalAmount
=
totalAmount
;
}
@Nullable
public
String
getFeeAmount
()
{
return
feeAmount
;
}
public
void
setFeeAmount
(
@Nullable
String
feeAmount
)
{
this
.
feeAmount
=
feeAmount
;
}
@Nullable
public
String
getReserved
()
{
return
reserved
;
}
public
void
setReserved
(
@Nullable
String
reserved
)
{
this
.
reserved
=
reserved
;
}
@Nullable
public
String
getExpTime
()
{
return
expTime
;
}
public
void
setExpTime
(
@Nullable
String
expTime
)
{
this
.
expTime
=
expTime
;
}
public
String
getSignType
()
{
return
signType
;
}
public
void
setSignType
(
String
signType
)
{
this
.
signType
=
signType
;
}
public
String
getSign
()
{
return
sign
;
}
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Response.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
Response
{
/**
* 交易码
*/
@JSONField
(
name
=
"method"
)
private
String
method
;
/**
* 机构号
*/
@JSONField
(
name
=
"agent_id"
)
private
String
agentId
;
/**
* 商户号
*/
@JSONField
(
name
=
"mch_id"
)
private
String
mchId
;
/**
* 应答码
*/
@JSONField
(
name
=
"code"
)
private
String
code
;
/**
* 应答描述
*/
@JSONField
(
name
=
"msg"
)
private
String
msg
;
public
String
getMethod
()
{
return
method
;
}
public
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
}
public
String
getAgentId
()
{
return
agentId
;
}
public
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
}
public
String
getMchId
()
{
return
mchId
;
}
public
void
setMchId
(
String
mchId
)
{
this
.
mchId
=
mchId
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
pay/src/main/java/com/xingdata/zxpay/pax/Service.java
0 → 100644
View file @
a12fc602
package
com
.
xingdata
.
zxpay
.
pax
;
import
io.reactivex.Observable
;
import
retrofit2.http.Body
;
import
retrofit2.http.POST
;
public
interface
Service
{
@POST
(
C
.
URL
)
Observable
<
Response
>
query
(
@Body
com
.
xingdata
.
zxpay
.
pax
.
Request
request
);
}
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