A secure and extensible digital wallet API built with Java and Spring Boot.
Customers can manage their own wallets, deposits, and withdrawals. Employees can perform operations on behalf of any customer.
- ✅ Create wallets with different currencies (TRY, USD, EUR)
- ✅ Deposit and withdraw money with business rules
- ✅ Approve or deny large transactions
- ✅ Role-based access control (CUSTOMER vs EMPLOYEE)
- ✅ Integrated Swagger documentation for API testing
- ✅ H2 in-memory database
- ✅ Unit and integration test coverage
- ✅ Secure endpoints with Spring Security
- Java 21
- Spring Boot 3.x
- Spring Security
- Spring Data JPA (H2)
- Lombok
- Swagger (SpringDoc OpenAPI)
- JUnit 5 & Mockito
- Maven
git clone <repo-url>
cd digital-wallet
./mvnw clean install
./mvnw spring-boot:run
http://localhost:8080/h2-console
- JDBC URL:
jdbc:h2:mem:digitalwallet
- Username:
digitalwallet
- Password: (leave empty)
Role | Username | Password |
---|---|---|
CUSTOMER | 12345678901 |
12345678901 |
EMPLOYEE | employee1 |
employee1 |
- CUSTOMERS can only manage their own wallets and transactions
- EMPLOYEES can access and manage all customer data
- Amount ≤ 1000 → Automatically
APPROVED
- Amount > 1000 → Saved as
PENDING
- APPROVED → added to both
balance
andusableBalance
- PENDING → added only to
balance
- APPROVED → added to both
- Amount ≤ 1000 → Automatically
APPROVED
- Amount > 1000 → Saved as
PENDING
- APPROVED → deducted from both
balance
andusableBalance
- PENDING → deducted only from
usableBalance
- APPROVED → deducted from both
APPROVED
→ Applies the transaction effect to walletDENIED
→ Cancels the transaction, reverts balances if necessary
Accessible at:
http://localhost:8080/swagger-ui/index.html
POST /api/wallets/create/{customerId}
Content-Type: application/json
{
"walletName": "My Wallet",
"currency": "TRY",
"activeForShopping": true,
"activeForWithdraw": true
}
POST /api/transactions/deposit
{
"walletId": 1,
"amount": 1500,
"oppositePartyType": "IBAN",
"oppositeParty": "TR123..."
}
POST /api/transactions/withdraw
{
"walletId": 1,
"amount": 500,
"oppositePartyType": "PAYMENT",
"oppositeParty": "PAY_ABC_001"
}
POST /api/transactions/approve
{
"transactionId": 10,
"status": "APPROVED"
}
./mvnw test
Includes:
- ✅ Unit tests for services
- ✅ Integration tests for controllers and repositories
com.digitalwallet
├── controller # REST endpoints
├── dto # Data Transfer Objects
├── service # Business logic
├── repository # JPA repositories
├── entity # Domain models
├── security # Spring Security config
├── config # Swagger, database configs
└── util # Common utility classes
- Basic Authentication
- Dynamic login:
- CUSTOMERS are authenticated via TCKN (used as both username & password)
- EMPLOYEES are authenticated via in-memory credentials
- Method-level access control with role checks
- Passwords are not encoded – this is for development only.
- Production usage should replace this with
BCryptPasswordEncoder
or JWT-based auth. - Database is in-memory; use PostgreSQL or MySQL for persistence.
This project is licensed under the MIT License.
Feel free to fork and submit pull requests. Feedback is always welcome!