public void Create_ShouldReturnError_WhenCvvHasAnExpectedLength(string code) { var cvv = Cvv.Create(code); cvv.IsSuccess.Should().BeFalse(); cvv.Error.Should().Be(Errors.InvalidCvv); }
public void Create_ShouldReturnCvv(string code) { var cvv = Cvv.Create(code); cvv.IsSuccess.Should().BeTrue(); var value = cvv.GetValue(); value.Code.Should().Be(code); }
protected override int GetHashCodeCore() { unchecked { int hashCode = Number.GetHashCode(); hashCode = (hashCode * 397) ^ Cvv.GetHashCode(); hashCode = (hashCode * 397) ^ Validate.GetHashCode(); hashCode = (hashCode * 397) ^ PrintName.GetHashCode(); return(hashCode); } }
public void Can_serialize_valid_CVV() { var jsonSerializerOptions = new JsonSerializerOptions(); jsonSerializerOptions.Converters.Add(new CardCvvJsonConverter()); var input = "123"; var cvv = new Cvv(input); var json = JsonSerializer.Serialize(cvv, jsonSerializerOptions); Assert.Equal(@$ "" "{input}" "", json); }
public void CardCvv_equality_can_be_checked() { var input1 = "123"; var input2 = "5678"; var cvv1a = new Cvv(input1); var cvv1b = new Cvv(input1); var cvv2 = new Cvv(input2); Assert.Equal(cvv1a, cvv1b); Assert.NotEqual(cvv1a, cvv2); Assert.NotEqual(cvv1b, cvv2); }
public override bool Dogrulama() { if (Numara.Length != 16 || Cvv.ToString().Length != 3 || SonAy <= 0 || SonAy >= 13 || SonYil < 2018 || SonYil > 2100) // Kredi karti bilgilerini kontrol etme islemi { MessageBox.Show("Kart Bilgileri Hatalı! Ödeme Onaylanmadı."); return(false); } else { MessageBox.Show("Ödeme Onaylandı."); return(true); } }
public override async Task <Result <Guid> > Handle(Command command, CancellationToken token = default) { // This cannot fail since we validated the entire command before var price = Price.Create(command.Currency, command.Amount).GetValue(); var number = CardNumber.Create(command.Card.Number).GetValue(); var expiryDate = ExpiryDate.Create(command.Card.ExpiryMonth, command.Card.ExpiryYear).GetValue(); var cvv = Cvv.Create(command.Card.Cvv).GetValue(); var card = Card.Create(number, expiryDate, cvv, command.Card.HolderName); // Starts the async job return(Ok( await _bus.StartAsync( new MakePayment(command.MerchantId, card.GetValue(), price, command.Description ?? string.Empty), token))); }
public Validator() { RuleFor(x => Price.Create(x.Currency, x.Amount)) .Must(x => x.IsSuccess) .WithState((x, res) => res.Error); RuleFor(x => CardNumber.Create(x.Card.Number)) .Must(x => x.IsSuccess) .WithState((x, res) => res.Error); RuleFor(x => ExpiryDate.Create(x.Card.ExpiryMonth, x.Card.ExpiryYear)) .Must(x => x.IsSuccess) .WithState((x, res) => res.Error); RuleFor(x => Cvv.Create(x.Card.Cvv)) .Must(x => x.IsSuccess) .WithState((x, res) => res.Error); }
public override async Task <string> Execute(ConsumeContext <MakePayment> context) { var command = context.Message; var response = await _processor.ProcessAsync( command.Currency, command.Amount, command.CardNumber, command.ExpiryMonth, command.ExpiryYear, command.Cvv, command.CardHolderName); // We assume command sent through the bus are ALWAYS valid. In other words, the code below should never fail. var payment = Payment.Create( response.PaymentId, command.MerchantId, Card.Create( CardNumber.Create(command.CardNumber).GetValue(), ExpiryDate.Create(command.ExpiryMonth, command.ExpiryYear).GetValue(), Cvv.Create(command.Cvv).GetValue(), command.CardHolderName).GetValue(), Price.Create(command.Currency, command.Amount).GetValue(), command.Description); // This is simplistic :) if (response.Status == PaymentStatus.Approved) { payment.Approve(); } else { payment.Decline("Payment was declined"); } // Persist the payment await _repository.AddAsync(payment); // We return the Id of the created entity! return(response.PaymentId); }
private void Cvv_Completed(object sender, System.EventArgs e) { Cvv.Unfocus(); }
private void Year_Completed(object sender, System.EventArgs e) { Year.Unfocus(); Cvv.Focus(); }
public void When_CardCvv_constructor_called_with_non_empty_value_then_pan_is_created(string input) { var cvv = new Cvv(input); Assert.Equal(input, cvv.Value.Value); }
public void Create_ShouldThrowArgumentNullException_WhenCvvIsNull() { Action action = () => Cvv.Create(null); action.Should().Throw <ArgumentNullException>().WithMessage("*code*"); }