Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "recommended" as possible value of Source card[three_d_secure] #830

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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(""));
}
}