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

Status
What it means

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

Status
What it means

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

Method
Description

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:

Scenario
Situation
What happens

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:

Channel
Description

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:

Create order from external channel

post

Creates an order from an external sales channel (e.g., Uber Eats, Takealot). Used for integrating third-party marketplace orders.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
orderobjectOptional

Order data from external channel

channelstringRequired

Channel name (e.g., UBER, TAKEALOT)

channel_idstringRequired

Channel-specific order ID

basket_idstring | nullableOptional
totalstring | nullableOptional
vatstring | nullableOptional
sub_totalstring | nullableOptional
statusstring | nullableOptional
user_idstring | nullableOptional
branch_idstring | nullableOptional
payment_typestring[] | nullableOptional
product_listobject[] | nullableOptional
requestobject | nullableOptional

Original request from channel

transaction_detailsobject | nullableOptional
Responses
post
/create/channel/order

Create order from basket

post

Converts an existing shopping basket into a confirmed order. Requires a valid basket ID and payment transaction details.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
basket_idstringRequired

Basket ID to convert to order

transaction_detailsobjectOptional

Payment transaction details

channelstring | nullableOptional

Sales channel identifier

basket_signaturestring | nullableOptional

Basket signature for validation

is_supplier_orderboolean | nullableOptional

Whether this is a supplier order

Responses
post
/create/order

Create order from customer quote

post

Converts an approved customer quote into a confirmed order. The quote must exist and be in an appropriate status.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
quote_idstringRequired

Customer quote ID to convert to order

transaction_detailsobjectOptional

Payment transaction details

channelstring | nullableOptional
Responses
post
/create/customer/quote/order

Get a single order

get

Retrieve an order by its ID, code, or associated basket ID. At least one identifier must be provided.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
_idstringOptional

Order MongoDB ObjectId

codestringOptional

Order reference code (e.g., ORD-2024-001234)

basket_idstringOptional

Associated basket ID

Responses
get
/order

Get order by extra data value

get

Retrieve an order using a value stored in its extra_data field. Useful for finding orders by external reference numbers.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
valuestringRequired

The extra data value to search for

Responses
get
/order/by/extra/data

Get paginated order list

get

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).

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
user_idstringOptional

Filter by user ID

branch_idstringOptional

Filter by single branch ID

branch_id_liststringOptional

Comma-separated list of branch IDs

branch_group_idstringOptional

Filter by branch group ID

search_stringstringOptional

Search orders by code, user name, etc.

statusstring · enumOptional

Filter by order status

Possible values:
methodstring · enumOptional

Filter by fulfillment method

Possible values:
channelstringOptional

Filter by sales channel

pagestringOptional

Page number for pagination (1-based)

Default: 1
sizestringOptional

Number of items per page

Default: 20
sort_bystring · enumOptional

Field to sort by

Possible values:
order_bystring · enumOptional

Sort direction

Default: descPossible values:
start_datestring · dateOptional

Filter orders created after this date

end_datestring · dateOptional

Filter orders created before this date

modified_start_datestring · dateOptional

Filter orders modified after this date

modified_end_datestring · dateOptional

Filter orders modified before this date

total_minnumberOptional

Minimum order total

total_maxnumberOptional

Maximum order total

Responses
get
/order/list

Export orders to CSV or Excel

get

Export orders matching the specified filters to CSV or Excel format. Returns a downloadable file.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
formatstring · enumOptional

Export file format

Default: csvPossible values:
user_idstringOptional

Filter by user ID

branch_idstringOptional

Filter by branch ID

statusstringOptional

Filter by order status

start_datestring · dateOptional

Filter orders created after this date

end_datestring · dateOptional

Filter orders created before this date

Responses
get
/order/export

Correct TLC orders (internal)

put

Internal endpoint to correct TLC (The Loyalty Channel) orders. Used for order data fixes.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Responses
put
/correct

Cancel an order

put

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

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
order_idstringRequired

Order ID to cancel

reasonstring | nullableOptional

Reason for cancellation

user_idstring | nullableOptional

User ID initiating cancellation

refund_typestring · enumOptional

Type of refund to issue

Possible values:
scenariostring | nullableOptional

Refund scenario (S1-S5)

product_id_liststring[] | nullableOptional

List of product IDs to cancel (partial cancellation)

Responses
put
/order/cancel

Refund an order

put

Issues a refund for an order. Can refund to wallet or as a voucher.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
order_idstringRequired

Order ID to refund

refund_typestring · enumOptional

Type of refund to issue

Possible values:
scenariostring | nullableOptional

Refund scenario

product_id_liststring[] | nullableOptional

List of product IDs to refund (partial refund)

Responses
put
/order/refund

Create a parcel

post

Creates a new parcel for shipping/delivery with recipient and collection details.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
user_idstringRequired

User ID creating the parcel

order_idstring | nullableOptional

Associated order ID

statusstring | nullableOptional
floating_fleetboolean | nullableOptional
parcel_datestring | nullableOptional
boxesstring | nullableOptional
methodstringRequired

Parcel method (required)

delivery_methodstring | nullableOptional
namestring | nullableOptional
descriptionstring | nullableOptional
conditionstring | nullableOptional
collection_timestring | nullableOptional
collection_datestring | nullableOptional
notesstring | nullableOptional
image_urlstring | nullableOptional
product_listobject[] | nullableOptional
Responses
post
/create/parcel

Get a parcel

get

Retrieve a parcel by its ID or code.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
_idstringOptional

Parcel MongoDB ObjectId

codestringOptional

Parcel reference code

Responses
get
/parcel

Create a quote

post

Creates a new quote for a user with the specified products and terms.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
user_idstring | nullableOptional
branch_idstring | nullableOptional
branch_group_idstring | nullableOptional
issue_datestring | nullableOptional
titlestring | nullableOptional
summarystring | nullableOptional
expiry_datestring | nullableOptional
currencystring | nullableOptional
deposit_amountstring | nullableOptional
subscriptionbooleanRequired

Whether this is a subscription quote

termsstring | nullableOptional
product_id_liststring[] | nullableOptional

List of product IDs to include

commentsstring | nullableOptional
Responses
post
/create/quote

Create a customer quote

post

Creates a detailed customer quote with customer information, addresses, products, and pricing.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Body
statusstring | nullableOptional
product_listobject[]Optional
branch_idstring | nullableOptional
totalstring | nullableOptional
sub_totalstring | nullableOptional
vatstring | nullableOptional
discountstring | nullableOptional
dealsobject[] | nullableOptional
vouchersobject[] | nullableOptional
quote_expiry_datestring | nullableOptional
outstanding_amountstring | nullableOptional
paid_amountstring | nullableOptional
Responses
post
/create/customer/quote

Get a quote for deals

get

Retrieve a flattened quote structure for deals processing.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
quote_idstringRequired

Quote ID

user_idstringRequired

User ID

flatbooleanRequired

Must be true for flattened format

Responses
get
/quote

Get customer quote by ID

get

Retrieve a customer quote by its ID.

Authorizations
AuthorizationstringRequired

JWT authentication token. Obtain from the authentication service.

Query parameters
_idstringRequired

Customer quote ID

Responses
get
/customer/quote

Last updated