Wallet Service .NET
Wallet and Point Account management service for GoodGo Platform.
Overview
The Wallet Service provides comprehensive wallet and loyalty points management with:
- Wallet Management - Create, deposit, withdraw, transfer funds
- Escrow Module - Hold, commit, and release funds (for Promotion Service)
- Point Account - Earn, spend, and track loyalty points
- Transaction History - Full audit trail of all transactions
- Multi-Currency Support - VND, USD, PPoint with exchange capabilities
- Currency Exchange - Convert between currencies with configurable rates
- Admin Backoffice - Full admin APIs for wallet/points management
- Domain-Driven Design - Clean Architecture with CQRS pattern
Tech Stack
| Component |
Technology |
| Framework |
.NET 10 |
| Database |
PostgreSQL (EF Core) |
| CQRS |
MediatR |
| Validation |
FluentValidation |
| API Docs |
Swagger/OpenAPI |
| Logging |
Serilog |
Prerequisites
Quick Start
1. Configure Environment
2. Run with Docker
3. Run Locally
API Endpoints
Wallet APIs
| Method |
Endpoint |
Description |
POST |
/api/v1/wallets |
Create new wallet |
GET |
/api/v1/wallets/{userId} |
Get wallet by user ID |
POST |
/api/v1/wallets/{userId}/deposit |
Deposit funds |
POST |
/api/v1/wallets/{userId}/withdraw |
Withdraw funds |
GET |
/api/v1/wallets/{userId}/transactions |
Get transaction history |
Escrow/Hold APIs
| Method |
Endpoint |
Description |
POST |
/api/v1/wallets/{walletId}/holds |
Create escrow hold |
GET |
/api/v1/wallets/{walletId}/holds/{holdId} |
Get hold details |
POST |
/api/v1/wallets/{walletId}/holds/{holdId}/execute |
Execute hold (deduct funds) |
POST |
/api/v1/wallets/{walletId}/holds/{holdId}/release |
Release hold (return funds) |
POST |
/api/v1/wallets/{walletId}/holds/{holdId}/cancel |
Cancel hold |
Points APIs
| Method |
Endpoint |
Description |
POST |
/api/v1/points |
Create point account |
GET |
/api/v1/points/{userId} |
Get point account |
POST |
/api/v1/points/{userId}/earn |
Earn points |
POST |
/api/v1/points/{userId}/spend |
Spend points |
GET |
/api/v1/points/{userId}/transactions |
Get point transactions |
Admin Wallet APIs
| Method |
Endpoint |
Description |
GET |
/api/v1/admin/wallets |
Get all wallets (paginated) |
GET |
/api/v1/admin/wallets/{walletId} |
Get wallet details |
POST |
/api/v1/admin/wallets/{walletId}/freeze |
Freeze wallet |
POST |
/api/v1/admin/wallets/{walletId}/unfreeze |
Unfreeze wallet |
POST |
/api/v1/admin/wallets/{walletId}/adjust |
Adjust balance |
GET |
/api/v1/admin/wallets/statistics |
Get wallet statistics |
GET |
/api/v1/admin/wallets/search |
Search wallets |
Admin Points APIs
| Method |
Endpoint |
Description |
GET |
/api/v1/admin/points |
Get all point accounts |
GET |
/api/v1/admin/points/{accountId} |
Get point account details |
POST |
/api/v1/admin/points/{accountId}/adjust |
Adjust points |
POST |
/api/v1/admin/points/{accountId}/bonus |
Grant bonus points |
GET |
/api/v1/admin/points/statistics |
Get points statistics |
GET |
/api/v1/admin/points/search |
Search point accounts |
Health Endpoints
| Endpoint |
Purpose |
/health |
Full health status |
/health/live |
Liveness probe (K8s) |
/health/ready |
Readiness probe (K8s) |
Multi-Currency Support
Wallet supports multiple currency types with exchange capabilities:
| Currency |
Code |
Base Rate to VND |
| Vietnamese Dong |
VND |
1 |
| US Dollar |
USD |
25,000 |
| Loyalty Points |
PPoint |
1,000 |
Currency Exchange
Project Structure
Domain Model
Wallet Aggregate
Point Account Aggregate
Testing
Test Results
- 23 tests total
- 20 unit tests (Wallet, PointAccount domain)
- 3 functional tests (Health endpoints)
Configuration
Environment Variables
| Variable |
Description |
Required |
DATABASE_URL |
PostgreSQL connection |
Yes |
ASPNETCORE_ENVIRONMENT |
Environment |
No (default: Development) |
JWT_AUTHORITY |
JWT issuer URL |
Yes (for auth) |
appsettings.json
Database Migrations
Deployment
Docker Build
Docker Compose
Service is registered in deployments/local/docker-compose.yml with Traefik routing.
Resources
License
Proprietary - GoodGo Platform