From df451d4c9d3ec517b752099723a2cd3bc939247f Mon Sep 17 00:00:00 2001 From: Kan Srimanchantha <34004612+kan98@users.noreply.github.com> Date: Mon, 8 Aug 2022 15:59:20 +0700 Subject: [PATCH] [EM-2197] Add mobile banking source types (#141) * added * fix test * fix * fix test * added changelog * bump version --- CHANGELOG.md | 4 + build.gradle | 2 +- .../java/co/omise/models/PlatformType.java | 2 +- src/main/java/co/omise/models/SourceType.java | 8 ++ .../co/omise/live/LiveSourceRequestTest.java | 89 +++++++++++++++++++ .../co/omise/models/PlatformTypeTest.java | 2 +- .../java/co/omise/models/SourceTypeTest.java | 4 + 7 files changed, 108 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7b3c6de..9f8c3a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGE LOG +## v4.1.0 + +* **NEW** Added `Mobile Banking Bay`, `Mobile Banking BBL`, `Mobile Banking KBank` and `Mobile Banking OCBC PAO` source types (#141) + ## v4.0.8 * **FIXED** Fix passing null if email not specified in request (#139) diff --git a/build.gradle b/build.gradle index b2a9e41c..1a7e92c1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.ben-manes.versions' group 'co.omise' -version '4.0.8' +version '4.1.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/src/main/java/co/omise/models/PlatformType.java b/src/main/java/co/omise/models/PlatformType.java index 6609098f..27de01cc 100644 --- a/src/main/java/co/omise/models/PlatformType.java +++ b/src/main/java/co/omise/models/PlatformType.java @@ -11,7 +11,7 @@ public enum PlatformType { Unknown, @JsonProperty("WEB") Web, - @JsonProperty("iOS") + @JsonProperty("IOS") iOS, @JsonProperty("ANDROID") Android; diff --git a/src/main/java/co/omise/models/SourceType.java b/src/main/java/co/omise/models/SourceType.java index 7089dd5b..7fb1a319 100644 --- a/src/main/java/co/omise/models/SourceType.java +++ b/src/main/java/co/omise/models/SourceType.java @@ -43,6 +43,14 @@ public enum SourceType { InternetBankingKtb, @JsonProperty("internet_banking_scb") InternetBankingScb, + @JsonProperty("mobile_banking_bay") + MobileBankingBay, + @JsonProperty("mobile_banking_bbl") + MobileBankingBbl, + @JsonProperty("mobile_banking_kbank") + MobileBankingKbank, + @JsonProperty("mobile_banking_ocbc_pao") + MobileBankingOcbcPao, @JsonProperty("mobile_banking_scb") MobileBankingScb, @JsonProperty("paynow") diff --git a/src/test/java/co/omise/live/LiveSourceRequestTest.java b/src/test/java/co/omise/live/LiveSourceRequestTest.java index 18d28575..2596da7c 100644 --- a/src/test/java/co/omise/live/LiveSourceRequestTest.java +++ b/src/test/java/co/omise/live/LiveSourceRequestTest.java @@ -4,6 +4,7 @@ import co.omise.models.OmiseException; import co.omise.models.Source; import co.omise.models.SourceType; +import co.omise.models.PlatformType; import co.omise.requests.Request; import org.junit.Before; import org.junit.Ignore; @@ -214,6 +215,94 @@ public void testLiveSourceZeroInterestInstallments() throws IOException, OmiseEx assertTrue(source.isZeroInterestInstallments()); } + @Test + @Ignore("only hit the network when we need to.") + public void testLiveSourceMobileBankingBay() throws IOException, OmiseException { + Request request = new Source.CreateRequestBuilder() + .type(SourceType.MobileBankingBay) + .amount(10000) + .currency("thb") + .platformType(PlatformType.iOS) + .build(); + + Source source = client.sendRequest(request); + + System.out.println("created source: " + source.getId()); + + assertNotNull(source.getId()); + assertEquals("mobile_banking_bay", source.getType().toString()); + assertEquals("app_redirect", source.getFlow().toString()); + assertEquals(10000L, source.getAmount()); + assertEquals("THB", source.getCurrency()); + assertEquals("IOS", source.getPlatformType().toString()); + } + + @Test + @Ignore("only hit the network when we need to.") + public void testLiveSourceMobileBankingBbl() throws IOException, OmiseException { + Request request = new Source.CreateRequestBuilder() + .type(SourceType.MobileBankingBbl) + .amount(25000) + .currency("thb") + .platformType(PlatformType.Android) + .build(); + + Source source = client.sendRequest(request); + + System.out.println("created source: " + source.getId()); + + assertNotNull(source.getId()); + assertEquals("mobile_banking_bbl", source.getType().toString()); + assertEquals("app_redirect", source.getFlow().toString()); + assertEquals(25000L, source.getAmount()); + assertEquals("THB", source.getCurrency()); + assertEquals("ANDROID", source.getPlatformType().toString()); + } + + @Test + @Ignore("only hit the network when we need to.") + public void testLiveSourceMobileBankingKbank() throws IOException, OmiseException { + Request request = new Source.CreateRequestBuilder() + .type(SourceType.MobileBankingKbank) + .amount(25000) + .currency("thb") + .platformType(PlatformType.Android) + .build(); + + Source source = client.sendRequest(request); + + System.out.println("created source: " + source.getId()); + + assertNotNull(source.getId()); + assertEquals("mobile_banking_kbank", source.getType().toString()); + assertEquals("app_redirect", source.getFlow().toString()); + assertEquals(25000L, source.getAmount()); + assertEquals("THB", source.getCurrency()); + assertEquals("ANDROID", source.getPlatformType().toString()); + } + + @Test + @Ignore("only hit the network when we need to.") + public void testLiveSourceMobileBankingOcbcPao() throws IOException, OmiseException { + Request request = new Source.CreateRequestBuilder() + .type(SourceType.MobileBankingOcbcPao) + .amount(25000) + .currency("thb") + .platformType(PlatformType.iOS) + .build(); + + Source source = client.sendRequest(request); + + System.out.println("created source: " + source.getId()); + + assertNotNull(source.getId()); + assertEquals("mobile_banking_ocbc_pao", source.getType().toString()); + assertEquals("app_redirect", source.getFlow().toString()); + assertEquals(25000L, source.getAmount()); + assertEquals("THB", source.getCurrency()); + assertEquals("IOS", source.getPlatformType().toString()); + } + @Test @Ignore("only hit the network when we need to.") public void testLiveSourceMobileBankingScb() throws IOException, OmiseException { diff --git a/src/test/java/co/omise/models/PlatformTypeTest.java b/src/test/java/co/omise/models/PlatformTypeTest.java index e4b04418..0469cffe 100644 --- a/src/test/java/co/omise/models/PlatformTypeTest.java +++ b/src/test/java/co/omise/models/PlatformTypeTest.java @@ -9,7 +9,7 @@ public class PlatformTypeTest { @Test public void checkStringValue() { assertEquals("WEB", PlatformType.Web.toString()); - assertEquals("iOS", PlatformType.iOS.toString()); + assertEquals("IOS", PlatformType.iOS.toString()); assertEquals("ANDROID", PlatformType.Android.toString()); } } diff --git a/src/test/java/co/omise/models/SourceTypeTest.java b/src/test/java/co/omise/models/SourceTypeTest.java index 0c49f0a6..7ec79430 100644 --- a/src/test/java/co/omise/models/SourceTypeTest.java +++ b/src/test/java/co/omise/models/SourceTypeTest.java @@ -12,6 +12,10 @@ public void checkStringValue() { assertEquals("internet_banking_ktb", SourceType.InternetBankingKtb.toString()); assertEquals("internet_banking_bbl", SourceType.InternetBankingBbl.toString()); assertEquals("internet_banking_scb", SourceType.InternetBankingScb.toString()); + assertEquals("mobile_banking_bay", SourceType.MobileBankingBay.toString()); + assertEquals("mobile_banking_bbl", SourceType.MobileBankingBbl.toString()); + assertEquals("mobile_banking_kbank", SourceType.MobileBankingKbank.toString()); + assertEquals("mobile_banking_ocbc_pao", SourceType.MobileBankingOcbcPao.toString()); assertEquals("mobile_banking_scb", SourceType.MobileBankingScb.toString()); assertEquals("bill_payment_tesco_lotus", SourceType.BillPaymentTescoLotus.toString()); assertEquals("alipay", SourceType.Alipay.toString());