diff --git a/Sheaft.Application.Handlers/Commands/PaymentCommandsHandler.cs b/Sheaft.Application.Handlers/Commands/PaymentCommandsHandler.cs index b08d1f16a..c8b103e76 100644 --- a/Sheaft.Application.Handlers/Commands/PaymentCommandsHandler.cs +++ b/Sheaft.Application.Handlers/Commands/PaymentCommandsHandler.cs @@ -79,6 +79,7 @@ public async Task> Handle(UpdateBankAccountCommand request, Cancell return Failed(resetResult.Exception); bankAccount.SetIdentifier(string.Empty); + await _context.SaveChangesAsync(token); } bankAccount.SetAddress(address); @@ -87,8 +88,6 @@ public async Task> Handle(UpdateBankAccountCommand request, Cancell bankAccount.SetIban(request.IBAN); bankAccount.SetBic(request.BIC); - await _context.SaveChangesAsync(token); - var result = await _pspService.CreateBankIbanAsync(bankAccount, token); if (!result.Success) return Failed(result.Exception); diff --git a/Sheaft.Infrastructure.Services/PspService.cs b/Sheaft.Infrastructure.Services/PspService.cs index e6e99ee01..b747e8192 100644 --- a/Sheaft.Infrastructure.Services/PspService.cs +++ b/Sheaft.Infrastructure.Services/PspService.cs @@ -183,7 +183,7 @@ public async Task> CreateBankIbanAsync(BankAccount payment, Cance if (string.IsNullOrWhiteSpace(payment.User.Identifier)) return BadRequest(MessageKind.PsP_CannotCreate_Bank_User_Not_Exists); - if (payment.Identifier.Length > 0) + if (!string.IsNullOrWhiteSpace(payment.Identifier) && payment.Identifier.Length > 0) return BadRequest(MessageKind.PsP_CannotCreate_Bank_Already_Exists); await EnsureAccessTokenIsValidAsync(token);