@@ -8,7 +8,7 @@ Copyright:Ant financial services group
88
99https://mvnrepository.com/artifact/com.alipay.global.sdk/global-open-sdk-java
1010
11- ```
11+ ``` xml
1212<dependency >
1313 <groupId >com.alipay.global.sdk</groupId >
1414 <artifactId >global-open-sdk-java</artifactId >
@@ -17,18 +17,18 @@ https://mvnrepository.com/artifact/com.alipay.global.sdk/global-open-sdk-java
1717```
1818
1919#### 2 Main class file
20- ```
20+ ``` java
2121DefaultAlipayClient . java
2222
2323public DefaultAlipayClient(String gatewayUrl, String merchantPrivateKey, String alipayPublicKey);
2424public < T extends AlipayResponse > T execute(AlipayRequest<T > alipayRequest);
2525
2626```
2727
28- ```
28+ ``` java
2929SignatureTool . java
3030
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);
3232public static boolean verify(String httpMethod, String path, String clientId, String rspTimeStr, String rspBody, String signature, String alipayPublicKey);
3333
3434```
@@ -37,7 +37,7 @@ public static boolean verify(String httpMethod, String path, String clientId, St
3737
3838AMS:
3939
40- ```
40+ ``` java
4141AlipayClient CLIENT = new DefaultAlipayClient (" https://open-na.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
4242
4343AlipayPayRequest alipayPayRequest = new AlipayPayRequest ();
@@ -97,7 +97,7 @@ AlipayPayResponse alipayPayResponse = CLIENT.execute(alipayPayRequest);
9797
9898APS:
9999
100- ```
100+ ``` java
101101AlipayClient CLIENT = new DefaultAlipayClient (" https://open-na.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
102102
103103AlipayApsInquiryPaymentRequest inquiryPaymentRequest = new AlipayApsInquiryPaymentRequest ();
@@ -112,7 +112,7 @@ AlipayApsInquiryPaymentResponse alipayResponse = CLIENT.execute(inquiryPaymentRe
112112
113113RISK:
114114
115- ```
115+ ``` java
116116AlipayClient CLIENT = new DefaultAlipayClient (" https://open-sea-global.alipay.com" , merchantPrivateKey, alipayPublicKey, clientid);
117117
118118RiskDecideRequest riskDecideRequest = new RiskDecideRequest ();
@@ -175,7 +175,7 @@ The execute method contains the HTTP request to the gateway.
175175
176176If you're concerned about HTTP invocation performance, you can implement HTTP invocation yourself.
177177
178- ```
178+ ``` java
179179public class YourAlipayClient extends BaseAlipayClient {
180180
181181 public YourAlipayClient (String gatewayUrl , String merchantPrivateKey , String alipayPublicKey ){
@@ -237,7 +237,7 @@ boolean isPass = SignatureTool.verify(httpMethod, path, clientId, rspTimeStr,
237237
238238For compatibility with lower version of Java JDK, signatureTool provided a base64 encryptor DefaultBase64Encryptor by default.
239239
240- ```
240+ ``` java
241241public class DefaultBase64Encryptor implements Base64Encryptor {
242242
243243 @Override
@@ -256,9 +256,9 @@ public class DefaultBase64Encryptor implements Base64Encryptor {
256256
257257For better performance, you can also customize the base64 tool. For example, jdk8 API Base64.
258258
259-
260- ```
261- public class YourBase64Encryptor implements Base64Encryptor {
259+ ##### 5.1 add "MyBase64Encryptor"
260+ ``` java
261+ public class MyBase64Encryptor implements Base64Encryptor {
262262
263263 @Override
264264 public String encodeToString (byte [] src ) {
@@ -271,7 +271,10 @@ public class YourBase64Encryptor implements Base64Encryptor {
271271 }
272272
273273}
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+ }
277280```
0 commit comments