Order Events
The Order Events APIs (api.events.order) provide access to order events.
When an OrderUpdates object is the expected response from the handler, the POS post-processes the value.
Data in the additionalOrderProperties field of the returned object is stored in the additional_properties field of the order.
// To save data on a finalized order use any unique field name
// In this example the name
// "fiscal_transaction" is used for transactional data
api.events.order.onOrderFinalized(order => {
if (order.additional_properies) {
// Access previously generated data
console.log('Previous transaction data:', order.additional_properies.fiscal_transaction);
}
// Create and return new data to be saved in the order object.
const fiscalTransaction = {
id: '1234', // some identifier
... // other data
}
const additionalOrderProperties = {
fiscal_transaction: fiscalTransaction
}
const orderUpdates = {
additionalOrderProperties
};
return Promise.resolve(orderUpdates);
});In this case a handler prints an order or kitchen receipt with an expectation of returned data of the appropriate printingInfo. This printing event is be tracked for the order.
api.events.order.onOrderFinalized(order => {
// Print an order receipt (customer copy)
...
// Include appropriate printing info for the returned value
const printingInfo = {
printingType: 'customer'
}
const orderUpdates = {
printingInfo
};
return Promise.resolve(orderUpdates);
});.onOrderCanceled
Event fires when an order is canceled before full payment.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrderFinalized
Event fires when:
Order checked out, fully paid and transitions to closed status
Order checked out, fully paid and transitions to saved status, awaiting tips
Tips applied to order in saved status and transitions to close status.
Incoming order paid online is manually checked in and transitions to closed status.
Incoming order paid and checked in online automatically transitions to closed status.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrderFinalizedPostPaymentVoid
Event fires on void of a fully paid order.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrderFinalizedRefund
Event fires on finalization of an order refund.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrderFinalizedVoid
Event fires upon void of a partially paid order.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrderPaymentProcessed
Event fires upon processing a new payment for an order.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onOrdersCombined
Event fires when combining several orders into one.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
Example
Example of order.onOrdersCombined(handler: Function)
api.events.order.onOrdersCombined(params => {
// Consider there were three orders: order1, order2, order3.
// And then those orders got combined into order1.
// targetOrder will be a reference to object order1 before combine.
console.log('order1:', params.targetOrder);
// order2 and order3 (before combine) can be accessed through params.
combinedOrders:console.log('order2 and order3:', params.combinedOrders);
return {};
});.onOrderSplit
Event fires when order items are moved to another order or shared between orders.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|
.onPrintOrderReceipt
Event fires prior to requesting a printed order receipt.
Note: when POS is configured to print N copies of the order receipt, this event fires before each printing.
Function |
| ||||||
Handler Parameters |
| ||||||
Handler Returns |
|