public static bool IsValid(string cardNumber, EnumBrand brand) { // Visa if (Regex.IsMatch(cardNumber, "^(4)") && ((brand & EnumBrand.Visa) != 0)) { return(cardNumber.Length == 13 || cardNumber.Length == 16); } // MasterCard if (Regex.IsMatch(cardNumber, "^(51|52|53|54|55)") && ((brand & EnumBrand.Master) != 0)) { return(cardNumber.Length == 16); } // Amex if (Regex.IsMatch(cardNumber, "^(34|37)") && ((brand & EnumBrand.Amex) != 0)) { return(cardNumber.Length == 15); } // Diners if (Regex.IsMatch(cardNumber, "^(300|301|302|303|304|305|36|38)") && ((brand & EnumBrand.Diners) != 0)) { return(cardNumber.Length == 14); } return(false); }
public CreditCard(string cardNumber, string holder, int yearExpiration, int monthExpiration, string securityCode, EnumBrand Brand) { AlterarBrand(Brand); AlterarCardNumber(cardNumber, Brand); AlterarSecurityCode(securityCode); AlterarHolder(holder); AlterarDateExpiration(yearExpiration, monthExpiration); }
private void AlterarCardNumber(string cardNumber, EnumBrand brand) { if (string.IsNullOrEmpty(cardNumber)) { throw new ArgumentException("CardNumber name is required"); } if (!CredcardValidator.IsValid(cardNumber, brand)) { throw new ArgumentException("Número de cartão é invalido"); } this.CardNumber = cardNumber; }
public Payment(string holder, string cardNumber, int yearExpiration, int monthExpiration, string securityCode, EnumBrand brand, decimal amount, int installments, string softDescriptor) { AlterarAmount(amount); AlterarInstallments(installments); AlterarSoftDescriptor(softDescriptor); AlterarCreditCard(cardNumber, holder, yearExpiration, monthExpiration, securityCode, brand); }
public CieloSale(string merchantOrderId, string customerName, string cardNumber, string holder, int yearExpiration, int monthExpiration, string securityCode, EnumBrand brand, decimal amount, int installments, string softDescriptor) { AlterarMerchantOderId(merchantOrderId); AlterarCustomer(customerName); AlterarPayment(holder, cardNumber, yearExpiration, monthExpiration, securityCode, brand, amount, installments, softDescriptor); }
private void AlterarPayment(string holder, string cardNumber, int yearExpiration, int monthExpiration, string securityCode, EnumBrand brand, decimal amount, int installments, string softDescriptor) { this.Payment = new Payment(holder, cardNumber, yearExpiration, monthExpiration, securityCode, brand, amount, installments, softDescriptor); }
private void AlterarBrand(EnumBrand brand) { this.Brand = brand.ToString(); }
private void AlterarCreditCard(string cardNumber, string holder, int yearExpiration, int monthExpiration, string securityCode, EnumBrand brand) { this.CreditCard = new CreditCard(cardNumber, holder, yearExpiration, monthExpiration, securityCode, brand); }