resolvePaymentSystem static method

CardPaymentSystem resolvePaymentSystem(
  1. String cardNumber
)

Узнать тип платежной системы по номеру карты

Implementation

static CardPaymentSystem resolvePaymentSystem(String cardNumber) {
  if (cardNumber.length >= 4) {
    if (CardSettings.mirPattern.hasMatch(cardNumber)) {
      return CardPaymentSystem.mir;
    }

    final String firstChar = cardNumber[0];
    if (firstChar == '2' || firstChar == '5') {
      return CardPaymentSystem.masterCard;
    }

    if (firstChar == '4') {
      return CardPaymentSystem.visa;
    }

    if (firstChar == '6') {
      return CardPaymentSystem.mestro;
    }
  }

  return CardPaymentSystem.unknown;
}