Merge branch 'kub-stage' into production
Build and Deploy to Production / build-and-deploy (push) Successful in 8m14s
Build and Deploy to Production / build-and-deploy (push) Successful in 8m14s
This commit is contained in:
@@ -173,6 +173,8 @@ public partial class Checkout
|
||||
|
||||
private async Task ProcessPayment()
|
||||
{
|
||||
if (_isProcessingPayment) return;
|
||||
|
||||
if (!CanProceedToPayment || _selectedPackage == null || _selectedAddress == null)
|
||||
{
|
||||
Snackbar.Add("لطفاً پکیج و آدرس را انتخاب کنید.", Severity.Warning);
|
||||
|
||||
@@ -91,6 +91,8 @@
|
||||
private string _message = string.Empty;
|
||||
private long _transactionId;
|
||||
private long _walletBalance;
|
||||
private bool _verifyCompleted;
|
||||
private readonly SemaphoreSlim _verifyGate = new(1, 1);
|
||||
|
||||
// دکمههای بازگشت بسته به نوع پرداخت
|
||||
private string _successReturnUrl = "/profile";
|
||||
@@ -100,9 +102,29 @@
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
if (firstRender && !_verifyCompleted)
|
||||
{
|
||||
await VerifyPaymentOnceAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blazor Server may invoke render/verify twice in quick succession — gate with semaphore.
|
||||
/// </summary>
|
||||
private async Task VerifyPaymentOnceAsync()
|
||||
{
|
||||
if (_verifyCompleted) return;
|
||||
|
||||
await _verifyGate.WaitAsync();
|
||||
try
|
||||
{
|
||||
if (_verifyCompleted) return;
|
||||
await VerifyPayment();
|
||||
_verifyCompleted = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_verifyGate.Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user