A Buy Now Pay Later (BNPL) application built with Java and Spring Boot that allows users to make purchases on credit, manage inventory, and track order history.
- Inventory Management: View and manage product inventory with sorting capabilities
- User Registration: Register users with credit limits
- BNPL Purchases: Make purchases using Buy Now Pay Later payment method
- Credit Limit Management: Automatic credit limit tracking and validation
- Order History: Track all user orders with payment methods and dates
- Dues Clearing: Clear outstanding dues and restore credit limits
- Java 17
- Spring Boot 3.4.0
- Maven (Build tool)
src/main/java/com/nilesh/cleartrip/
├── BNPLApplication.java # Main application logic
├── CleartripApplication.java # Spring Boot application entry point
├── Exception/
│ ├── CreditLimitException.java
│ └── UserNotFoundException.java
└── Model/
├── User.java
├── Order.java
├── Item.java
└── Product.java
- Seed inventory with products
- View inventory sorted by name, count, or price
- Register users with credit limits
- Track user order history
- Buy products using BNPL or regular payment methods
- Automatic inventory updates
- Credit limit validation for BNPL purchases
- Clear outstanding dues for specific orders
- Restore credit limits upon payment
- Java 17 or higher
- Maven 3.6+
mvn clean installmvn spring-boot:runBNPLApplication app = new BNPLApplication();
// Seed inventory
List<Product> products = Arrays.asList(
new Product("Laptop", 10, 50000.0),
new Product("Phone", 20, 30000.0)
);
app.seedInventory(products);
// Register user
app.registerUser("John Doe", 100000.0);
// View inventory
app.viewInventory("price");
// Make a purchase
List<Item> items = Arrays.asList(
new Item(new Product("Laptop", 0, 0.0), 1)
);
app.buy("John Doe", items, "BNPL", new Date());
// Clear dues
app.clearDues("John Doe", ordersToClear, new Date());The application includes custom exceptions:
CreditLimitException: Thrown when purchase amount exceeds user's credit limitUserNotFoundException: Thrown when attempting operations on non-existent users
This project is part of the ClearTrip assignment.
Nilesh Prasad
- Email: nileshprasad54321@gmail.com
- GitHub: @Kakashi54321