diff --git a/src/FrontOffice.Main/Pages/Checkout.razor.cs b/src/FrontOffice.Main/Pages/Checkout.razor.cs index 24b12f8..aeaf1a6 100644 --- a/src/FrontOffice.Main/Pages/Checkout.razor.cs +++ b/src/FrontOffice.Main/Pages/Checkout.razor.cs @@ -1,7 +1,6 @@ using CMSMicroservice.Protobuf.Protos.Package; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; using MudBlazor; using Severity = MudBlazor.Severity; @@ -11,7 +10,6 @@ public partial class Checkout { [Inject] private PackageService PackageService { get; set; } = default!; [Inject] private PackageContract.PackageContractClient PackageClient { get; set; } = default!; - [Inject] private IJSRuntime JSRuntime { get; set; } = default!; [Parameter] public long? PackageId { get; set; } diff --git a/src/FrontOffice.Main/Pages/Profile/WithdrawalRequests.razor.cs b/src/FrontOffice.Main/Pages/Profile/WithdrawalRequests.razor.cs index 5866666..2370755 100644 --- a/src/FrontOffice.Main/Pages/Profile/WithdrawalRequests.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/WithdrawalRequests.razor.cs @@ -58,8 +58,19 @@ public partial class WithdrawalRequests : ComponentBase try { _isSubmittingWithdrawal = true; - _withdrawIban=_withdrawIban!.Trim().ToUpper().Replace("IR", "").Replace(" ", ""); - await WalletService.RequestWithdrawalAsync(_selectedPayout.Id, _withdrawMethod, "IR"+_withdrawIban); + + string? normalizedIban = null; + if (_withdrawMethod == WithdrawalMethodClient.Cash) + { + normalizedIban = NormalizeIranianIban(_withdrawIban); + if (normalizedIban is null) + { + Snackbar.Add("فرمت شماره شبا معتبر نیست. باید IR و ۲۴ رقم باشد (خط تیره اختیاری است).", Severity.Warning); + return; + } + } + + await WalletService.RequestWithdrawalAsync(_selectedPayout.Id, _withdrawMethod, normalizedIban); Snackbar.Add("درخواست برداشت ثبت شد.", Severity.Success); // بروزرسانی لیست @@ -125,4 +136,26 @@ public partial class WithdrawalRequests : ComponentBase 1 => "الماس", _ => "-" }; + + /// + /// فاصله و خط تیره را حذف می‌کند و شبا را به شکل IR + ۲۴ رقم برمی‌گرداند. + /// + private static string? NormalizeIranianIban(string? iban) + { + if (string.IsNullOrWhiteSpace(iban)) + return null; + + var normalized = iban.Trim().ToUpperInvariant() + .Replace(" ", "", StringComparison.Ordinal) + .Replace("-", "", StringComparison.Ordinal); + + if (normalized.StartsWith("IR", StringComparison.Ordinal)) + normalized = normalized[2..]; + + normalized = "IR" + normalized; + + return System.Text.RegularExpressions.Regex.IsMatch(normalized, @"^IR\d{24}$") + ? normalized + : null; + } }