feat: implement Magic Wallet feature with charging and status display
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 6m25s

This commit is contained in:
masoodafar-web
2026-02-21 19:50:43 +03:30
parent c08d776ecc
commit 104e4df1a6
9 changed files with 368 additions and 8 deletions
@@ -25,6 +25,16 @@ public enum WithdrawalMethodClient
}
public record WithdrawalSettings(long MinWithdrawalAmount);
public record MagicWalletStatus(
int WalletMode,
long MagicTotalDeposited,
long MagicTotalCredited,
long MagicMaxDeposit,
long MagicRemainingDeposit,
long Balance,
DateTime? MagicActivatedAt
);
public class WalletService
{
private readonly CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient _client;
@@ -183,4 +193,64 @@ public class WalletService
return new WithdrawalSettings(0);
}
}
// ============= Magic Wallet =============
public async Task<MagicWalletStatus> GetMagicWalletStatusAsync()
{
try
{
var response = await _client.GetMagicWalletStatusAsync(new Empty());
DateTime? activatedAt = response.MagicActivatedAt != null
? response.MagicActivatedAt.ToDateTime().ToLocalTime()
: null;
return new MagicWalletStatus(
response.WalletMode,
response.MagicTotalDeposited,
response.MagicTotalCredited,
response.MagicMaxDeposit,
response.MagicRemainingDeposit,
response.Balance,
activatedAt
);
}
catch
{
return new MagicWalletStatus(0, 0, 0, 0, 0, 0, null);
}
}
public async Task<(bool Success, string? GatewayUrl, string? Error)> InitiateMagicChargeAsync(long amount)
{
try
{
var response = await _client.InitiateMagicChargeAsync(new InitiateMagicChargeRequest
{
Amount = amount
});
if (response.IsSuccess)
return (true, response.GatewayUrl, null);
return (false, null, response.ErrorMessage);
}
catch (Grpc.Core.RpcException ex)
{
return (false, null, ex.Status.Detail ?? "خطا در ارتباط با سرور");
}
}
public int GetWalletMode()
{
try
{
var response = _client.GetCustomerWallet(new Empty());
return response.WalletMode;
}
catch
{
return 0;
}
}
}