diff --git a/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs b/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs index a334ee0..bdab090 100644 --- a/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs +++ b/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs @@ -8,6 +8,7 @@ using Nexus.Sdk.Shared.Requests; using Nexus.Sdk.Token; using Nexus.Sdk.Token.Responses; +using stellar_dotnet_sdk; namespace Core.Infrastructure.Nexus.Repositories { @@ -31,14 +32,18 @@ public async Task CreateAsync(Customer customer, string? ip = null, Cancellation throw new CustomErrorsException(NexusErrorCodes.ExistingProperty.ToString(), customer.CustomerCode, Constants.NexusErrorMessages.ExistingCode); } + var encodedEmail = Uri.EscapeDataString(customer.Email.ToLower().Trim()); + var query = new Dictionary { - { "Email", customer.Email.ToLower().Trim() } + { "Email", encodedEmail } }; var existingCustomersWithEmail = await _tokenServer.Customers.Get(query); - if (existingCustomersWithEmail != null && existingCustomersWithEmail.Records.Any(existingCustomer => existingCustomer.Status != CustomerStatus.DELETED.ToString())) + if (existingCustomersWithEmail != null + && existingCustomersWithEmail.Records.Any() + && existingCustomersWithEmail.Records.Any(existingCustomer => existingCustomer.Status != CustomerStatus.DELETED.ToString())) { throw new CustomErrorsException(NexusErrorCodes.ExistingProperty.ToString(), customer.Email, Constants.NexusErrorMessages.ExistingEmail); }