PHP Developer Assignment
Assignment Title
Mini Wallet & Payment Management System
Objective
Build a scalable and logically strong backend system where users can manage wallets,
transfer money, view transaction history, and handle concurrency and validations properly.
This assignment evaluates:
- Architecture understanding
- Database design
- API handling
- Transaction management
- Code quality
- Edge case handling
- Optimization thinking
1. User Module
Features:
- User Registration
- Login API (JWT/Sanctum)
- Profile API
Fields:
- name
- email
- mobile
- password
2. Wallet Module
Each user should have:
- Main Wallet Balance
- Reward Balance
APIs:
- Get Wallet Balance
- Add Money
- Deduct Money
Conditions:
- Negative balance should not be allowed
- Proper validations are required
- Decimal precision must be maintained
3. Wallet Transfer Module (Important)
User A can transfer money to User B.
Rules:
- Sender balance must be sufficient
- Transfer should be atomic
- Double debit issue should not occur
- Transaction rollback should be handled properly
Mandatory:
- Use DB Transactions
- Use Row Locking (FOR UPDATE) or Laravel locking
4. Transaction History
Maintain records for:
- credit
- debit
- transfer
- refund
APIs:
- Paginated transaction history
- Filter by type, date range, and amount range
5. Payment Gateway Simulation
Build a fake payment gateway integration.
Flow:
- User creates add money request
- Payment remains in pending state initially
- Simulated callback/webhook updates status
- Wallet balance updates on successful payment
States:
- pending
- success
- failed
Important:
- Duplicate callbacks must be handled
6. Refund Logic
If transfer fails:
- Automatic refund should happen
- Duplicate refund should not happen
7. Admin APIs
Admin should be able to:
- View all users
- View wallet balances
- View top spenders
- View failed transactions
- View total platform balance
8. Logical Scenarios (Must Implement)
Scenario 1:
If the same user initiates two simultaneous transfers of ₹1000 while having only ₹1000
balance:
- Prevent double spending
Scenario 2:
If payment gateway callback hits 3 times:
- Prevent duplicate wallet credit
Scenario 3:
If transaction history table grows to 5 crore rows:
- Explain optimization strategy