public void Validate(object sender) { _validParts.Clear(); if (!_isTokenPayment) { var network = _cardNetworkDiscoverer.DiscoverCardNetwork(cardNumberEntry.Text ?? string.Empty); if (network.GetCardNetworkType() != _currentDiscoveredNetwork.GetCardNetworkType()) { _currentDiscoveredNetwork = network; UpdateCardIcons(); UpdateCvvMaxLength(); UpdateCardNumberFormat(); UpdateCardNumberMaxLength(); _currentDiscoveredNetwork.SetAvsEnabled(Judo.AvsEnabled); startDateEntry.IsVisible = _currentDiscoveredNetwork.ShouldDisplayStartDate(); issueNumberEntry.IsVisible = _currentDiscoveredNetwork.ShouldDisplayIssueNumber(); } ValidatePart(cardNumberEntry, new CardNumberValidator(), CardPart.CardNumber); ValidatePart(expiryDateEntry, new ExpiryDateValidator(DateTime.Now), CardPart.ExpiryDate); ValidatePart(startDateEntry, new StartDateValidator(DateTime.Now), CardPart.StartDate); ValidatePart(issueNumberEntry, new IssueNumberValidator(), CardPart.IssueNumber); } ValidatePart(cvvEntry, new SecurityCodeValidator(), CardPart.SecurityCode); ValidatePart(postcodeEntry, new PostcodeValidator(_currentDiscoveredCountry), CardPart.Postcode); DisplayAvsFieldIfAvsEnabledAndPrimaryPartsAreMet(); DisplayPaymentButtonIfValidPartsMet(); var entry = (JudoEntry)sender; Advance(entry, string.IsNullOrWhiteSpace(entry.Error)); }
void SetUpDefaults(TokenPaymentDefaultsViewModel defaults) { cardNumberEntry.Format = ""; cardNumberEntry.Text = defaults.MaskedCardNumber; cardImage.Opacity = !string.IsNullOrWhiteSpace(defaults.MaskedCardNumber) ? 1 : 0.5; expiryDateEntry.Text = defaults.ExpiryDate; expiryDateEntry.Format = ""; cardNumberEntry.IsEnabled = false; expiryDateEntry.IsEnabled = false; startDateEntry.IsEnabled = false; issueNumberEntry.IsEnabled = false; _currentDiscoveredNetwork = defaults.CardNetork; UpdateCardIcons(); UpdateCvvMaxLength(); _currentDiscoveredNetwork.SetAvsEnabled(Judo.AvsEnabled); }