Skip to content

Commit 3a38771

Browse files
authored
Merge pull request #56 from alipay/feature-base64
优化base64多jdk版本兼容-readme
2 parents a444804 + 1f62276 commit 3a38771

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Copyright:Ant financial services group
88

99
https://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
2121
DefaultAlipayClient.java
2222

2323
public DefaultAlipayClient(String gatewayUrl, String merchantPrivateKey, String alipayPublicKey);
2424
public <T extends AlipayResponse> T execute(AlipayRequest<T> alipayRequest);
2525

2626
```
2727

28-
```
28+
```java
2929
SignatureTool.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);
3232
public 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

3838
AMS:
3939

40-
```
40+
```java
4141
AlipayClient CLIENT = new DefaultAlipayClient("https://open-na.alipay.com", merchantPrivateKey, alipayPublicKey, clientid);
4242

4343
AlipayPayRequest alipayPayRequest = new AlipayPayRequest();
@@ -97,7 +97,7 @@ AlipayPayResponse alipayPayResponse = CLIENT.execute(alipayPayRequest);
9797

9898
APS:
9999

100-
```
100+
```java
101101
AlipayClient CLIENT = new DefaultAlipayClient("https://open-na.alipay.com", merchantPrivateKey, alipayPublicKey, clientid);
102102

103103
AlipayApsInquiryPaymentRequest inquiryPaymentRequest = new AlipayApsInquiryPaymentRequest();
@@ -112,7 +112,7 @@ AlipayApsInquiryPaymentResponse alipayResponse = CLIENT.execute(inquiryPaymentRe
112112

113113
RISK:
114114

115-
```
115+
```java
116116
AlipayClient CLIENT = new DefaultAlipayClient("https://open-sea-global.alipay.com", merchantPrivateKey, alipayPublicKey, clientid);
117117

118118
RiskDecideRequest riskDecideRequest = new RiskDecideRequest();
@@ -175,7 +175,7 @@ The execute method contains the HTTP request to the gateway.
175175

176176
If you're concerned about HTTP invocation performance, you can implement HTTP invocation yourself.
177177

178-
```
178+
```java
179179
public 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

238238
For compatibility with lower version of Java JDK, signatureTool provided a base64 encryptor DefaultBase64Encryptor by default.
239239

240-
```
240+
```java
241241
public class DefaultBase64Encryptor implements Base64Encryptor {
242242

243243
@Override
@@ -256,9 +256,9 @@ public class DefaultBase64Encryptor implements Base64Encryptor {
256256

257257
For 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

Comments
 (0)