From 1af14da0ee79fb3b6c9304a8dfa08824ee0b5a5e Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 13:07:54 +0800 Subject: [PATCH 01/25] feat: update qrcodes for v2 --- .../main/java/com/xendit/model/QRCode.java | 28 ++++++-- .../java/com/xendit/model/QRCodeClient.java | 24 +++++-- .../java/com/xenditclient/QRCodeTest.java | 72 ++++++++++++++----- 3 files changed, 97 insertions(+), 27 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java index 6914fb3..c2ef39d 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java @@ -24,8 +24,14 @@ public enum QRCodeStatus { @SerializedName("id") private String id; - @SerializedName("external_id") - private String externalId; + @SerializedName("reference_id") + private String referenceId; + + @SerializedName("business_id") + private String businessId; + + @SerializedName("currency") + private String currency; @SerializedName("amount") private Number amount; @@ -33,8 +39,14 @@ public enum QRCodeStatus { @SerializedName("qr_string") private String qrString; - @SerializedName("callback_url") - private String callbackUrl; + @SerializedName("webhook_url") + private String webhookUrl; + + @SerializedName("channel_code") + private String channelCode; + + @SerializedName("expires_at") + private String expiresAt; @SerializedName("type") private String type; @@ -48,12 +60,18 @@ public enum QRCodeStatus { @SerializedName("updated") private String updated; + @SerializedName("basket") + private Object basket; + + @SerializedName("metadata") + private Object metadata; + private static QRCodeClient qrCodeClient; /** * Create QR Code with given parameters * - * @param externalId An ID of your choice. Often it is unique identifier in your system like + * @param referenceId An ID of your choice. Often it is unique identifier in your system like * customer ID or order ID * @param type DYNAMIC or STATIC. DYNAMIC QR code contains the payment value upon scanning and can * be paid multiple times. STATIC QR code requires end user to input the payment value and can diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index a57731f..5d9475a 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -19,16 +19,21 @@ public Xendit.Option getOpt() { } public QRCode createQRCode( - String externalId, QRCode.QRCodeType type, String callbackUrl, Number amount) + String referenceId, QRCode.QRCodeType type, String currency, Number amount) throws XenditException { Map params = new HashMap<>(); - params.put("external_id", externalId); + params.put("reference_id", referenceId); params.put("type", type.toString()); - params.put("callback_url", callbackUrl); + params.put("currency", currency) params.put("amount", amount); + + //Use new API version + + Map headers = new HashMap<>(); + headers.put("api-version", "2022-07-31") String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( - RequestResource.Method.POST, url, params, opt.getApiKey(), QRCode.class); + RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } public QRCode createQRCode(Map params) throws XenditException { @@ -38,6 +43,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); + headers.put("api-version", "2022-07-31") return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } @@ -47,4 +53,14 @@ public QRCode getQRCode(String externalId) throws XenditException { return this.requestClient.request( RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class); } + + public QRCode getQRCodeByQRId(String qrId) throws XenditException { + String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); + + Map headers = new HashMap<>(); + headers.put("api-version", "2022-07-31") + + return this.requestClient.request( + RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); + } } diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index 4d27419..ec8245e 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -19,19 +19,19 @@ public class QRCodeTest { private static String URL = String.format("%s%s", Xendit.Opt.getXenditURL(), "/qr_codes"); private static String TEST_ID = "test_id"; - private static String TEST_EXTERNAL_ID = "test_external_id"; + private static String TEST_REFERENCE_ID = "test_reference_id"; private static String TEST_QR_STRING = "this_is_qr_string"; - private static String TEST_CALLBACK_URL = "https://callback.url"; private static String TEST_QR_TYPE = QRCode.QRCodeType.DYNAMIC.toString(); private static String TEST_QR_STATUS = QRCode.QRCodeStatus.ACTIVE.toString(); + private static String TEST_QR_CURRENCY = "IDR" private static Map PARAMS = new HashMap<>(); private static Map HEADERS = new HashMap<>(); private static QRCode VALID_PAYMENT = QRCode.builder() .id(TEST_ID) - .externalId(TEST_EXTERNAL_ID) + .externalId(TEST_REFERENCE_ID) + .currency(TEST_QR_CURRENCY) .qrString(TEST_QR_STRING) - .callbackUrl(TEST_CALLBACK_URL) .status(TEST_QR_STATUS) .amount(10000) .build(); @@ -49,25 +49,29 @@ public void initMocks() { } private void initCreateParams() { - PARAMS.put("external_id", TEST_EXTERNAL_ID); + PARAMS.put("reference_id", TEST_REFERENCE_ID); PARAMS.put("type", TEST_QR_TYPE); - PARAMS.put("callback_url", TEST_CALLBACK_URL); + PARAMS.put("currency", TEST_QR_CURRENCY); PARAMS.put("amount", 10000); } + private void initCreateHeaders() { + HEADERS.put("api-version", "2022-07-31") + } + @Test public void createQRCode_Success_IfMethodCalledCorrectly() throws XenditException { initCreateParams(); when(this.requestClient.request( - RequestResource.Method.POST, URL, PARAMS, opt.getApiKey(), QRCode.class)) + RequestResource.Method.POST, URL, HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.createQRCode( - TEST_EXTERNAL_ID, QRCode.QRCodeType.DYNAMIC, TEST_CALLBACK_URL, 10000)) + TEST_REFERENCE_ID, QRCode.QRCodeType.DYNAMIC, TEST_QR_CURRENCY, 10000)) .thenReturn(VALID_PAYMENT); QRCode qrCode = qrCodeClient.createQRCode( - TEST_EXTERNAL_ID, QRCode.QRCodeType.DYNAMIC, TEST_CALLBACK_URL, 10000); + TEST_REFERENCE_ID, QRCode.QRCodeType.DYNAMIC, TEST_QR_CURRENCY, 10000); assertEquals(qrCode, VALID_PAYMENT); } @@ -79,7 +83,7 @@ public void createQRCode_Success_IfParamsIsValid() throws XenditException { when(this.requestClient.request( RequestResource.Method.POST, URL, - new HashMap<>(), + HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) @@ -98,7 +102,7 @@ public void createQRCode_ThrowsException_IfParamsIsInvalid() throws XenditExcept when(this.requestClient.request( RequestResource.Method.POST, URL, - new HashMap<>(), + HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) @@ -126,27 +130,59 @@ public void createQRCode_Success_WithHeaderProvided() throws XenditException { @Test public void GetQRCode_Success_WithExternalId() throws XenditException { - String url = String.format("%s/%s", URL, TEST_EXTERNAL_ID); + String url = String.format("%s/%s", URL, TEST_REFERENCE_ID); + + when(this.requestClient.request( + RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) + .thenReturn(VALID_PAYMENT); + when(qrCodeClient.getQRCode(TEST_REFERENCE_ID)).thenReturn(VALID_PAYMENT); + QRCode qrCode = qrCodeClient.getQRCode(TEST_REFERENCE_ID); + + assertEquals(qrCode, VALID_PAYMENT); + } + + @Test(expected = XenditException.class) + public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditException { + String NOT_VALID_REFERENCE_ID = "not_valid_reference_id"; + String url = String.format("%s/%s", URL, NOT_VALID_REFERENCE_ID); when(this.requestClient.request( RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) + .thenThrow(new XenditException("not found")); + when(qrCodeClient.getQRCode(NOT_VALID_REFERENCE_ID)).thenThrow(new XenditException("not found")); + + qrCodeClient.getQRCode(NOT_VALID_REFERENCE_ID); + } + + @Test + public void GetQRCode_Success_WithQRId() throws XenditException { + String url = String.format("%s/%s", URL, TEST_ID); + + Map headers = new HashMap<>(); + headers.put("api-version", "2022-07-31") + + when(this.requestClient.request( + RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); - when(qrCodeClient.getQRCode(TEST_EXTERNAL_ID)).thenReturn(VALID_PAYMENT); - QRCode qrCode = qrCodeClient.getQRCode(TEST_EXTERNAL_ID); + when(qrCodeClient.getQRCodeByQRId(TEST_ID)).thenReturn(VALID_PAYMENT); + QRCode qrCode = qrCodeClient.getQRCodeByQRId(TEST_ID); assertEquals(qrCode, VALID_PAYMENT); } @Test(expected = XenditException.class) public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditException { - String NOT_VALID_EXTERNAL_ID = "not_valid_external_id"; - String url = String.format("%s/%s", URL, NOT_VALID_EXTERNAL_ID); + String NOT_VALID_QR_ID = "not_valid_qr_id"; + String url = String.format("%s/%s", URL, NOT_VALID_QR_ID); + + Map headers = new HashMap<>(); + headers.put("api-version", "2022-07-31") when(this.requestClient.request( RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) .thenThrow(new XenditException("not found")); - when(qrCodeClient.getQRCode(NOT_VALID_EXTERNAL_ID)).thenThrow(new XenditException("not found")); + when(qrCodeClient.getQRCodeByQRId(NOT_VALID_QR_ID)).thenThrow(new XenditException("not found")); - qrCodeClient.getQRCode(NOT_VALID_EXTERNAL_ID); + qrCodeClient.getQRCodeByQRId(NOT_VALID_QR_ID); } } From 58c78b484b55d05b8d8cdcf62710a56a1009fac2 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 13:19:51 +0800 Subject: [PATCH 02/25] fix: compile issues --- .../src/main/java/com/xendit/model/QRCodeClient.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 5d9475a..381f980 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -30,7 +30,7 @@ public QRCode createQRCode( //Use new API version Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); @@ -43,7 +43,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } @@ -58,7 +58,7 @@ public QRCode getQRCodeByQRId(String qrId) throws XenditException { String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); From 0c0aa00437c768616155fed4e939f6a1c2a89288 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 13:20:30 +0800 Subject: [PATCH 03/25] fix: linting issues --- .../src/main/java/com/xendit/model/QRCodeClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 381f980..6c744d0 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -24,7 +24,7 @@ public QRCode createQRCode( Map params = new HashMap<>(); params.put("reference_id", referenceId); params.put("type", type.toString()); - params.put("currency", currency) + params.put("currency", currency); params.put("amount", amount); //Use new API version From 3d0771a3a2a88ea5cf1f21166ed923b16c43e7d7 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 13:42:57 +0800 Subject: [PATCH 04/25] fix: move version to one var --- .../src/main/java/com/xendit/model/QRCodeClient.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 6c744d0..3209a68 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -14,6 +14,8 @@ public class QRCodeClient { private NetworkClient requestClient; + private String APIVersion = "2022-07-31"; + public Xendit.Option getOpt() { return opt; } @@ -30,7 +32,7 @@ public QRCode createQRCode( //Use new API version Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31"); + headers.put("api-version", APIVersion); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); @@ -43,7 +45,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); - headers.put("api-version", "2022-07-31"); + headers.put("api-version", APIVersion); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } @@ -58,7 +60,7 @@ public QRCode getQRCodeByQRId(String qrId) throws XenditException { String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31"); + headers.put("api-version", APIVersion); return this.requestClient.request( RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); From 4a9c11f0220dd4463dfc586fe2d82e842b076516 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 13:56:01 +0800 Subject: [PATCH 05/25] fix: remove private var --- .../src/main/java/com/xendit/model/QRCodeClient.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 3209a68..5d9475a 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -14,8 +14,6 @@ public class QRCodeClient { private NetworkClient requestClient; - private String APIVersion = "2022-07-31"; - public Xendit.Option getOpt() { return opt; } @@ -26,13 +24,13 @@ public QRCode createQRCode( Map params = new HashMap<>(); params.put("reference_id", referenceId); params.put("type", type.toString()); - params.put("currency", currency); + params.put("currency", currency) params.put("amount", amount); //Use new API version Map headers = new HashMap<>(); - headers.put("api-version", APIVersion); + headers.put("api-version", "2022-07-31") String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); @@ -45,7 +43,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); - headers.put("api-version", APIVersion); + headers.put("api-version", "2022-07-31") return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } @@ -60,7 +58,7 @@ public QRCode getQRCodeByQRId(String qrId) throws XenditException { String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); Map headers = new HashMap<>(); - headers.put("api-version", APIVersion); + headers.put("api-version", "2022-07-31") return this.requestClient.request( RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); From 67207001c52ebddf0e6067265ef3a99986aca25c Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 14:49:18 +0800 Subject: [PATCH 06/25] fix: linter --- .../src/main/java/com/xendit/model/QRCodeClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 5d9475a..6c744d0 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -24,13 +24,13 @@ public QRCode createQRCode( Map params = new HashMap<>(); params.put("reference_id", referenceId); params.put("type", type.toString()); - params.put("currency", currency) + params.put("currency", currency); params.put("amount", amount); //Use new API version Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); @@ -43,7 +43,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); } @@ -58,7 +58,7 @@ public QRCode getQRCodeByQRId(String qrId) throws XenditException { String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); From 3373be71edbbeb70ea2fec9abb1c387c2b909b92 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 14:52:57 +0800 Subject: [PATCH 07/25] fix: hashmap type to string --- .../src/main/java/com/xendit/model/QRCodeClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 6c744d0..c2beb74 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -29,7 +29,7 @@ public QRCode createQRCode( //Use new API version - Map headers = new HashMap<>(); + Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); return this.requestClient.request( @@ -57,7 +57,7 @@ public QRCode getQRCode(String externalId) throws XenditException { public QRCode getQRCodeByQRId(String qrId) throws XenditException { String url = String.format("%s%s%s", opt.getXenditURL(), "/qr_codes/", qrId); - Map headers = new HashMap<>(); + Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); return this.requestClient.request( From fbec404d3db43c5e737136a5b0f20179ee53cbd7 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:06:21 +0800 Subject: [PATCH 08/25] fix: get qr code method call --- .../src/main/java/com/xendit/model/QRCodeClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index c2beb74..de62b30 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -61,6 +61,6 @@ public QRCode getQRCodeByQRId(String qrId) throws XenditException { headers.put("api-version", "2022-07-31"); return this.requestClient.request( - RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class); + RequestResource.Method.GET, url, headers, null, opt.getApiKey(), QRCode.class); } } From 0cc071b6431f114908a8907000c16b8e84d44e4a Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:08:45 +0800 Subject: [PATCH 09/25] fix: compile test --- .../src/test/java/com/xenditclient/QRCodeTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index ec8245e..8d6a78e 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -23,7 +23,7 @@ public class QRCodeTest { private static String TEST_QR_STRING = "this_is_qr_string"; private static String TEST_QR_TYPE = QRCode.QRCodeType.DYNAMIC.toString(); private static String TEST_QR_STATUS = QRCode.QRCodeStatus.ACTIVE.toString(); - private static String TEST_QR_CURRENCY = "IDR" + private static String TEST_QR_CURRENCY = "IDR"; private static Map PARAMS = new HashMap<>(); private static Map HEADERS = new HashMap<>(); private static QRCode VALID_PAYMENT = @@ -56,7 +56,7 @@ private void initCreateParams() { } private void initCreateHeaders() { - HEADERS.put("api-version", "2022-07-31") + HEADERS.put("api-version", "2022-07-31"); } @Test @@ -159,7 +159,7 @@ public void GetQRCode_Success_WithQRId() throws XenditException { String url = String.format("%s/%s", URL, TEST_ID); Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); when(this.requestClient.request( RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class)) @@ -176,7 +176,7 @@ public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditExcept String url = String.format("%s/%s", URL, NOT_VALID_QR_ID); Map headers = new HashMap<>(); - headers.put("api-version", "2022-07-31") + headers.put("api-version", "2022-07-31"); when(this.requestClient.request( RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) From e42557c9af4814607f14e0dfdc2f1b113a9fe75c Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:15:09 +0800 Subject: [PATCH 10/25] fix: compile test qrcode builder --- xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index 8d6a78e..c62a2c4 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -29,7 +29,7 @@ public class QRCodeTest { private static QRCode VALID_PAYMENT = QRCode.builder() .id(TEST_ID) - .externalId(TEST_REFERENCE_ID) + .referenceId(TEST_REFERENCE_ID) .currency(TEST_QR_CURRENCY) .qrString(TEST_QR_STRING) .status(TEST_QR_STATUS) From e8e0a819b3de4a4c95332df5de24de10308a4827 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:17:14 +0800 Subject: [PATCH 11/25] fix: compile test qrcode test --- xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index c62a2c4..a9f48da 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -171,7 +171,7 @@ public void GetQRCode_Success_WithQRId() throws XenditException { } @Test(expected = XenditException.class) - public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditException { + public void GetQRCode_ThrowsException_OnReferenceIDNotFound() throws XenditException { String NOT_VALID_QR_ID = "not_valid_qr_id"; String url = String.format("%s/%s", URL, NOT_VALID_QR_ID); From f07228a3e96d52019fcac9aef7c658052335486f Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:37:55 +0800 Subject: [PATCH 12/25] fix: fix qrcode test with headers --- .../test/java/com/xenditclient/QRCodeTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index a9f48da..d3aa70c 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -55,10 +55,6 @@ private void initCreateParams() { PARAMS.put("amount", 10000); } - private void initCreateHeaders() { - HEADERS.put("api-version", "2022-07-31"); - } - @Test public void createQRCode_Success_IfMethodCalledCorrectly() throws XenditException { initCreateParams(); @@ -118,8 +114,13 @@ public void createQRCode_Success_WithHeaderProvided() throws XenditException { initCreateParams(); HEADERS.put("for-user-id", "user-id"); + private static Map RequestHeaders = new HashMap<>(); + RequestHeaders.put("for-user-id", "user-id"); + RequestHeaders.put("api-version", "2022-07-31"); + + when(this.requestClient.request( - RequestResource.Method.POST, URL, HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) + RequestResource.Method.POST, URL, RequestHeaders, PARAMS, opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.createQRCode(HEADERS, PARAMS)).thenReturn(VALID_PAYMENT); @@ -162,7 +163,7 @@ public void GetQRCode_Success_WithQRId() throws XenditException { headers.put("api-version", "2022-07-31"); when(this.requestClient.request( - RequestResource.Method.GET, url, headers, opt.getApiKey(), QRCode.class)) + RequestResource.Method.GET, url, headers, null, opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.getQRCodeByQRId(TEST_ID)).thenReturn(VALID_PAYMENT); QRCode qrCode = qrCodeClient.getQRCodeByQRId(TEST_ID); @@ -179,7 +180,7 @@ public void GetQRCode_ThrowsException_OnReferenceIDNotFound() throws XenditExcep headers.put("api-version", "2022-07-31"); when(this.requestClient.request( - RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) + RequestResource.Method.GET, url, headers, null, opt.getApiKey(), QRCode.class)) .thenThrow(new XenditException("not found")); when(qrCodeClient.getQRCodeByQRId(NOT_VALID_QR_ID)).thenThrow(new XenditException("not found")); From b42933aef4eadc697194e409925e8b60ddef376b Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:40:46 +0800 Subject: [PATCH 13/25] fix: fix qrcode test compile --- xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index d3aa70c..6577a96 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -114,7 +114,7 @@ public void createQRCode_Success_WithHeaderProvided() throws XenditException { initCreateParams(); HEADERS.put("for-user-id", "user-id"); - private static Map RequestHeaders = new HashMap<>(); + Map RequestHeaders = new HashMap<>(); RequestHeaders.put("for-user-id", "user-id"); RequestHeaders.put("api-version", "2022-07-31"); From 907a7fd36462451c0a5fdd9f9d28bccf8defefc6 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 15:43:42 +0800 Subject: [PATCH 14/25] fix: fix qrcode test hashmap --- .../src/test/java/com/xenditclient/QRCodeTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index 6577a96..245d64a 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -159,7 +159,7 @@ public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditExcept public void GetQRCode_Success_WithQRId() throws XenditException { String url = String.format("%s/%s", URL, TEST_ID); - Map headers = new HashMap<>(); + Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); when(this.requestClient.request( @@ -176,7 +176,7 @@ public void GetQRCode_ThrowsException_OnReferenceIDNotFound() throws XenditExcep String NOT_VALID_QR_ID = "not_valid_qr_id"; String url = String.format("%s/%s", URL, NOT_VALID_QR_ID); - Map headers = new HashMap<>(); + Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); when(this.requestClient.request( From d091201500b15e4f23b7eec18897832bd0d74144 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:01:59 +0800 Subject: [PATCH 15/25] fix: update QRCode class --- .../main/java/com/xendit/model/QRCode.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java index c2ef39d..e2118da 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java @@ -76,18 +76,17 @@ public enum QRCodeStatus { * @param type DYNAMIC or STATIC. DYNAMIC QR code contains the payment value upon scanning and can * be paid multiple times. STATIC QR code requires end user to input the payment value and can * be paid multiple times - * @param callbackUrl The URL to receive payment notification after payment has been made by end - * user + * @param currency Currency of the QR code generated * @param amount The payment value embedded in the QR code, end user can only pay the specified * amount after scanning the QR code. For STATIC QR code, amount parameter will be ignored. * @return QRCode * @throws XenditException XenditException */ public static QRCode createQRCode( - String externalId, QRCodeType type, String callbackUrl, Number amount) + String referenceId, QRCode.QRCodeType type, String currency, Number amount) throws XenditException { QRCodeClient client = getClient(); - return client.createQRCode(externalId, type, callbackUrl, amount); + return client.createQRCode(referenceId, type, currency, amount); } /** @@ -127,6 +126,18 @@ public static QRCode getQRCode(String externalId) throws XenditException { return client.getQRCode(externalId); } + /** + * Get QR Code by external id + * + * @param qrId Xendit provided unique ID returned when generating a qr code request. Starts with qr_ + * @return QRCode + * @throws XenditException XenditException + */ + public static QRCode getQRCode(String qrId) throws XenditException { + QRCodeClient client = getClient(); + return client.getQRCodeByQRId(externalId); + } + /** * Its create a client for QRCode * From 7d5c7557f47256c6a01d60233a73c78cee88104c Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:13:14 +0800 Subject: [PATCH 16/25] fix: update QRCode function --- xendit-java-lib/src/main/java/com/xendit/model/QRCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java index e2118da..4500431 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java @@ -133,7 +133,7 @@ public static QRCode getQRCode(String externalId) throws XenditException { * @return QRCode * @throws XenditException XenditException */ - public static QRCode getQRCode(String qrId) throws XenditException { + public static QRCode getQRCodeByQRId(String qrId) throws XenditException { QRCodeClient client = getClient(); return client.getQRCodeByQRId(externalId); } From bbb2e4e38ff39167b18fe80127ebb6111241f4d2 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:16:29 +0800 Subject: [PATCH 17/25] fix: update QRCode function var --- xendit-java-lib/src/main/java/com/xendit/model/QRCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java index 4500431..8902268 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java @@ -127,7 +127,7 @@ public static QRCode getQRCode(String externalId) throws XenditException { } /** - * Get QR Code by external id + * Get QR Code by qr id id * * @param qrId Xendit provided unique ID returned when generating a qr code request. Starts with qr_ * @return QRCode @@ -135,7 +135,7 @@ public static QRCode getQRCode(String externalId) throws XenditException { */ public static QRCode getQRCodeByQRId(String qrId) throws XenditException { QRCodeClient client = getClient(); - return client.getQRCodeByQRId(externalId); + return client.getQRCodeByQRId(qrId); } /** From 7455d9bbc00c4640f0984aa3f50fda0b2e895a59 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:39:00 +0800 Subject: [PATCH 18/25] update readme and examples --- README.md | 12 ++++++------ .../java/ExampleWithClient/ExampleGetQRCode.java | 4 ++-- .../java/ExampleWithoutClient/ExampleGetQRCode.java | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f005429..e7e4f05 100644 --- a/README.md +++ b/README.md @@ -1334,16 +1334,16 @@ CardlessCredit cardlessCredit = xenditClient.cardlessCredit.create( ```java /* Without client */ QRCode qrCode = QRCode.create( - "external_id", + "reference_id", QRCode.QRCodeType.DYNAMIC, - "https://callback.site", + "IDR", 10000 ); /* With client */ QRCode qrCode = xenditClient.qrCode.create( - "external_id", + "reference_id", QRCode.QRCodeType.DYNAMIC, - "https://callback.site", + "IDR", 10000 ); ``` @@ -1352,9 +1352,9 @@ QRCode qrCode = xenditClient.qrCode.create( ```java /* Without client */ -QRCode qrCode = QRCode.getQRCode("external_id"); +QRCode qrCode = QRCode.getQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); /* With client */ -QRCode qrCode = xenditClient.qrCode.getQRCode("external_id"); +QRCode qrCode = xenditClient.qrCode.getQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); ``` ### Customer diff --git a/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java b/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java index 3be8d45..78f883d 100644 --- a/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java +++ b/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java @@ -4,7 +4,7 @@ import com.xendit.XenditClient; import com.xendit.model.QRCode; -public class ExampleGetQRCode { +public class ExampleGetQRCodeByQRId { public static void main(String[] args) { //create xendit client which holds value of apikey XenditClient xenditClient = new XenditClient.Builder() @@ -12,7 +12,7 @@ public static void main(String[] args) { .build(); try { - QRCode qrCode = xenditClient.qrCode.getQRCode("12"); + QRCode qrCode = xenditClient.qrCode.getQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); System.out.println(qrCode.getId()); } catch (XenditException e) { e.printStackTrace(); diff --git a/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java b/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java index 117cf4d..946e85b 100644 --- a/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java +++ b/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java @@ -4,7 +4,7 @@ import com.xendit.Xendit; import com.xendit.model.QRCode; -public class ExampleGetQRCode { +public class ExampleGetQRCodeByQRId { public static void main(String[] args) { // access key with Option Xendit.Opt.setApiKey("xnd_development_..."); @@ -13,7 +13,7 @@ public static void main(String[] args) { // Xendit.apiKey = "xnd_development_..."; try { - QRCode qrCode = QRCode.getQRCode("12"); + QRCode qrCode = QRCode.ExampleGetQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); System.out.println(qrCode.getId()); } catch (XenditException e) { e.printStackTrace(); From 7b4139d08d27612c0cb0ce00bed69aa2c64867ec Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:42:57 +0800 Subject: [PATCH 19/25] rename files --- .../{ExampleGetQRCode.java => ExampleGetQRCodeByQRId.java} | 0 .../{ExampleGetQRCode.java => ExampleGetQRCodeByQRId.java} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename xendit-java-library-example/src/main/java/ExampleWithClient/{ExampleGetQRCode.java => ExampleGetQRCodeByQRId.java} (100%) rename xendit-java-library-example/src/main/java/ExampleWithoutClient/{ExampleGetQRCode.java => ExampleGetQRCodeByQRId.java} (100%) diff --git a/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java b/xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCodeByQRId.java similarity index 100% rename from xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCode.java rename to xendit-java-library-example/src/main/java/ExampleWithClient/ExampleGetQRCodeByQRId.java diff --git a/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java b/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java similarity index 100% rename from xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCode.java rename to xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java From 772218f35279eb95cba1486eeec30a88dffab6be Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 16:56:07 +0800 Subject: [PATCH 20/25] fix: example --- .../main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java b/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java index 946e85b..0476635 100644 --- a/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java +++ b/xendit-java-library-example/src/main/java/ExampleWithoutClient/ExampleGetQRCodeByQRId.java @@ -13,7 +13,7 @@ public static void main(String[] args) { // Xendit.apiKey = "xnd_development_..."; try { - QRCode qrCode = QRCode.ExampleGetQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); + QRCode qrCode = QRCode.getQRCodeByQRId("qr_004a0427-b194-49be-9439-657ef77ee4f3"); System.out.println(qrCode.getId()); } catch (XenditException e) { e.printStackTrace(); From c2d0d39581010381452634dba3fc7baa3c2bc696 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 17:27:01 +0800 Subject: [PATCH 21/25] fix: linting --- .../src/main/java/com/xendit/model/QRCode.java | 5 +++-- .../main/java/com/xendit/model/QRCodeClient.java | 1 - .../src/test/java/com/xenditclient/QRCodeTest.java | 14 ++------------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java index 8902268..e5c3ff3 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCode.java @@ -76,7 +76,7 @@ public enum QRCodeStatus { * @param type DYNAMIC or STATIC. DYNAMIC QR code contains the payment value upon scanning and can * be paid multiple times. STATIC QR code requires end user to input the payment value and can * be paid multiple times - * @param currency Currency of the QR code generated + * @param currency Currency of the QR code generated * @param amount The payment value embedded in the QR code, end user can only pay the specified * amount after scanning the QR code. For STATIC QR code, amount parameter will be ignored. * @return QRCode @@ -129,7 +129,8 @@ public static QRCode getQRCode(String externalId) throws XenditException { /** * Get QR Code by qr id id * - * @param qrId Xendit provided unique ID returned when generating a qr code request. Starts with qr_ + * @param qrId Xendit provided unique ID returned when generating a qr code request. Starts with + * qr_ * @return QRCode * @throws XenditException XenditException */ diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index de62b30..16c13f3 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -28,7 +28,6 @@ public QRCode createQRCode( params.put("amount", amount); //Use new API version - Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index 245d64a..84612dc 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -77,12 +77,7 @@ public void createQRCode_Success_IfParamsIsValid() throws XenditException { initCreateParams(); when(this.requestClient.request( - RequestResource.Method.POST, - URL, - HEADERS, - PARAMS, - opt.getApiKey(), - QRCode.class)) + RequestResource.Method.POST, URL, HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.createQRCode(PARAMS)).thenReturn(VALID_PAYMENT); QRCode qrCode = qrCodeClient.createQRCode(PARAMS); @@ -96,12 +91,7 @@ public void createQRCode_ThrowsException_IfParamsIsInvalid() throws XenditExcept PARAMS.put("type", "NOT_DYNAMIC"); when(this.requestClient.request( - RequestResource.Method.POST, - URL, - HEADERS, - PARAMS, - opt.getApiKey(), - QRCode.class)) + RequestResource.Method.POST, URL, HEADERS, PARAMS, opt.getApiKey(), QRCode.class)) .thenThrow(new XenditException("QR Code type is invalid")); when(qrCodeClient.createQRCode(PARAMS)) .thenThrow(new XenditException("QR Code type is invalid")); From 64ec5e9546330592c466e5f4626e5a0be262347d Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 17:30:01 +0800 Subject: [PATCH 22/25] fix: add comment --- xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 16c13f3..6154043 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -42,6 +42,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); + //Use new API version headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); From 3ce4d24df57f4b40c1d013bc2633419cf82d101f Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Thu, 8 Dec 2022 17:41:56 +0800 Subject: [PATCH 23/25] fix: linter --- .../src/main/java/com/xendit/model/QRCodeClient.java | 4 ++-- .../src/test/java/com/xenditclient/QRCodeTest.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java index 6154043..664d756 100644 --- a/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java +++ b/xendit-java-lib/src/main/java/com/xendit/model/QRCodeClient.java @@ -27,7 +27,7 @@ public QRCode createQRCode( params.put("currency", currency); params.put("amount", amount); - //Use new API version + // Use new API version Map headers = new HashMap<>(); headers.put("api-version", "2022-07-31"); String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); @@ -42,7 +42,7 @@ public QRCode createQRCode(Map params) throws XenditException { public QRCode createQRCode(Map headers, Map params) throws XenditException { String url = String.format("%s%s", opt.getXenditURL(), "/qr_codes"); - //Use new API version + // Use new API version headers.put("api-version", "2022-07-31"); return this.requestClient.request( RequestResource.Method.POST, url, headers, params, opt.getApiKey(), QRCode.class); diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index 84612dc..c1246fd 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -110,7 +110,12 @@ public void createQRCode_Success_WithHeaderProvided() throws XenditException { when(this.requestClient.request( - RequestResource.Method.POST, URL, RequestHeaders, PARAMS, opt.getApiKey(), QRCode.class)) + RequestResource.Method.POST, + URL, + RequestHeaders, + PARAMS, + opt.getApiKey(), + QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.createQRCode(HEADERS, PARAMS)).thenReturn(VALID_PAYMENT); From 3080678a7736d5014d71729f2680b884b41b9ef8 Mon Sep 17 00:00:00 2001 From: Shaun Yee Date: Mon, 12 Dec 2022 13:51:11 +0800 Subject: [PATCH 24/25] fix: update version --- xendit-java-lib/build.gradle | 2 +- xendit-java-lib/src/main/java/com/xendit/Xendit.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xendit-java-lib/build.gradle b/xendit-java-lib/build.gradle index 1db05c7..f9eb283 100644 --- a/xendit-java-lib/build.gradle +++ b/xendit-java-lib/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.xendit' -version '1.20.7' +version '1.21.0' sourceCompatibility = 1.8 diff --git a/xendit-java-lib/src/main/java/com/xendit/Xendit.java b/xendit-java-lib/src/main/java/com/xendit/Xendit.java index 4a82809..f59fe96 100644 --- a/xendit-java-lib/src/main/java/com/xendit/Xendit.java +++ b/xendit-java-lib/src/main/java/com/xendit/Xendit.java @@ -37,7 +37,7 @@ public String getXenditURL() { } public String getVersion() { - return "1.20.7"; + return "1.21.0"; } } } From 34eb7b7385e5ea3dea889c93d07af9c918146af6 Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Mon, 12 Dec 2022 16:04:56 +0700 Subject: [PATCH 25/25] Fix spotless apply --- .../src/test/java/com/xenditclient/QRCodeTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java index c1246fd..94a76ee 100644 --- a/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java +++ b/xendit-java-lib/src/test/java/com/xenditclient/QRCodeTest.java @@ -108,13 +108,12 @@ public void createQRCode_Success_WithHeaderProvided() throws XenditException { RequestHeaders.put("for-user-id", "user-id"); RequestHeaders.put("api-version", "2022-07-31"); - when(this.requestClient.request( - RequestResource.Method.POST, - URL, - RequestHeaders, - PARAMS, - opt.getApiKey(), + RequestResource.Method.POST, + URL, + RequestHeaders, + PARAMS, + opt.getApiKey(), QRCode.class)) .thenReturn(VALID_PAYMENT); when(qrCodeClient.createQRCode(HEADERS, PARAMS)).thenReturn(VALID_PAYMENT); @@ -145,7 +144,8 @@ public void GetQRCode_ThrowsException_OnExternalIDNotFound() throws XenditExcept when(this.requestClient.request( RequestResource.Method.GET, url, null, opt.getApiKey(), QRCode.class)) .thenThrow(new XenditException("not found")); - when(qrCodeClient.getQRCode(NOT_VALID_REFERENCE_ID)).thenThrow(new XenditException("not found")); + when(qrCodeClient.getQRCode(NOT_VALID_REFERENCE_ID)) + .thenThrow(new XenditException("not found")); qrCodeClient.getQRCode(NOT_VALID_REFERENCE_ID); }