Online orders API
Transporting orders from e-shops or food delivery platforms to the PORTOS application.

Glossary

Term
Definition
PORTOS
The cash register solution developed by Nine Digit, s.r.o.
External system
The 3rd party system (such as e-shop or food delivery platform) from which unprocessed orders are imported to PORTOS.
Venue
The restaurant processing the order.
Cashier
The Venue personnel
Customer
User who orders the goods trough external system.
Order
The purchase request made by customer trough the external system, containing data about products, delivery address, etc.
Unprocessed order
Order accepted by external system, but not yet confirmed nor rejected by PORTOS.
Processed order
Order confirmed or rejected by PORTOS.
Product
The product (such as food or drink) that is ordered by customer.

How it works

The online orders API is a mechanism that allows importing online orders from "external system" (such as e-shops or food delivery platforms) to the PORTOS system.
The PORTOS system acts as an "client" initiating HTTP requests targeting the external system, that acts as an "server" and handles the following requests:
  1. 1.
    Fetch unprocessed orders
  2. 2.
    Process order
After unprocessed order is fetched, cashier is requested to process (either accept or reject) the order trough the PORTOS application. After cashier confirms or rejects the order, PORTOS application will initiate second request (process order) to the external system.
The PORTOS system expects that responses from external system follows data format described below.
get
{external-system}
{unprocessed-orders-url}
Fetch unprocessed orders
post
{external-system}
{process-order-url}
Process order

Data model

The data model of online orders exchange is described below. All prices include taxes.

Order

Order represents purchase request made by customer trough the external system, containing data about products, delivery address, etc.
Name
Type
Required
Description
externalId
string
Yes
The unique identifier of order, generated by the external system.
type
string
No
The type of order. Contains one of following values:delivery (products will be delivered to customers address), takeAway(customer will pick up the order at the venue) ordineIn(customer will eat at the venue, e.g. table reservation). If type is not specified, delivery is used.
delivery
No
Information about the order delivery. Required, when type is delivery. Otherwise must be null (or not specified at all).
createdAt
string
Yes
The ISO_8601 formatted date and time of order creation (when the order has been created in external system).
scheduledAt
string
No
The optional ISO_8601 formatted date and time of scheduled order. If not specified, order should be delivered ASAP. This field is required when order type is dineIn.
customer
Customer
Yes
Customer contact information.
products
Product[]
Yes
The collection of products. Must contain at least one product.
currency
string
Yes
Currency code (in ISO 4217 standard) for order price information.
payment
Payment
No
The information about payment.
wrappingFee
number
No
Wrapping fee (not applicable in Slovak republic due to Slovak legislation).
totalPrice
number
Yes
Total price of order, including all products, product additions, delivery and wrapping fee. Precision up to 2 decimal places.

OrderDelivery

Order delivery information.
Name
Type
Required
Description
address
Address
Yes
The delivery address.
fee
number
No
The cost of delivery. Precision up to 2 decimal places. If not specified, zero value will be used.

Address

The customer's address.
Name
Type
Required
Description
line1
string
Yes
1st line of delivery address (e.g. street name, building number)
line2
string
No
Optional 2nd line of delivery address.
city
string
Yes
Name of the city.
zipCode
string
Yes
The ZIP code (postal code).
note
string
No
Optional comment related to the address or delivery.

Customer

The customer's contact information.
Name
Type
Required
Description
name
string
Yes
Name of customer.
phone
string
Yes
Phone number.
email
string
No
E-mail address.

Product

The product (such as food or drink).
Name
Type
Required
Description
id
string
No
The product identifier in PORTOS system. If this field will not be provided, the processing of order will not affect stock quantity of the material in PORTOS stock management system.
name
string
Yes
Name of product.
quantity
int
Yes
Positive, non-zero integer quantity of the product (e.g. 1, 2, ...).
baseUnitPrice
number
Yes
The base unit price of product (product additions are not included).
note
string
No
The optional product-related comment, provided by customer.
additions
No
The product additions (modifiers). If product quantity is greater than 1, each one will have same additions applied.
Example #1: if customer orders two burgers with fries for each burger, order will contain product with name "Burger", quantity equal to 2 and addition with name "Fires" and quantity equal to one.
Example #2: if customer orders two burgers, one with fries and second with salad. In this case, order will contain two separate products - first with quantity equal to one and fries in additions; second with quantity equal to one and salad in additions.

ProductAddition

The product addition (option, modifier) that adds more information about how the product should be prepared.
Name
Type
Required
Description
id
string
No
The product identifier in PORTOS system. If this field will not be provided, the processing of order will not affect stock quantity of the material in PORTOS stock management system.
name
string
Yes
Name of product.
quantity
int
Yes
Positive, non-zero integer quantity of the product option (e.g. 1, 2, ...).
unitPrice
number
Yes
The unit price of product option. Value may be positive or negative, if affects the price of product. Value also may be equal to zero, if product price is not affected (e.g. steak doeness).
note
string
No
The optional attribute-related comment, provided by customer.

Payment

The product payment information.
Name
Type
Required
Description
isSettled
boolean
Yes
true, if payment has already been completed (e.g. transaction has been transferred), false otherwise.
method
string
No
The description of payment method that was used (when isSettledis true) or will be used (when isSettled is false).
One of following: cash, card

Configuration

To communicate with external system properly, the external system administrators must provide values stated below to the venue owners or PORTOS support.
Value
Type
Description
External system unprocessed orders URL
string
The URL hosted by external system, that will be requested by PORTOS to fetch the unprocessed orders.
External system process order URL
string
The URL hosted by external system, that will be requested by PORTOS to process (confirm or reject) order.
API key
string
The venue-specific API key (authorization token) that will be placed in the key query parameter of all HTTP requests.
Fetch period
int
The period (in seconds) that specifies, how often will PORTOS system invoke the "fetch unprocessed orders" API call. Default value is 15seconds.

