Saleculator supports asynchronous HTTP GET calls from ticket scripts and event scripts. This is useful for updating online ordering or delivery platforms without slowing down POS operations such as KOT printing, billing, driver assignment, or ticket closing.
Why Use Async HTTP Calls? #
Different platforms use different order statuses. For example:
- Online ordering platform: `accepted`, `preparing`, `ready`
- Delivery platform: `assigned`, `picked_up`, `delivered`
- Hotel / room service: `sent_to_room`, `room_delivered`
- Pickup orders: `ready_for_pickup`
Instead of hardcoding one status flow, restaurants can decide which Saleculator event should update which platform status.
The HTTP call runs in the background, so the POS does not wait for the remote server response.
Available Script Methods #
These methods are available through the `sales` object in ticket event scripts:
sales.httpGetAsync(url);
sales.httpGetAsync(url, bearerToken);
sales.httpGetAsync(url, connectTimeout, readTimeout);
sales.httpGetAsync(url, bearerToken, connectTimeout, readTimeout);
sales.urlParam(url, key, value);
sales.urlEncode(value);
They are also available directly on the ticket object:
ticket.httpGetAsync(url);
ticket.httpGetAsync(url, bearerToken);
ticket.urlParam(url, key, value);
ticket.urlEncode(value);
Basic Example #
String url = "https://example.com/api/order/status";
url = sales.urlParam(url, "order_id", ticket.getProperty("DeliveryOrder"));
url = sales.urlParam(url, "status", "preparing");
url = sales.urlParam(url, "comment", "KOT sent from Saleculator");
sales.httpGetAsync(url);
Example with Bearer Token #
String url = “https://menu.example.com/api/v1/pos/orders/”
+ ticket.getProperty(“YaadroPublicId”)
+ “/status”;
url = sales.urlParam(url, “status”, “preparing”);
url = sales.urlParam(url, “comment”, “KOT sent from Saleculator”);
sales.httpGetAsync(url, “YOUR_POS_API_TOKEN”);
This sends:
GET /api/v1/pos/orders/{order}/status?status=preparing&comment=KOT%20sent%20from%20Saleculator
Authorization: Bearer YOUR_POS_API_TOKEN
Recommended Event Usage
| Saleculator event | Typical use |
|---|---|
ticket.orderaccepted | Send accepted |
script.sendorder | Send preparing when KOT is sent |
ticket.save | Send ready or custom status |
ticket.close | Send paid / completed status |
ticket.driverselected | Send assigned with driver details |
| Custom event | Send platform-specific status |
Example: Update Preparing from script.sendorder
String orderId = ticket.getProperty("YaadroPublicId");
if (orderId != null && orderId.length() > 0) {
String url = "https://menu.example.com/api/v1/pos/orders/" + orderId + "/status";
url = sales.urlParam(url, "status", "preparing");
url = sales.urlParam(url, "comment", "KOT sent from Saleculator");
sales.httpGetAsync(url, "INMENU_POS_TOKEN");
}
Timeouts #
Default timeout is 10 seconds for connection and read.
You can override it:
sales.httpGetAsync(url, "INMENU_POS_TOKEN", 3000, 3000);
This uses:
3000ms connect timeout3000ms read timeout
Notes #
- The HTTP call is asynchronous and does not block POS operations.
- Failed calls are logged but do not interrupt billing or KOT.
- Use
sales.urlParam()to safely encode query parameters. - Avoid placing API tokens directly inside shared scripts unless access is controlled.
- Each restaurant can map events to statuses differently depending on order type, delivery method, or platform requirements.
Leave a Reply