resolvePaymentSystem static method
Узнать тип платежной системы по номеру карты
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;
}