Order
What is the Order Service?
The Order service is the core transactional engine of the LetsTrade platform. It manages the complete lifecycle of customer purchases - from the moment a customer checks out, through fulfillment and delivery, to potential refunds.
Core Entities
Order
An Order is a customer purchase transaction. It's created when:
A customer completes checkout from their shopping basket
An order comes in from an external sales channel (Shopify, Uber Eats, Takealot, etc.)
Each order contains:
Products: The items being purchased with quantities and prices
Customer info: Who placed the order and where to deliver
Payment details: How the order was paid for
Status tracking: Current state and full history of status changes
Fulfillment method: Delivery to address or collection from store
Parcel
A Parcel is the physical package used to ship an order. Think of it as the "shipping side" of an order:
One order can have multiple parcels (e.g., items shipped separately)
One parcel can combine items from multiple orders (batch shipping)
Parcels track the physical journey: packed → collected by driver → in transit → delivered
Quote
A Quote is a formal price proposal before an order is created. Useful for:
B2B transactions requiring approval
Custom pricing or bulk orders
Customers who want to review pricing before committing
Quotes can be sent to customers, tracked (viewed/accepted/declined), and converted into orders.
Order Lifecycle
Order Statuses
ORDERED
Order placed, awaiting processing
PROCESSING
Store is preparing the order
DELIVERY-READY
Packed and ready to ship or collect
PARTIALLY-FULFILLED
Some items delivered, others pending
FULFILLED
All items successfully delivered/collected
CANCELLED
Order was cancelled before completion
REFUNDED
Payment returned to customer
PARTIALLY-REFUNDED
Some items refunded
Parcel Statuses
OPEN
Parcel created, not yet packed
PACKED
Items packed into boxes
READY
Ready for courier pickup
COLLECTED-BY-DRIVER
Driver has the parcel
IN-TRANSIT
On the way to destination
ARRIVED
At delivery location
DELIVERED
Successfully handed to customer
COLLECTED
Customer picked up from store
RETURNED
Sent back to sender
Fulfillment Methods
Delivery
Items shipped to customer's address
Collection
Customer picks up from store (click & collect)
Refund Scenarios
When things go wrong, the system supports 5 refund scenarios:
S1
Store can't fulfill (no stock, weather, no driver)
Full refund + delivery fee returned
S2
Customer not available at delivery
Refund minus delivery fee (customer's fault)
S3
Customer rejects (wrong items, damaged goods)
Full refund + delivery fee returned
S4
Store issues voucher (e.g., delayed delivery compensation)
Voucher/store credit issued
S5
POS or loyalty program refunds
Handled externally
Refunds can be issued to:
Wallet: Credit added to customer's account balance
Voucher: Store credit for future purchases
Sales Channels
Orders can come from multiple sources:
Internal
LetsTrade apps and website
Shopify
Shopify e-commerce stores
Takealot
Takealot marketplace
Uber Eats
Food delivery orders
Munch
Point-of-sale integration
Custom
Other integrated platforms
Each channel order includes the external reference ID for tracking across systems.
Key API Operations
Orders
Create order - From basket checkout or external channel
Get order - Retrieve by ID, code, or basket reference
List orders - Paginated list with filters
Export orders - Download as CSV for reporting
Cancel order - Cancel and optionally refund
Refund order - Issue full or partial refund
Parcels
Create parcel - Create shipping package for order
Get parcel - Track parcel by ID or code
Quotes
Create quote - Generate price proposal
Get quote - Retrieve quote details
Convert to order - Accept quote and create order
Authentication
All API endpoints require JWT Bearer token authentication:
Response Format
All responses follow a consistent structure:
Success:
Error:
Creates an order from an external sales channel (e.g., Uber Eats, Takealot). Used for integrating third-party marketplace orders.
JWT authentication token. Obtain from the authentication service.
Order data from external channel
Channel name (e.g., UBER, TAKEALOT)
Channel-specific order ID
Original request from channel
Channel order created successfully
Validation error or bad request
Authentication required or invalid token
Converts an existing shopping basket into a confirmed order. Requires a valid basket ID and payment transaction details.
JWT authentication token. Obtain from the authentication service.
Basket ID to convert to order
Payment transaction details
Sales channel identifier
Basket signature for validation
Whether this is a supplier order
Order created successfully
Validation error or bad request
Authentication required or invalid token
Converts an approved customer quote into a confirmed order. The quote must exist and be in an appropriate status.
JWT authentication token. Obtain from the authentication service.
Customer quote ID to convert to order
Payment transaction details
Order created successfully from quote
Validation error or bad request
Authentication required or invalid token
Internal server error
Retrieve an order by its ID, code, or associated basket ID. At least one identifier must be provided.
JWT authentication token. Obtain from the authentication service.
Order MongoDB ObjectId
Order reference code (e.g., ORD-2024-001234)
Associated basket ID
Order retrieved successfully
Validation error or bad request
Authentication required or invalid token
Retrieve an order using a value stored in its extra_data field. Useful for finding orders by external reference numbers.
JWT authentication token. Obtain from the authentication service.
The extra data value to search for
Order retrieved successfully
Validation error or bad request
Authentication required or invalid token
Retrieves a paginated list of orders with optional filtering by user, branch, status, method, channel, date range, and total amount range. When both created and modified date ranges are provided, returns orders that match either range (OR logic).
JWT authentication token. Obtain from the authentication service.
Filter by user ID
Filter by single branch ID
Comma-separated list of branch IDs
Filter by branch group ID
Search orders by code, user name, etc.
Filter by order status
Filter by fulfillment method
Filter by sales channel
Page number for pagination (1-based)
1Number of items per page
20Field to sort by
Sort direction
descPossible values: Filter orders created after this date
Filter orders created before this date
Filter orders modified after this date
Filter orders modified before this date
Minimum order total
Maximum order total
Orders retrieved successfully
Validation error or bad request
Authentication required or invalid token
Export orders matching the specified filters to CSV or Excel format. Returns a downloadable file.
JWT authentication token. Obtain from the authentication service.
Export file format
csvPossible values: Filter by user ID
Filter by branch ID
Filter by order status
Filter orders created after this date
Filter orders created before this date
File downloaded successfully
Validation error or bad request
Authentication required or invalid token
Internal endpoint to correct TLC (The Loyalty Channel) orders. Used for order data fixes.
JWT authentication token. Obtain from the authentication service.
Orders corrected successfully
Validation error or bad request
Cancels an order and optionally issues a refund. Supports different refund types and scenarios:
S1: Store can't fulfill (weather, no driver, etc.) - refund + delivery fee
S2: Customer unavailable at delivery - refund minus delivery fee
S3: Customer rejects order (wrong items) - refund + delivery fee
S4: Store issues voucher (e.g., 7-day delivery) - App-only, no wallet credit
S5: POS or loyalty refunds - No dev required
JWT authentication token. Obtain from the authentication service.
Order ID to cancel
Reason for cancellation
User ID initiating cancellation
Type of refund to issue
Refund scenario (S1-S5)
List of product IDs to cancel (partial cancellation)
Order cancelled successfully
Validation error or bad request
Authentication required or invalid token
Issues a refund for an order. Can refund to wallet or as a voucher.
JWT authentication token. Obtain from the authentication service.
Order ID to refund
Type of refund to issue
Refund scenario
List of product IDs to refund (partial refund)
Order refunded successfully
Validation error or bad request
Authentication required or invalid token
Creates a new parcel for shipping/delivery with recipient and collection details.
JWT authentication token. Obtain from the authentication service.
User ID creating the parcel
Associated order ID
Parcel method (required)
Parcel created successfully
Validation error or bad request
Authentication required or invalid token
Retrieve a parcel by its ID or code.
JWT authentication token. Obtain from the authentication service.
Parcel MongoDB ObjectId
Parcel reference code
Parcel retrieved successfully
Validation error or bad request
Creates a new quote for a user with the specified products and terms.
JWT authentication token. Obtain from the authentication service.
Whether this is a subscription quote
List of product IDs to include
Quote created successfully
Validation error or bad request
Authentication required or invalid token
Creates a detailed customer quote with customer information, addresses, products, and pricing.
JWT authentication token. Obtain from the authentication service.
Customer quote created successfully
Validation error or bad request
Authentication required or invalid token
Internal server error
Retrieve a flattened quote structure for deals processing.
JWT authentication token. Obtain from the authentication service.
Quote ID
User ID
Must be true for flattened format
Quote retrieved successfully
Validation error or bad request
Authentication required or invalid token
Resource not found
Retrieve a customer quote by its ID.
JWT authentication token. Obtain from the authentication service.
Customer quote ID
Customer quote retrieved successfully
Validation error or bad request
Authentication required or invalid token
Internal server error
Last updated