The SDK now uses Jackson for ordinary JSON requests, multipart JSON parts, and
Meter HTTP/2 bodies. Its POM imports Jackson BOM 2.18.10. An application’s BOM
can override these dependencies; check the effective dependency tree and keep
Jackson modules aligned. Jackson 3 is not supported.
Existing Client calls, model field types, and Java enum constants are retained.
Generated AMS string enums write API wire values and accept both wire values and
historical Java constant names on input; unknown input returns null, including
direct calls to fromValue. In particular, TEMPLATE/FILE write
DISPUTE_EVIDENCE_TEMPLATE/DISPUTE_EVIDENCE_FILE, and
PAYMENTCODE/ORDERCODE/ENTRYCODE write PaymentCode/OrderCode/EntryCode.
Authentication responses read both isPassed and historical passed, but write
only isPassed.
For custom JSON handling, use com.alipay.global.api.tools.JsonUtil.toJson and
JsonUtil.fromJson. Object field order and complete JSON strings may change;
assert JSON structure instead of string snapshots. The SDK no longer supplies
fastjson transitively, so applications that still use it must manage that
dependency themselves. The SDK’s mapper is private and does not reuse an
application’s Spring ObjectMapper.
Sign exactly the JSON body you send. For notifications, call
WebhookTool.checkSignature with the original HTTP body before parsing it
with JsonUtil.fromJson; do not reserialize a notification before verification.
Meter HTTP/2 continues to use only X-Session-Id, as described below.
2 Main class file
DefaultAlipayClient.java
public DefaultAlipayClient(String gatewayUrl, String merchantPrivateKey, String alipayPublicKey);
public <T extends AlipayResponse> T execute(AlipayRequest<T> alipayRequest);
Meter event upload
meter/createSession uses the regular signed AMS transport. Use its session ID
to call meter/uploadEvent through executeWithHeaders:
AlipayMeterUploadEventRequest request = new AlipayMeterUploadEventRequest();
request.setMeters(meters);
Map<String, String> headers = new HashMap<>();
headers.put("X-Session-Id", sessionId);
AlipayMeterUploadEventResponse response = CLIENT.executeWithHeaders(request, headers);
The SDK sends meter/uploadEvent to the gateway URL configured on the client,
without sandbox path rewriting, request signing, response signature verification,
or automatic retries. This API requires HTTP/2.
1 Please use the latest version
https://mvnrepository.com/artifact/com.alipay.global.sdk/global-open-sdk-java
Upgrading to 3.0.0
The SDK now uses Jackson for ordinary JSON requests, multipart JSON parts, and Meter HTTP/2 bodies. Its POM imports Jackson BOM
2.18.10. An application’s BOM can override these dependencies; check the effective dependency tree and keep Jackson modules aligned. Jackson 3 is not supported.Existing Client calls, model field types, and Java enum constants are retained. Generated AMS string enums write API wire values and accept both wire values and historical Java constant names on input; unknown input returns null, including direct calls to
fromValue. In particular,TEMPLATE/FILEwriteDISPUTE_EVIDENCE_TEMPLATE/DISPUTE_EVIDENCE_FILE, andPAYMENTCODE/ORDERCODE/ENTRYCODEwritePaymentCode/OrderCode/EntryCode. Authentication responses read bothisPassedand historicalpassed, but write onlyisPassed.For custom JSON handling, use
com.alipay.global.api.tools.JsonUtil.toJsonandJsonUtil.fromJson. Object field order and complete JSON strings may change; assert JSON structure instead of string snapshots. The SDK no longer supplies fastjson transitively, so applications that still use it must manage that dependency themselves. The SDK’s mapper is private and does not reuse an application’s Spring ObjectMapper.Sign exactly the JSON body you send. For notifications, call
WebhookTool.checkSignaturewith the original HTTP body before parsing it withJsonUtil.fromJson; do not reserialize a notification before verification. Meter HTTP/2 continues to use onlyX-Session-Id, as described below.2 Main class file
Meter event upload
meter/createSessionuses the regular signed AMS transport. Use its session ID to callmeter/uploadEventthroughexecuteWithHeaders:The SDK sends
meter/uploadEventto the gateway URL configured on the client, without sandbox path rewriting, request signing, response signature verification, or automatic retries. This API requires HTTP/2.3 The sample for ams、aps、risk
AMS:
APS:
RISK:
The execute method contains the HTTP request to the gateway.
If you’re concerned about HTTP invocation performance, you can implement HTTP invocation yourself.
4 If you don’t care about HTTP calls,the sample for sign and verify
5 For base64
For compatibility with lower version of Java JDK, signatureTool provided a base64 encryptor DefaultBase64Encryptor by default.
For better performance, you can also customize the base64 tool. For example, jdk8 API Base64.
5.1 add “MyBase64Encryptor”
5.2 init before invoke alipayClient