feat(wallet): add credit wallet charge functionality and update payment callback
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
- Introduced methods for initiating and verifying credit wallet charges in the WalletService. - Updated PaymentCallback.razor to handle credit wallet charge verification. - Added a button for charging the credit wallet in Wallet.razor. - Updated route constants to include the new credit wallet charge route. These changes enhance the wallet functionality by allowing users to charge their credit wallets and verify transactions seamlessly.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class ChargeCreditWallet : ComponentBase
|
||||
{
|
||||
private bool _isProcessing;
|
||||
private long _chargeAmount;
|
||||
private string? _paymentResult;
|
||||
|
||||
private readonly long[] _presetAmounts = { 500_000, 1_000_000, 5_000_000, 10_000_000, 20_000_000, 50_000_000 };
|
||||
|
||||
[SupplyParameterFromQuery(Name = "payment")]
|
||||
public string? PaymentQueryParam { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_paymentResult = PaymentQueryParam;
|
||||
}
|
||||
|
||||
private async Task StartCreditCharge()
|
||||
{
|
||||
if (_chargeAmount <= 0 || _isProcessing) return;
|
||||
|
||||
_isProcessing = true;
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{
|
||||
var (success, gatewayUrl, error) = await WalletService.InitiateCreditChargeAsync(_chargeAmount);
|
||||
|
||||
if (success && !string.IsNullOrEmpty(gatewayUrl))
|
||||
{
|
||||
Navigation.NavigateTo(gatewayUrl, forceLoad: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(error ?? "خطا در ایجاد درخواست پرداخت", Severity.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isProcessing = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatToman(long toman)
|
||||
=> string.Format("{0:N0} تومان", toman);
|
||||
}
|
||||
Reference in New Issue
Block a user