Basket
What is the Basket Service?
The Basket Service (lets-trade-basket) is a core microservice in the LetsTrade platform responsible for managing shopping carts, checkout processes, and order creation. It handles the entire shopping journey from adding products to a basket through to final checkout and payment processing.
This service provides APIs for:
Creating and managing shopping baskets
Adding, updating, and removing products from baskets
Applying discounts, vouchers, and promotional deals
Processing checkout with various payment methods
Generating delivery quotes and estimates
POS (Point of Sale) basket operations
Kiosk-based ordering
Basket analytics and abandonment tracking
Core Entities
Basket
The central entity representing a shopping cart. A basket contains:
client_id: The merchant/business that owns this basket
user_id: The customer who owns the basket (optional for guest checkouts)
branch_id: The specific store/branch location
channel: The sales channel (e.g., "WEB", "APP", "POS", "KIOSK")
status: Current state of the basket (ACTIVE, CHECKED_OUT, ABANDONED, etc.)
product_list: Array of products in the basket
totals: Calculated subtotal, VAT, discounts, and final total
delivery_address: Shipping destination (if applicable)
payment: Payment method and transaction details
subscription: Subscription/recurring order details
deal: Applied promotional deals
extra_data: Custom key-value pairs for client-specific data
Basket Product
Individual items within a basket:
product_id: Reference to the product catalog
title: Product name
sku: Stock keeping unit
quantity: Number of items
price: Unit price
variations: Selected product variations (size, color, etc.)
condiments: Add-ons or modifiers
instructions: Special instructions for this item
Payment
Payment information attached to a basket:
type: Payment method (CARD, EFT, WALLET, CASH, etc.)
card_token: Tokenized card reference
wallet_id: Customer wallet identifier
amount: Payment amount
status: Payment status
Delivery
Shipping/delivery information:
type: Fulfillment method (DELIVERY, COLLECTION, DINE_IN)
address: Delivery destination
fee: Calculated delivery fee
estimated_time: Expected delivery/collection time
Basket Lifecycle
Basket Statuses
ACTIVE
Basket is open and can be modified
CHECKED_OUT
Checkout completed, payment processed
ABANDONED
Basket inactive beyond abandonment threshold
EXPIRED
Basket validity period exceeded
Fulfillment Methods
The basket service supports multiple fulfillment types:
DELIVERY
Products shipped to customer address
COLLECTION
Customer picks up from store/branch
DINE_IN
For restaurant orders consumed on premises
DRIVE_THROUGH
For quick-service restaurant drive-through
Key API Operations
Basket Management
/create/basket
POST
Create a new basket
/basket/{id}
GET
Retrieve basket by ID
/user/basket
GET
Get user's active basket
/user/baskets
GET
List all baskets for a user
/basket/list
GET
List baskets with filters
Product Operations
/add/product
POST
Add product to basket
/update/product
POST
Update product quantity/options
/remove/product
POST
Remove product from basket
/clear/basket
POST
Remove all products from basket
Checkout & Payment
/checkout
POST
Process basket checkout
/pos/checkout
POST
POS-specific checkout
/add/payment
POST
Add payment method to basket
/add/subscription
POST
Convert to subscription order
Discounts & Deals
/add/voucher
POST
Apply voucher/promo code
/remove/voucher
POST
Remove applied voucher
/add/deal
POST
Apply promotional deal
/remove/deal
POST
Remove applied deal
Delivery
/add/delivery
POST
Set delivery address and method
/quote
POST
Get delivery quote/estimate
Analytics & Dashboard
/client/dashboard
GET
Basket dashboard metrics
/client/basket/analytics
GET
Client-level analytics
/user/basket/analytics
GET
User-level basket analytics
/highest/basket/spent
GET
Top spending customer
Kiosk Operations
/create/kiosk/basket
POST
Create and checkout kiosk order
Abandonment
/config/basket/abandonment
POST
Configure abandonment settings
Authentication
All Basket API endpoints require JWT Bearer token authentication:
API Base URL
The base URL for all API endpoints is:
Response Format
All responses follow the standard LetsTrade format:
Success Response:
Error Response:
Configures the basket abandonment settings for the client, specifying how long before an inactive basket is marked as abandoned.
Abandonment configuration saved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves the customer with the highest basket spending for the client.
Highest spending customer retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves aggregated basket analytics for the client.
Client analytics retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves dashboard analytics for a specific user.
User ID
User dashboard analytics retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves basket analytics for a specific user.
User ID
User basket analytics retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Completes the checkout process for a basket, processing payment and finalizing the order.
Basket ID
Transaction details
Wallet payment details
Loan amount if applicable
Laybuy amount if applicable
Include straw
Include cutlery
Include serviettes
Special instructions
Checkout timestamp
Basket successfully checked out
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Sends a payment request to a user for a basket, typically via email.
Basket ID
Payment notes
Payment request sent successfully
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Creates a new shopping basket for a user with optional products and delivery address.
User ID
Branch ID
Branch group ID
Sales channel
Additional custom data
Basket successfully created
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Cancels an existing basket by setting its status to CANCELLED.
Basket ID to cancel
Basket successfully cancelled
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Creates a Point of Sale basket and immediately checks it out. Used for in-store transactions.
Client ID
User ID
Branch ID
Unique identifier for the basket
Delivery fee
Outstanding amount
Total amount
Service fee
Product handling fees
VAT amount
Subtotal
POS basket successfully created and checked out
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Creates a new basket with products and immediately proceeds to checkout.
Branch ID
Order type (DELIVERY, COLLECTION, etc.)
Basket successfully created and checked out
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Submits a basket as a quote for review, typically used for B2B or custom pricing scenarios.
Basket ID to submit as quote
Quote successfully submitted
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves a specific basket by ID, user ID, or UUID.
Basket ID
User ID
Basket UUID
Return flat product structure
Branch ID filter
Basket successfully retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves the most recent basket for a user or UUID with optional status filtering.
Basket ID
User ID
Basket UUID
Return flat product structure
Branch ID filter
List of statuses to filter by
Latest basket successfully retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves baskets for specified branches with optional date filtering and pagination.
List of branch IDs
Start date filter (ISO format)
End date filter (ISO format)
Page number
Page size
Branch baskets successfully retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves a paginated list of baskets for a specific user with filtering options.
User ID
Branch ID filter
Page number
Page size
Start date filter
End date filter
Status filter
Order type filter
Search string
User basket list successfully retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves a paginated list of all baskets for the client with advanced filtering and sorting options.
Page number
Page size
Start date filter (created)
End date filter (created)
Status filter
Order type filter
Branch ID filter
Search string
Field to sort by
Sort order (asc/desc)
Client basket list successfully retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Adds a single product to an existing basket with optional variations and condiments.
Basket ID
Override product price
Product successfully added
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Adds multiple products to an existing basket in a single request.
Basket ID
Products successfully added
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Updates the status of a basket (ACTIVE, PROCESSING, ABANDONED, CANCELLED, QUOTE).
Basket ID
New basket status
Status successfully updated
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Removes specified products from a basket by their IDs.
Basket ID
List of product IDs to remove
Products successfully removed
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Updates basket properties such as delivery address, type, provider, and scheduled time.
Basket ID
Basket successfully updated
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Applies or removes a voucher from a basket.
Basket ID
Voucher code to apply
Whether to apply or remove voucher
Redemption ID if applicable
Voucher application successfully updated
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Updates a specific product in a basket (quantity, instructions, etc.).
Basket ID
Product successfully updated
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Updates a Point of Sale basket with amounts, products, deals, and vouchers.
Basket ID
POS basket successfully updated
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Applies a selected Starshipit shipping rate to a basket.
Basket ID
Rate successfully applied
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Prepares a rate request for Starshipit shipping based on basket and address.
Basket ID
Rate request prepared successfully
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Retrieves basket dashboard data for a client including basket status groupings.
Dashboard period (e.g., daily, weekly, monthly)
Branch ID filter
Comma-separated branch IDs
Dashboard data retrieved
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Creates a new basket for kiosk orders and immediately checks it out.
User ID
Branch ID
Sales channel (e.g., KIOSK)
Additional custom data
Order instructions
Kiosk basket created and checked out
Bad request - validation failed or invalid parameters
Unauthorized - missing or invalid JWT token
Last updated