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

Support 3 digit AMEX CVC input. #548

Merged
merged 2 commits into from
Apr 11, 2018
Merged

Support 3 digit AMEX CVC input. #548

merged 2 commits into from
Apr 11, 2018

Conversation

joel-stripe
Copy link
Contributor

@joel-stripe joel-stripe commented Apr 10, 2018

Copy link

@ksun-stripe ksun-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
It would be optimal if we could look into simplifying the expressions though.

if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) {
String cvcValue = mCvcNumberEditText.getText().toString().trim();
int cvcLength = cvcValue.length();
if (!(cvcLength == Card.CVC_LENGTH_COMMON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we simplify this expression at all? I'm worried it'll be confusing down the line with all the nesting and the parts

One idea is we can either pull it into two functions
isCommonCSVLength() || isValidAmexCVC()

boolean cvcIsValid = ViewUtils.isCvcMaximalLength(
mCardBrand, mCvcEditText.getText().toString());
int cvcLength = mCvcEditText.getText().toString().trim().length();
boolean cvcIsValid = cvcLength == Card.CVC_LENGTH_COMMON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we simplify this at all? This looks confusing and I'm concern it will be hard to maintain.

One option is to pull this into a self documenting helper function and to write some tests for it because then we will be able to know what the expression is expected to resolve to

@joel-stripe joel-stripe merged commit c1cf33d into master Apr 11, 2018
@joel-stripe joel-stripe deleted the joel-3digitamex branch April 11, 2018 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants