Skip to content

Commit bdacc8e

Browse files
committed
refactor(snapbi): address PR feedback and add fixture-based webhook tests
- Apply Copilot suggestions: @OverRide on getMessage(), StandardCharsets.UTF_8 in test helper, remove redundant toLowerCase(), fix CHANGELOG grammar - Restore minifyJson to private visibility, test through public API only - Replace direct minifyJson unit tests with fixture-based webhook signature tests covering VA, QRIS, and Direct Debit (pending + success/settlement) - Add JSON fixture files with edge cases: spaces in string values, escaped quotes, empty objects, nested arrays
1 parent adb7e2c commit bdacc8e

11 files changed

Lines changed: 312 additions & 146 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## v3.2.2 (April 7, 2026)
44

5-
Bugs fix:
5+
Bug fixes:
66
- Fix `minifyJson()` in SnapBi stripping whitespace inside JSON string values, which caused incorrect SNAP-BI webhook notification signature verification. The method now uses a character-level JSON minifier that preserves whitespace within quoted strings.
77
- Fix `MidtransError` getter methods not being generated by Lombok on JDK 25. Replaced `@Getter` annotation with explicit getter methods for `statusCode`, `responseBody`, and `response`.
88

library/src/main/java/com/midtrans/httpclient/error/MidtransError.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class MidtransError extends Exception {
1212
private String responseBody;
1313
private Response response;
1414

15+
@Override
1516
public String getMessage() {
1617
return message;
1718
}

library/src/main/java/com/midtrans/snapbi/SnapBi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public static String getSymmetricSignatureHmacSh512(String accessToken, Map<Stri
294294
}
295295
}
296296

297-
static String minifyJson(String json) {
297+
private static String minifyJson(String json) {
298298
if (json == null || json.isEmpty()) {
299299
return "";
300300
}

library/src/test/java/com/midtrans/snapbi/SnapBiMinifyJsonTest.java

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)