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:
@@ -24,6 +24,7 @@ public static class RouteConstants
|
||||
public const string Wallet = "/profile/wallet";
|
||||
public const string MagicWallet = "/profile/magic-wallet";
|
||||
public const string ChargeDiscountWallet = "/profile/charge-discount-wallet";
|
||||
public const string ChargeCreditWallet = "/profile/charge-credit-wallet";
|
||||
public const string WithdrawalRequests = "/profile/withdrawal-requests";
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,26 @@ public class WalletService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string? GatewayUrl, string? Error)> InitiateCreditChargeAsync(long amount)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.InitiateCreditChargeAsync(new InitiateCreditChargeRequest
|
||||
{
|
||||
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 ?? "خطا در ارتباط با سرور");
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Wallet Verify Methods =============
|
||||
|
||||
public async Task<(bool Success, string Message)> VerifyMagicChargeAsync(string authority, string status)
|
||||
@@ -304,6 +324,24 @@ public class WalletService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string Message)> VerifyCreditChargeAsync(string authority, string status)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.VerifyCreditChargeAsync(new VerifyWalletChargeRequest
|
||||
{
|
||||
Authority = authority,
|
||||
Status = status
|
||||
});
|
||||
|
||||
return (response.Success, response.Message);
|
||||
}
|
||||
catch (Grpc.Core.RpcException ex)
|
||||
{
|
||||
return (false, ex.Status.Detail ?? "خطا در بررسی وضعیت پرداخت");
|
||||
}
|
||||
}
|
||||
|
||||
public int GetWalletMode()
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user