Example

In all request examples below, we will assume following configuration:
  • external system unprocessed orders URL: https://the-foo-bar.sk/unprocessed_orders
  • external system process order URL: https://the-foo-bar.sk/process_order
  • API key is: my-token

Step 1: Fetching unprocessed orders

The PORTOS will request following URL:
1
GET https://the-foo-bar.sk/unprocessed_orders?version=1&key=my-token
Copied!
The external system returns following payload as an response:
1
[
2
{
3
"externalId": "b478396ad654",
4
"type": "delivery",
5
"delivery": {
6
"address": {
7
"line1": "Kresankova 12",
8
"line2": "",
9
"city": "Bratislava",
10
"zipCode": 84105,
11
"note": "Please knock twice"
12
},
13
"fee": 1.99
14
},
15
"createdAt": "2021-02-01T12:01:00.000Z",
16
"scheduledAt": null,
17
"customer": {
18
"name": "John Doe",
19
"phone": "+421 900 123 456",
20
"email": "[email protected]"
21
},
22
"products": [
23
{
24
"id": "1234",
25
"name": "Burger",
26
"quantity": 1,
27
"baseUnitPrice": 8.99,
28
"note": "",
29
"additions": [
30
{
31
"id": "11002",
32
"name": "No cheese",
33
"quantity": 1,
34
"unitPrice": 0.00,
35
"note": ""
36
},
37
{
38
"id": "11002",
39
"name": "Extra bacon",
40
"quantity": 1,
41
"unitPrice": 1.99,
42
"note": ""
43
}
44
]
45
}
46
],
47
"currency": "EUR",
48
"payment": {
49
"isSettled": true,
50
"method": "card"
51
},
52
"wrappingFee": 0,
53
"totalPrice": 12.97
54
},
55
{
56
"externalId": "6a2ad048e32d",
57
"type": "takeAway",
58
"delivery": null,
59
"createdAt": "2021-02-01T12:01:00.000Z",
60
"scheduledAt": "2021-02-01T13:00:00.000Z",
61
"customer": {
62
"name": "John Doe",
63
"phone": "+421 900 123 456",
64
"email": "[email protected]"
65
},
66
"products": [
67
{
68
"id": "2345",
69
"name": "Fries",
70
"quantity": 2,
71
"baseUnitPrice": 4.99,
72
"note": "",
73
"additions": [
74
{
75
"id": "11024",
76
"name": "Ketchup",
77
"quantity": 1,
78
"unitPrice": 1.99,
79
"note": ""
80
}
81
]
82
}
83
],
84
"currency": "EUR",
85
"payment": {
86
"isSettled": false,
87
"method": null
88
},
89
"wrappingFee": 0,
90
"totalPrice": 13.96
91
}
92
]
Copied!
As we can see, the external systems returns two unprocessed orders.

Step 2: Order acceptation

The PORTOS will mark first order as accepted by requesting following URL:
1
POST https://the-foo-bar.sk/process_order?version=1&key=my-token&externalId=b478396ad654&status=accepted&estimatedCompletionAt=2021-02-01T13%3A01%3A00.000Z
Copied!
Please note that all query parameters are URL encoded. In URL above, the estimatedCompletionAt query parameter value 2021-02-01T13:01:00.000Z is URL encoded as 2021-02-01T13%3A01%3A00.000Z.

Step 3: Fetching unprocessed orders

The PORTOS will request unprocessed requests again:
1
GET https://the-foo-bar.sk/unprocessed_orders?version=1&key=my-token
Copied!
The external system returns following payload as an response:
1
[
2
{
3
"externalId": "6a2ad048e32d",
4
"type": "takeAway",
5
"delivery": null,
6
"createdAt": "2021-02-01T12:01:00.000Z",
7
"scheduledAt": "2021-02-01T13:00:00.000Z",
8
"customer": {
9
"name": "John Doe",
10
"phone": "+421 900 123 456",
11
"email": "[email protected]"
12
},
13
"products": [
14
{
15
"id": "2345",
16
"name": "Fries",
17
"quantity": 2,
18
"baseUnitPrice": 4.99,
19
"note": "",
20
"additions": [
21
{
22
"id": "11024",
23
"name": "Ketchup",
24
"quantity": 1,
25
"unitPrice": 1.99,
26
"note": ""
27
}
28
]
29
}
30
],
31
"currency": "EUR",
32
"payment": {
33
"isSettled": false,
34
"method": null
35
},
36
"wrappingFee": 0,
37
"totalPrice": 13.96
38
}
39
]
Copied!
The recently accepted order no longer appears in unprocessed orders collection.

Step 4: Order rejection

The PORTOS will mark remaining order as rejected by requesting following URL:
1
POST https://the-foo-bar.sk/process_order?version=1&key=my-token&externalId=6a2ad048e32d&status=rejected&rejectionReason=The%20food%20is%20out%20of%20stock.
Copied!
Please note that all query parameters are URL encoded. In URL above, the rejectionReason query parameter value The food is out of stock. is URL encoded as The%20food%20is%20out%20of%20stock..

Step 5: Fetching unprocessed orders

The PORTOS will request unprocessed requests again:
1
GET https://the-foo-bar.sk/unprocessed_orders?version=1&key=my-token
Copied!
All requests has been processed (rejected or accepted). The external system returns empty collection as an response.
1
[]
Copied!
Last modified 5mo ago