feat(withdrawal): normalize IBAN format in withdrawal requests
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m38s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m38s
- Added IbanNormalizer to validate and normalize IBAN numbers in RequestWithdrawalCommandHandler and UserWalletService. - Implemented error handling for invalid IBAN formats, ensuring compliance with expected standards. - Updated relevant methods to handle normalized IBANs for cash withdrawal requests.
This commit is contained in:
@@ -18,6 +18,7 @@ using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWalletHistory;
|
||||
using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWithdrawals;
|
||||
using CMSMicroservice.Application.UserWalletCQ.Queries.GetCustomerWithdrawalSettings;
|
||||
using CMSMicroservice.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Application.Common;
|
||||
using CMSMicroservice.Application.Common.Exceptions;
|
||||
using CMSMicroservice.Domain.Common;
|
||||
using CMSMicroservice.Domain.Enums;
|
||||
@@ -175,7 +176,18 @@ public class UserWalletService : UserWalletContract.UserWalletContractBase
|
||||
|
||||
// Update payout with withdrawal info
|
||||
payout.WithdrawalMethod = (Domain.Enums.WithdrawalMethod)request.WithdrawalMethod;
|
||||
payout.IbanNumber = request.IbanNumber;
|
||||
if (payout.WithdrawalMethod == Domain.Enums.WithdrawalMethod.Cash)
|
||||
{
|
||||
var normalizedIban = IbanNormalizer.TryNormalize(request.IbanNumber);
|
||||
if (normalizedIban is null)
|
||||
throw new RpcException(new Status(StatusCode.InvalidArgument,
|
||||
"فرمت شماره شبا معتبر نیست. باید IR و ۲۴ رقم باشد."));
|
||||
payout.IbanNumber = normalizedIban;
|
||||
}
|
||||
else
|
||||
{
|
||||
payout.IbanNumber = null;
|
||||
}
|
||||
payout.Status = Domain.Enums.CommissionPayoutStatus.WithdrawRequested;
|
||||
|
||||
await _context.SaveChangesAsync(context.CancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user