Skip to main content

Orders

An Order is a collection of Products and Prices that can be purchased by a Customer. Orders can be created manually on the platform our through automations that run upon certain events, such as a Journey submission.

Our platform is build in a way such that Business Entities can be installed by our customers, and on this context we can also claim that we "eat our own dog food". This means that we use our own platform to build and model the Order Entity.

Order Details View

Managing Orders via Pricing API

Using our Entity API we can directly manage Orders, although very rapidly we realise that an Order has more to it than just a collection of Products and Prices. We needed to be able to manage the Order's lifecycle, and we needed to be able to manage the Order's state. We also needed to be able to recompute the order's product and price totals, along with the order price and product relations. Using just our Entity API would not suffice here since there is additional logic required to fully manage an order.

To fullfil this purpose we have designed the Pricing API, which is a wrapper around the Entity API. The Pricing API allows us to manage Orders, and it also allows us to manage the Order's lifecycle and state, recomputing the order's product and price totals, along with its price and product relations.

Example: Updating an Order

For general cases, the Entity API can be used directly to deal with simple business entities. In the Orders case, it relies on the Pricing API to ensure any changes over line_items will have all the line items and grand totals computed properly.

On both examples below API/SDK we authenticate using a Org Access Token (OAT) that can be generated from our Epilot Portal:

Getting an Order using the Entity API
curl --location --request GET 'https://entity.sls.epilot.io/v1/entity/schemas/order?id=<order-id>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <org-access-token>'

After fetching the Order from the Pricing API we can change the line_items and then call the Pricing API to update the order. The update is done via PUT so it's a full update. We don't yet have a PATCH endpoint for upserting entity changes.

Updating an Order via Pricing API
curl --location --request PUT 'https://pricing-api.sls.epilot.io/v1/order/<order-id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <org-access-token>' \
--data-raw '{
"line_items": [
{
"description": "individual adjustment",
"_price": {
"unit_amount": 1000,
"unit_amount_decimal": "10.00",
"unit_amount_currency": "EUR"
}
}
]
}'