public void Encrypt() { CardNumber = StringEncryptionHelper.Encrypt(CardNumber, Cvv); CardHolderFullName = StringEncryptionHelper.Encrypt(CardHolderFullName, Cvv); Expiration = StringEncryptionHelper.Encrypt(Expiration, Cvv); Cvv = StringEncryptionHelper.Encrypt(Cvv); }
private async Task ValidatePaymentHistoryAddingAsync(AddPaymentHistoryDto paymentHistoryDto, CancellationToken ct) { var paymentMethodDto = await _unitOfWork.PaymentMethodRepository.GetAsync(paymentHistoryDto.PaymentMethodId, ct); if (paymentMethodDto == null) { _logger.LogInformation("Payment method with id {PaymentMethodId} not found", paymentHistoryDto.PaymentMethodId); throw new ItemNotFoundException(); } if (paymentMethodDto.AccountId != paymentHistoryDto.AccountId) { _logger.LogInformation("Access to this payment method is not allowed for account {AccountId}", paymentHistoryDto.AccountId); throw new AccessToItemForbiddenException(); } var isAlreadyPaid = await _unitOfWork.PaymentHistoryRepository.IsExistsAsync(paymentMethodDto.AccountId, paymentHistoryDto.OrderId, ct); if (isAlreadyPaid) { _logger.LogInformation("Order with Id {OrderId} already paid", paymentHistoryDto.OrderId); throw new OrderAlreadyPaidException(); } if (paymentMethodDto.Cvv != StringEncryptionHelper.Encrypt(paymentHistoryDto.Cvv)) { _logger.LogInformation("Cvv code for payment method {PaymentMethodId} is wrong", paymentHistoryDto.PaymentMethodId); throw new CvvIsWrongException(); } }