@Test public void shouldFailValidateCVCIfVisaAndLength2() { Card card = new Card("4242 4242 4242 4242", null, null, "12"); assertFalse(card.validateCVC()); }
public boolean validateCVC() { if (StripeTextUtils.isBlank(cvc)) { return false; } String cvcValue = cvc.trim(); String updatedType = getBrand(); boolean validLength = (updatedType == null && cvcValue.length() >= 3 && cvcValue.length() <= 4) || (AMERICAN_EXPRESS.equals(updatedType) && cvcValue.length() == 4) || cvcValue.length() == 3; return ModelUtils.isWholePositiveNumber(cvcValue) && validLength; }
Card extends StripeJsonModel implements StripePaymentSource { public boolean validateCVC() { if (StripeTextUtils.isBlank(cvc)) { return false; } String cvcValue = cvc.trim(); String updatedType = getBrand(); boolean validLength = (updatedType == null && cvcValue.length() >= 3 && cvcValue.length() <= 4) || (AMERICAN_EXPRESS.equals(updatedType) && cvcValue.length() == 4) || cvcValue.length() == 3; return ModelUtils.isWholePositiveNumber(cvcValue) && validLength; } }
Card extends StripeJsonModel implements StripePaymentSource { public boolean validateCVC() { if (StripeTextUtils.isBlank(cvc)) { return false; } String cvcValue = cvc.trim(); String updatedType = getBrand(); boolean validLength = (updatedType == null && cvcValue.length() >= 3 && cvcValue.length() <= 4) || (AMERICAN_EXPRESS.equals(updatedType) && cvcValue.length() == 4) || cvcValue.length() == 3; return ModelUtils.isWholePositiveNumber(cvcValue) && validLength; } Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String brand,
            @Size(4) String last4,
            String fingerprint,
            String funding,
            String country,
            String currency,
            String id);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String currency);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc); private  Card(Builder builder); }
Card extends StripeJsonModel implements StripePaymentSource { public boolean validateCVC() { if (StripeTextUtils.isBlank(cvc)) { return false; } String cvcValue = cvc.trim(); String updatedType = getBrand(); boolean validLength = (updatedType == null && cvcValue.length() >= 3 && cvcValue.length() <= 4) || (AMERICAN_EXPRESS.equals(updatedType) && cvcValue.length() == 4) || cvcValue.length() == 3; return ModelUtils.isWholePositiveNumber(cvcValue) && validLength; } Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String brand,
            @Size(4) String last4,
            String fingerprint,
            String funding,
            String country,
            String currency,
            String id);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String currency);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc); private  Card(Builder builder); @Nullable @CardBrand static String asCardBrand(@Nullable String possibleCardType); @Nullable @FundingType static String asFundingType(@Nullable String possibleFundingType); @Nullable static Card fromString(String jsonString); @Nullable static Card fromJson(JSONObject jsonObject); boolean validateCard(); boolean validateNumber(); boolean validateExpiryDate(); boolean validateCVC(); boolean validateExpMonth(); String getNumber(); @NonNull List<String> getLoggingTokens(); @NonNull Card addLoggingToken(@NonNull String loggingToken); @Deprecated void setNumber(String number); String getCVC(); @Deprecated void setCVC(String cvc); @Nullable @IntRange(from = 1, to = 12) Integer getExpMonth(); @Deprecated void setExpMonth(@Nullable @IntRange(from = 1, to = 12) Integer expMonth); Integer getExpYear(); @Deprecated void setExpYear(Integer expYear); String getName(); void setName(String name); String getAddressLine1(); void setAddressLine1(String addressLine1); String getAddressLine2(); void setAddressLine2(String addressLine2); String getAddressCity(); void setAddressCity(String addressCity); String getAddressZip(); void setAddressZip(String addressZip); String getAddressState(); void setAddressState(String addressState); String getAddressCountry(); void setAddressCountry(String addressCountry); String getCurrency(); void setCurrency(String currency); String getLast4(); @Deprecated @CardBrand String getType(); @CardBrand String getBrand(); String getFingerprint(); @Nullable @FundingType String getFunding(); String getCountry(); @Override String getId(); @Nullable String getAddressLine1Check(); @Nullable String getAddressZipCheck(); @Nullable String getCustomerId(); @Nullable String getCvcCheck(); @NonNull @Override JSONObject toJson(); @NonNull @Override Map<String, Object> toMap(); }
