asCardBrand static method

String? asCardBrand(
  1. String? possibleCardType
)

Converts an unchecked String value to a {@link CardBrand} or {@code null}.

@param possibleCardType a String that might match a {@link CardBrand} or be empty. @return {@code null} if the input is blank, else the appropriate {@link CardBrand}.

Implementation

static String? asCardBrand(String? possibleCardType) {
  if (possibleCardType == null) {
    return null;
  }else if(possibleCardType ==""){
    return null;
  }

  if (StripeCard.americanExpress == possibleCardType) {
    return StripeCard.americanExpress;
  } else if (StripeCard.masterCard == possibleCardType) {
    return StripeCard.masterCard;
  } else if (StripeCard.dinersClub == possibleCardType) {
    return StripeCard.dinersClub;
  } else if (StripeCard.discover == possibleCardType) {
    return StripeCard.discover;
  } else if (StripeCard.jcb == possibleCardType) {
    return StripeCard.jcb;
  } else if (StripeCard.visa == possibleCardType) {
    return StripeCard.visa;
  } else if (StripeCard.unionPay == possibleCardType) {
    return StripeCard.unionPay;
  } else {
    return StripeCard.unknown;
  }
}