Skip to content

A Buy Now Pay Later (BNPL) application built with Java and Spring Boot for managing purchases on credit, inventory, and order history

Notifications You must be signed in to change notification settings

Kakashi54321/bnpl_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BNPL Application

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.

Features

  • 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

Tech Stack

  • Java 17
  • Spring Boot 3.4.0
  • Maven (Build tool)

Project Structure

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

Core Functionality

Inventory Management

  • Seed inventory with products
  • View inventory sorted by name, count, or price

User Management

  • Register users with credit limits
  • Track user order history

Purchase Operations

  • Buy products using BNPL or regular payment methods
  • Automatic inventory updates
  • Credit limit validation for BNPL purchases

Dues Management

  • Clear outstanding dues for specific orders
  • Restore credit limits upon payment

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6+

Building the Project

mvn clean install

Running the Application

mvn spring-boot:run

Usage Example

BNPLApplication 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());

Exception Handling

The application includes custom exceptions:

  • CreditLimitException: Thrown when purchase amount exceeds user's credit limit
  • UserNotFoundException: Thrown when attempting operations on non-existent users

License

This project is part of the ClearTrip assignment.

Author

Nilesh Prasad

About

A Buy Now Pay Later (BNPL) application built with Java and Spring Boot for managing purchases on credit, inventory, and order history

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages