@@ -8,7 +8,7 @@ Copyright:Ant financial services group
8
8
9
9
https://mvnrepository.com/artifact/com.alipay.global.sdk/global-open-sdk-java
10
10
11
- ```
11
+ ``` xml
12
12
<dependency >
13
13
<groupId >com.alipay.global.sdk</groupId >
14
14
<artifactId >global-open-sdk-java</artifactId >
@@ -17,18 +17,18 @@ https://mvnrepository.com/artifact/com.alipay.global.sdk/global-open-sdk-java
17
17
```
18
18
19
19
#### 2 Main class file
20
- ```
20
+ ``` java
21
21
DefaultAlipayClient . java
22
22
23
23
public DefaultAlipayClient(String gatewayUrl, String merchantPrivateKey, String alipayPublicKey);
24
24
public < T extends AlipayResponse > T execute(AlipayRequest<T > alipayRequest);
25
25
26
26
```
27
27
28
- ```
28
+ ``` java
29
29
SignatureTool . java
30
30
31
- public static String sign(String httpMethod, String path, String clientId, String reqTimeStr, String reqBody, String merchantPrivateKey);
31
+ public static String sign(String httpMethod, String path, String clientId, String reqTimeStr, String reqBody, String merchantPrivateKey);
32
32
public static boolean verify(String httpMethod, String path, String clientId, String rspTimeStr, String rspBody, String signature, String alipayPublicKey);
33
33
34
34
```
@@ -37,7 +37,7 @@ public static boolean verify(String httpMethod, String path, String clientId, St
37
37
38
38
AMS:
39
39
40
- ```
40
+ ``` java
41
41
AlipayClient CLIENT = new DefaultAlipayClient (" https://open-na.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
42
42
43
43
AlipayPayRequest alipayPayRequest = new AlipayPayRequest ();
@@ -97,7 +97,7 @@ AlipayPayResponse alipayPayResponse = CLIENT.execute(alipayPayRequest);
97
97
98
98
APS:
99
99
100
- ```
100
+ ``` java
101
101
AlipayClient CLIENT = new DefaultAlipayClient (" https://open-na.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
102
102
103
103
AlipayApsInquiryPaymentRequest inquiryPaymentRequest = new AlipayApsInquiryPaymentRequest ();
@@ -112,7 +112,7 @@ AlipayApsInquiryPaymentResponse alipayResponse = CLIENT.execute(inquiryPaymentRe
112
112
113
113
RISK:
114
114
115
- ```
115
+ ``` java
116
116
AlipayClient CLIENT = new DefaultAlipayClient (" https://open-sea-global.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
117
117
118
118
RiskDecideRequest riskDecideRequest = new RiskDecideRequest ();
@@ -175,7 +175,7 @@ The execute method contains the HTTP request to the gateway.
175
175
176
176
If you're concerned about HTTP invocation performance, you can implement HTTP invocation yourself.
177
177
178
- ```
178
+ ``` java
179
179
public class YourAlipayClient extends BaseAlipayClient {
180
180
181
181
public YourAlipayClient (String gatewayUrl , String merchantPrivateKey , String alipayPublicKey ){
@@ -237,7 +237,7 @@ boolean isPass = SignatureTool.verify(httpMethod, path, clientId, rspTimeStr,
237
237
238
238
For compatibility with lower version of Java JDK, signatureTool provided a base64 encryptor DefaultBase64Encryptor by default.
239
239
240
- ```
240
+ ``` java
241
241
public class DefaultBase64Encryptor implements Base64Encryptor {
242
242
243
243
@Override
@@ -256,9 +256,9 @@ public class DefaultBase64Encryptor implements Base64Encryptor {
256
256
257
257
For better performance, you can also customize the base64 tool. For example, jdk8 API Base64.
258
258
259
-
260
- ```
261
- public class YourBase64Encryptor implements Base64Encryptor {
259
+ ##### 5.1 add "MyBase64Encryptor"
260
+ ``` java
261
+ public class MyBase64Encryptor implements Base64Encryptor {
262
262
263
263
@Override
264
264
public String encodeToString (byte [] src ) {
@@ -271,7 +271,10 @@ public class YourBase64Encryptor implements Base64Encryptor {
271
271
}
272
272
273
273
}
274
-
275
- Base64Provider.setBase64Encryptor(new YourBase64Encryptor());
276
-
274
+ ```
275
+ ##### 5.2 init before invoke alipayClient
276
+ ``` java
277
+ static {
278
+ Base64Provider . setBase64Encryptor(new MyBase64Encryptor ());
279
+ }
277
280
```
0 commit comments