FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pay-java-parent/pay-java-payoneer/test/java/PayTest.java at develop · egzosn/pay-java-parent · GitHub
egzosn
/
pay-java-parent
Public
Notifications
You must be signed in to change notification settings
Fork
954
Star
3.1k
Code
Issues
17
Pull requests
4
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pay-java-parent
/
pay-java-payoneer
/
test
/
java
/
PayTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
99 lines (85 loc) · 4.24 KB
Breadcrumbs
pay-java-parent
/
pay-java-payoneer
/
test
/
java
/
PayTest.java
Copy path
File metadata and controls
99 lines (85 loc) · 4.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import
com
.
alibaba
.
fastjson
.
JSON
;
import
com
.
egzosn
.
pay
.
common
.
bean
.
CurType
;
import
com
.
egzosn
.
pay
.
common
.
util
.
sign
.
encrypt
.
Base64
;
import
org
.
apache
.
http
.
HttpHost
;
import
org
.
apache
.
http
.
auth
.
AuthScope
;
import
org
.
apache
.
http
.
auth
.
UsernamePasswordCredentials
;
import
org
.
apache
.
http
.
client
.
AuthCache
;
import
org
.
apache
.
http
.
client
.
CredentialsProvider
;
import
org
.
apache
.
http
.
client
.
methods
.
CloseableHttpResponse
;
import
org
.
apache
.
http
.
client
.
methods
.
HttpPost
;
import
org
.
apache
.
http
.
client
.
protocol
.
HttpClientContext
;
import
org
.
apache
.
http
.
entity
.
ContentType
;
import
org
.
apache
.
http
.
entity
.
StringEntity
;
import
org
.
apache
.
http
.
impl
.
auth
.
BasicScheme
;
import
org
.
apache
.
http
.
impl
.
client
.
BasicAuthCache
;
import
org
.
apache
.
http
.
impl
.
client
.
BasicCredentialsProvider
;
import
org
.
apache
.
http
.
impl
.
client
.
CloseableHttpClient
;
import
org
.
apache
.
http
.
impl
.
client
.
HttpClients
;
import
org
.
apache
.
http
.
util
.
EntityUtils
;
import
java
.
io
.
IOException
;
import
java
.
net
.
URI
;
import
java
.
util
.
UUID
;
/**
*
*
* payoneer支付测试
* @author Actinia
* email hayesfu@qq.com
* date 2018/1/18 0018 16:49
*/
public
class
PayTest
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
if
(
1
==
1
){
String
auth
=
Base64
.
encode
(
"egan6190:12BkDT8152Zj"
.
getBytes
());
System
.
out
.
println
(
auth
);
return
;
}
// URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/payees/registration-link");
// https://api.sandbox.payoneer.com/v2/programs/100086190/payees/registration-link
URI
uri
=
URI
.
create
(
"https://api.sandbox.payoneer.com/v2/programs/100086190/charges"
);
HttpHost
target
=
new
HttpHost
(
uri
.
getHost
(),
uri
.
getPort
(),
uri
.
getScheme
());
HttpPost
httpPost
=
new
HttpPost
(
uri
.
toString
());
CredentialsProvider
credsProvider
=
new
BasicCredentialsProvider
();
credsProvider
.
setCredentials
(
new
AuthScope
(
uri
.
getHost
(),
uri
.
getPort
()),
new
UsernamePasswordCredentials
(
"egan6190"
,
"12BkDT8152Zj"
));
CloseableHttpClient
httpclient
=
HttpClients
.
custom
()
.
setDefaultCredentialsProvider
(
credsProvider
)
.
build
();
try
{
// Create AuthCache instance
AuthCache
authCache
=
new
BasicAuthCache
();
// Generate BASIC scheme object and add it to the local
// auth cache
BasicScheme
basicAuth
=
new
BasicScheme
();
authCache
.
put
(
target
,
basicAuth
);
// Add AuthCache to the execution context
HttpClientContext
localContext
=
HttpClientContext
.
create
();
// localContext.setCredentialsProvider(credsProvider);
localContext
.
setAuthCache
(
authCache
);
// BasicHttpContext localContext = new BasicHttpContext();
// localContext.setAttribute(ClientContext.AUTH_CACHE,authCache);
// PayoneerRequestBean bean = new PayoneerRequestBean("666");
String
referenceId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
PayoneerRequestBean
bean
=
new
PayoneerRequestBean
(
"8a2950f959043699015904453b330057"
,
"1.01"
,
referenceId
,
CurType
.
USD
,
"egan order"
);
// PayoneerRequestBean bean = JSON.parseObject("{\"amount\":\"1.00\",\"client_reference_id\":\""+ System.nanoTime()+"\",\"currency\":\"USD\",\"description\":\"aaabb\",\"payee_id\":\"asdfg13\"}", PayoneerRequestBean.class);
System
.
out
.
println
(
JSON
.
toJSONString
(
bean
));
StringEntity
entity
=
new
StringEntity
(
JSON
.
toJSONString
(
bean
),
ContentType
.
APPLICATION_JSON
);
httpPost
.
setEntity
(
entity
);
System
.
out
.
println
(
"Executing request "
+
httpPost
.
getRequestLine
() +
" to target "
+
target
);
for
(
int
i
=
0
;
i
<
1
;
i
++) {
CloseableHttpResponse
response
=
httpclient
.
execute
(
target
,
httpPost
,
localContext
);
try
{
System
.
out
.
println
(
"----------------------------------------"
);
System
.
out
.
println
(
response
.
getStatusLine
());
System
.
out
.
println
(
EntityUtils
.
toString
(
response
.
getEntity
()));
}
finally
{
response
.
close
();
}
}
}
finally
{
httpclient
.
close
();
}
}
}
Back
|
FazBrowse Home
|
New Git URL