@Test public void getCard_whenInputIsValidVisa_returnsCardObjectWithLoggingToken() { assertTrue(Calendar.getInstance().get(Calendar.YEAR) < 2050); mCardNumberEditText.setText(VALID_VISA_WITH_SPACES); mExpiryEditText.append("12"); mExpiryEditText.append("50"); mCvcEditText.append("123"); Card card = mCardInputWidget.getCard(); assertNotNull(card); assertEquals(VALID_VISA_NO_SPACES, card.getNumber()); assertNotNull(card.getExpMonth()); assertNotNull(card.getExpYear()); assertEquals(12, card.getExpMonth().intValue()); assertEquals(2050, card.getExpYear().intValue()); assertEquals("123", card.getCVC()); assertTrue(card.validateCard()); assertArrayEquals(EXPECTED_LOGGING_ARRAY, card.getLoggingTokens().toArray()); }
@Nullable public Card getCard() { String cardNumber = mCardNumberEditText.getCardNumber(); int[] cardDate = mExpiryDateEditText.getValidDateFields(); if (cardNumber == null || cardDate == null || cardDate.length != 2) { return null; } int requiredLength = mIsAmEx ? Card.CVC_LENGTH_AMERICAN_EXPRESS : Card.CVC_LENGTH_COMMON; String cvcValue = mCvcNumberEditText.getText().toString(); if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) { return null; } return new Card(cardNumber, cardDate[0], cardDate[1], cvcValue) .addLoggingToken(LOGGING_TOKEN); }
CardInputWidget extends LinearLayout { @Nullable public Card getCard() { String cardNumber = mCardNumberEditText.getCardNumber(); int[] cardDate = mExpiryDateEditText.getValidDateFields(); if (cardNumber == null || cardDate == null || cardDate.length != 2) { return null; } int requiredLength = mIsAmEx ? Card.CVC_LENGTH_AMERICAN_EXPRESS : Card.CVC_LENGTH_COMMON; String cvcValue = mCvcNumberEditText.getText().toString(); if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) { return null; } return new Card(cardNumber, cardDate[0], cardDate[1], cvcValue) .addLoggingToken(LOGGING_TOKEN); } }
CardInputWidget extends LinearLayout { @Nullable public Card getCard() { String cardNumber = mCardNumberEditText.getCardNumber(); int[] cardDate = mExpiryDateEditText.getValidDateFields(); if (cardNumber == null || cardDate == null || cardDate.length != 2) { return null; } int requiredLength = mIsAmEx ? Card.CVC_LENGTH_AMERICAN_EXPRESS : Card.CVC_LENGTH_COMMON; String cvcValue = mCvcNumberEditText.getText().toString(); if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) { return null; } return new Card(cardNumber, cardDate[0], cardDate[1], cvcValue) .addLoggingToken(LOGGING_TOKEN); } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); }
CardInputWidget extends LinearLayout { @Nullable public Card getCard() { String cardNumber = mCardNumberEditText.getCardNumber(); int[] cardDate = mExpiryDateEditText.getValidDateFields(); if (cardNumber == null || cardDate == null || cardDate.length != 2) { return null; } int requiredLength = mIsAmEx ? Card.CVC_LENGTH_AMERICAN_EXPRESS : Card.CVC_LENGTH_COMMON; String cvcValue = mCvcNumberEditText.getText().toString(); if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) { return null; } return new Card(cardNumber, cardDate[0], cardDate[1], cvcValue) .addLoggingToken(LOGGING_TOKEN); } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); @Nullable Card getCard(); void setCardInputListener(@Nullable CardInputListener listener); void setCardNumber(String cardNumber); void setExpiryDate(
            @IntRange(from = 1, to = 12) int month,
            @IntRange(from = 0, to = 9999) int year); void setCvcCode(String cvcCode); void clear(); void setEnabled(boolean isEnabled); @Override boolean isEnabled(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override void onWindowFocusChanged(boolean hasWindowFocus); }
CardInputWidget extends LinearLayout { @Nullable public Card getCard() { String cardNumber = mCardNumberEditText.getCardNumber(); int[] cardDate = mExpiryDateEditText.getValidDateFields(); if (cardNumber == null || cardDate == null || cardDate.length != 2) { return null; } int requiredLength = mIsAmEx ? Card.CVC_LENGTH_AMERICAN_EXPRESS : Card.CVC_LENGTH_COMMON; String cvcValue = mCvcNumberEditText.getText().toString(); if (StripeTextUtils.isBlank(cvcValue) || cvcValue.length() != requiredLength) { return null; } return new Card(cardNumber, cardDate[0], cardDate[1], cvcValue) .addLoggingToken(LOGGING_TOKEN); } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); @Nullable Card getCard(); void setCardInputListener(@Nullable CardInputListener listener); void setCardNumber(String cardNumber); void setExpiryDate(
            @IntRange(from = 1, to = 12) int month,
            @IntRange(from = 0, to = 9999) int year); void setCvcCode(String cvcCode); void clear(); void setEnabled(boolean isEnabled); @Override boolean isEnabled(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override void onWindowFocusChanged(boolean hasWindowFocus);  }