Implement a Buy Now Pay Later (BNPL) system.
Unlock detailed company stats for this questionUpgrade
Customers can buy products instantly and pay the dues within 30 days; each user has an initial BNPL credit limit. All data must be stored in memory (no database), and AI use was prohibited.
- seed inventory: read from FILE/STDIN/DRIVER and add products with attributes (name, count, price) to inventory.
- view_inventory(): show the inventory at any point.
- register_user(user, credit_limit): initialize a user with basic details and an initial BNPL credit limit.
- buy(user, List<item, quantity>, payment method, date of purchase): PREPAID places the order, adds it to order history and reduces inventory. BNPL places the order, decreases the credit limit, adds it to order history and reduces inventory; if the credit limit is exhausted, payment is not allowed.
- clear_dues(user, List<orderId>, date of clearing): pay dues partially (a few orders) or completely.
- view_dues(user, date): print pending dues for orders placed before the date, with date of purchase, pending amount and order detail, in ascending order of purchase date, with status DELAYED (30-day window crossed) or PENDING.
- order_status(user): print order history in ascending order of purchase date, plus the current BNPL credit limit available.
Bonus: blacklisting (a customer who defaults on 3 orders cannot place new BNPL orders; check in buy) and add_inventory/remove_inventory.
Community answers
No answers contributed by the community yet.


