feat: Implement Magic Wallet functionality
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m36s

- Added ClubMembershipCycle entity and DbSet to IApplicationDbContext.
- Updated VAT rate from 9% to 10% in VatCalculator and related areas.
- Introduced Magic Wallet settings in SystemConstants.
- Enhanced UserWallet entity to support Magic Wallet features.
- Updated TransactionType enum to include Magic Wallet transactions.
- Configured UserWallet to handle Magic Wallet properties in ApplicationDbContext.
- Implemented OrmCommissionCalculationStrategy to exclude Magic Wallet users from commission calculations.
- Added Protobuf definitions for Magic Wallet methods and responses.
- Created PaymentCallbackController endpoint for handling Magic Wallet charge callbacks.
- Updated UserOrderService to manage Magic Wallet state transitions.
- Developed UserWalletService to support Magic Wallet operations.
- Created ChargeMagicWalletCommand and its handler for initiating Magic Wallet charges.
- Implemented VerifyMagicWalletChargeCommand and handler for payment verification.
- Added validation for ChargeMagicWalletCommand.
- Established ClubMembershipCycle configuration for EF Core.
- Introduced WalletMode enum to differentiate between Normal and Magic modes.
This commit is contained in:
masoodafar-web
2026-02-21 19:50:28 +03:30
parent 04e8c49fa7
commit 2a569a024f
23 changed files with 914 additions and 22 deletions
@@ -1,5 +1,6 @@
using CMSMicroservice.Application.Common.Interfaces;
using CMSMicroservice.Application.DiscountShopCQ.Commands.CompleteOrderPayment;
using CMSMicroservice.Application.WalletCQ.Commands.VerifyMagicWalletCharge;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -143,4 +144,46 @@ public class PaymentCallbackController : ControllerBase
$"{frontOfficeBaseUrl}/discount-store/order/{orderId}?payment=error");
}
}
/// <summary>
/// Callback برای شارژ کیف‌پول جادویی — زرین‌پال بعد از پرداخت کاربر را اینجا برمی‌گرداند
/// </summary>
[HttpGet("/api/wallet/verify-magic-charge")]
public async Task<IActionResult> MagicChargeCallback(
[FromQuery(Name = "Authority")] string? authority,
[FromQuery(Name = "Status")] string? status,
CancellationToken cancellationToken)
{
var frontOfficeBaseUrl = _configuration["FrontOfficeBaseUrl"] ?? "https://localhost:5268";
_logger.LogInformation(
"Magic charge callback received: Authority={Authority}, Status={Status}",
authority, status);
try
{
if (string.IsNullOrEmpty(authority))
{
_logger.LogError("Magic charge callback: Authority is missing");
return Redirect($"{frontOfficeBaseUrl}/magic-wallet?payment=error&reason=no-authority");
}
var result = await _sender.Send(new VerifyMagicWalletChargeCommand
{
Authority = authority,
Status = status ?? "NOK"
}, cancellationToken);
_logger.LogInformation(
"Magic charge completed successfully. Authority={Authority}",
authority);
return Redirect($"{frontOfficeBaseUrl}/magic-wallet?payment=success");
}
catch (Exception ex)
{
_logger.LogError(ex, "Magic charge callback error. Authority={Authority}", authority);
return Redirect($"{frontOfficeBaseUrl}/magic-wallet?payment=failed");
}
}
}