diff --git a/stripe/src/main/java/com/stripe/android/model/SourceCardData.java b/stripe/src/main/java/com/stripe/android/model/SourceCardData.java index 64c6632eec4..83605f7f6e2 100644 --- a/stripe/src/main/java/com/stripe/android/model/SourceCardData.java +++ b/stripe/src/main/java/com/stripe/android/model/SourceCardData.java @@ -35,12 +35,14 @@ public class SourceCardData extends StripeSourceTypeModel { REQUIRED, OPTIONAL, NOT_SUPPORTED, + RECOMMENDED, UNKNOWN }) public @interface ThreeDSecureStatus { } public static final String REQUIRED = "required"; public static final String OPTIONAL = "optional"; public static final String NOT_SUPPORTED = "not_supported"; + public static final String RECOMMENDED = "recommended"; public static final String UNKNOWN = "unknown"; private static final String FIELD_ADDRESS_LINE1_CHECK = "address_line1_check"; @@ -239,11 +241,11 @@ static SourceCardData fromString(String jsonString) { } } + @VisibleForTesting @Nullable @ThreeDSecureStatus - private static String asThreeDSecureStatus(@Nullable String threeDSecureStatus) { - String nullChecked = StripeJsonUtils.nullIfNullOrEmpty(threeDSecureStatus); - if (nullChecked == null) { + static String asThreeDSecureStatus(@Nullable String threeDSecureStatus) { + if (StripeJsonUtils.nullIfNullOrEmpty(threeDSecureStatus) == null) { return null; } @@ -253,6 +255,8 @@ private static String asThreeDSecureStatus(@Nullable String threeDSecureStatus) return OPTIONAL; } else if (NOT_SUPPORTED.equalsIgnoreCase(threeDSecureStatus)) { return NOT_SUPPORTED; + } else if (RECOMMENDED.equalsIgnoreCase(threeDSecureStatus)) { + return RECOMMENDED; } else { return UNKNOWN; } diff --git a/stripe/src/test/java/com/stripe/android/model/SourceCardDataTest.java b/stripe/src/test/java/com/stripe/android/model/SourceCardDataTest.java index 3081cae82fb..9e3e6dd410d 100644 --- a/stripe/src/test/java/com/stripe/android/model/SourceCardDataTest.java +++ b/stripe/src/test/java/com/stripe/android/model/SourceCardDataTest.java @@ -8,6 +8,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; /** * Test class for {@link SourceCardData}. @@ -70,4 +71,16 @@ public void testHashCode() { assertEquals(CARD_DATA.hashCode(), SourceCardData.fromString(EXAMPLE_JSON_SOURCE_CARD_DATA_WITH_APPLE_PAY).hashCode()); } + + @Test + public void testAsThreeDSecureStatus() { + assertEquals(SourceCardData.REQUIRED, SourceCardData.asThreeDSecureStatus("required")); + assertEquals(SourceCardData.OPTIONAL, SourceCardData.asThreeDSecureStatus("optional")); + assertEquals(SourceCardData.NOT_SUPPORTED, + SourceCardData.asThreeDSecureStatus("not_supported")); + assertEquals(SourceCardData.RECOMMENDED, + SourceCardData.asThreeDSecureStatus("recommended")); + assertEquals(SourceCardData.UNKNOWN, SourceCardData.asThreeDSecureStatus("unknown")); + assertNull(SourceCardData.asThreeDSecureStatus("")); + } }