Card extends StripeJsonModel implements StripePaymentSource { public boolean validateCVC() { if (StripeTextUtils.isBlank(cvc)) { return false; } String cvcValue = cvc.trim(); String updatedType = getBrand(); boolean validLength = (updatedType == null && cvcValue.length() >= 3 && cvcValue.length() <= 4) || (AMERICAN_EXPRESS.equals(updatedType) && cvcValue.length() == 4) || cvcValue.length() == 3; return ModelUtils.isWholePositiveNumber(cvcValue) && validLength; } Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String brand,
            @Size(4) String last4,
            String fingerprint,
            String funding,
            String country,
            String currency,
            String id);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc,
            String name,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressState,
            String addressZip,
            String addressCountry,
            String currency);  Card(
            String number,
            Integer expMonth,
            Integer expYear,
            String cvc); private  Card(Builder builder); @Nullable @CardBrand static String asCardBrand(@Nullable String possibleCardType); @Nullable @FundingType static String asFundingType(@Nullable String possibleFundingType); @Nullable static Card fromString(String jsonString); @Nullable static Card fromJson(JSONObject jsonObject); boolean validateCard(); boolean validateNumber(); boolean validateExpiryDate(); boolean validateCVC(); boolean validateExpMonth(); String getNumber(); @NonNull List<String> getLoggingTokens(); @NonNull Card addLoggingToken(@NonNull String loggingToken); @Deprecated void setNumber(String number); String getCVC(); @Deprecated void setCVC(String cvc); @Nullable @IntRange(from = 1, to = 12) Integer getExpMonth(); @Deprecated void setExpMonth(@Nullable @IntRange(from = 1, to = 12) Integer expMonth); Integer getExpYear(); @Deprecated void setExpYear(Integer expYear); String getName(); void setName(String name); String getAddressLine1(); void setAddressLine1(String addressLine1); String getAddressLine2(); void setAddressLine2(String addressLine2); String getAddressCity(); void setAddressCity(String addressCity); String getAddressZip(); void setAddressZip(String addressZip); String getAddressState(); void setAddressState(String addressState); String getAddressCountry(); void setAddressCountry(String addressCountry); String getCurrency(); void setCurrency(String currency); String getLast4(); @Deprecated @CardBrand String getType(); @CardBrand String getBrand(); String getFingerprint(); @Nullable @FundingType String getFunding(); String getCountry(); @Override String getId(); @Nullable String getAddressLine1Check(); @Nullable String getAddressZipCheck(); @Nullable String getCustomerId(); @Nullable String getCvcCheck(); @NonNull @Override JSONObject toJson(); @NonNull @Override Map<String, Object> toMap(); static final String AMERICAN_EXPRESS; static final String DISCOVER; static final String JCB; static final String DINERS_CLUB; static final String VISA; static final String MASTERCARD; static final String UNKNOWN; static final int CVC_LENGTH_AMERICAN_EXPRESS; static final int CVC_LENGTH_COMMON; static final String FUNDING_CREDIT; static final String FUNDING_DEBIT; static final String FUNDING_PREPAID; static final String FUNDING_UNKNOWN; static final Map<String , Integer> BRAND_RESOURCE_MAP; static final String[] PREFIXES_AMERICAN_EXPRESS; static final String[] PREFIXES_DISCOVER; static final String[] PREFIXES_JCB; static final String[] PREFIXES_DINERS_CLUB; static final String[] PREFIXES_VISA; static final String[] PREFIXES_MASTERCARD; static final int MAX_LENGTH_STANDARD; static final int MAX_LENGTH_AMERICAN_EXPRESS; static final int MAX_LENGTH_DINERS_CLUB; }