Sending an order
Call info
Description
To submit an order into the Harmony system, simply send a payload of
order to the specified URL.
The URL needs a {StoreCode} specified in order to know which store the order must be forwarded to.
Harmony will return to you with a payload of
orderInsertStatus.
In this load, you will find a status
code and a message. This message will contain the errors if import or validation fails.
If import is successful, a token will be in the payload.
This token will be used for all further communication concerning this order (like requesting the current order status / getting a push notification when order status changes).
Exceptions
In case of an exception where we cannot recover from, a special object is returned. The body load will always be of the type
simpleMessage.
HTTP Code 404
If status code is 404, an resource could not be allocated. For example, the store code was not found. The details will be in the message.
HTTP Code 400
If status code is 400, the body payload sent was incomplete or malformed and could not be parsed by the system. More details (if available) can be found in the message.
HTTP Code 500
If status code is 500, you probably have blown up our server :). This is triggered if something happens unforeseen. If details are available, we will provide these in the message part.
PHP Samples
Sending empty order (will result in error)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{}",
CURLOPT_HTTPHEADER => array(
"authorization: Basic Ihavetobechanged",
"content-type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Sending Full test order
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"OrderInfo\":{\"ExternalToken\":\"TESTTOKEN009\",\"StoreCode\":\"150A\",\"ASAP\":false,\"CustomerComment\":\"Test order\",\"CustomerPickupDateTime\":null,\"RiderPickupDateTime\":null,\"ExternalLogisticsJobTrackingID\":null,\"ExpeditionType\":2,\"CreatedDateTime\":\"2017-10-03T16:05:51.8706132+02:00\",\"ExpiryDateTime\":\"2017-10-03T16:10:51.8711135+02:00\",\"DeliveryDateTime\":\"2017-10-03T16:40:00+02:00\",\"ForcedClientOrderStatus\":null},\"Products\":[{\"BindingID\":\"1337\",\"Quantity\":1,\"SingleProductPrice\":96.0,\"RowPrice\":98.0,\"CategoryName\":\"Test product group\",\"Name\":\"Test product\",\"ProductComment\":\"This is a test product\",\"Choices\":[{\"BindingID\":\"a1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test addon\"},{\"BindingID\":\"t1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test topping\"}],\"BoundProducts\":null,\"Discounts\":[{\"Name\":null,\"Price\":0.10}],}],\"CostInformation\":{\"SubTotal\":98.0,\"DeliveryFee\":2.5,\"ServiceFee\":0.0,\"GrandTotal\":100.50},\"LocalInfo\":{\"PlatformName\":\"TEST\"},\"Customer\":{\"Email\":\"spam@cashdesk.nl\",\"FirstName\":\"Bas\",\"LastName\":\"Tester\",\"CompanyName\":\" CashDesk\",\"PhoneNumber\":\"0612345678\"},\"WaiterDetails\":null,\"DeliveryDetails\":{\"ZipCode\":\"1111AA\",\"Latitude\":0.0,\"Longitude\":0.0,\"FlatNumber\":null,\"Room\":null,\"Number\":\"50\",\"Street\":\"Test straat\",\"Structure\":null,\"Entrance\":null,\"Floor\":null,\"District\":null,\"City\":\"TestCity\"},\"PaymentDetails\":{\"CustomerCashAmount\":2.7,\"Code\":\"iDEAL\",\"ElectronicalPaid\":true},\"Discounts\":[{\"Name\":null,\"Price\":0.0}]}",
CURLOPT_HTTPHEADER => array(
"authorization: Basic Ihavetobechanged",
"content-type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
JavaScript Samples
Sending empty order (will result in error)
var settings = {
"async": true,
"crossDomain": true,
"url": "http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/",
"method": "POST",
"headers": {
"authorization": "Basic ineedtobechanged",
"content-type: application/json",
"cache-control": "no-cache"
},
"data": "{}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Sending Full test order
var settings = {
"async": true,
"crossDomain": true,
"url": "http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/",
"method": "POST",
"headers": {
"authorization": "Basic ineedtobechanged",
"content-type: application/json",
"cache-control": "no-cache"
},
"data": "{\"OrderInfo\":{\"ExternalToken\":\"TESTTOKEN009\",\"StoreCode\":\"150A\",\"ASAP\":false,\"CustomerComment\":\"Test order\",\"CustomerPickupDateTime\":null,\"RiderPickupDateTime\":null,\"ExternalLogisticsJobTrackingID\":null,\"ExpeditionType\":2,\"CreatedDateTime\":\"2017-10-03T16:05:51.8706132+02:00\",\"ExpiryDateTime\":\"2017-10-03T16:10:51.8711135+02:00\",\"DeliveryDateTime\":\"2017-10-03T16:40:00+02:00\",\"ForcedClientOrderStatus\":null},\"Products\":[{\"BindingID\":\"1337\",\"Quantity\":1,\"SingleProductPrice\":96.0,\"RowPrice\":98.0,\"CategoryName\":\"Test product group\",\"Name\":\"Test product\",\"ProductComment\":\"This is a test product\",\"Choices\":[{\"BindingID\":\"a1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test addon\"},{\"BindingID\":\"t1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test topping\"}],\"BoundProducts\":null,\"Discounts\":[{\"Name\":null,\"Price\":0.10}],}],\"CostInformation\":{\"SubTotal\":98.0,\"DeliveryFee\":2.5,\"ServiceFee\":0.0,\"GrandTotal\":100.50},\"LocalInfo\":{\"PlatformName\":\"TEST\"},\"Customer\":{\"Email\":\"spam@cashdesk.nl\",\"FirstName\":\"Bas\",\"LastName\":\"Tester\",\"CompanyName\":\" CashDesk\",\"PhoneNumber\":\"0612345678\"},\"WaiterDetails\":null,\"DeliveryDetails\":{\"ZipCode\":\"1111AA\",\"Latitude\":0.0,\"Longitude\":0.0,\"FlatNumber\":null,\"Room\":null,\"Number\":\"50\",\"Street\":\"Test straat\",\"Structure\":null,\"Entrance\":null,\"Floor\":null,\"District\":null,\"City\":\"TestCity\"},\"PaymentDetails\":{\"CustomerCashAmount\":2.7,\"Code\":\"iDEAL\",\"ElectronicalPaid\":true},\"Discounts\":[{\"Name\":null,\"Price\":0.0}]}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
C# Samples
Sample uses the RestSharp library
Sending empty order (will result in error)
var client = new RestClient("http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "Basic ineedtobechanged");
request.AddHeader("content-type", "application/json");
request.AddParameter("undefined", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Sending Full test order
var client = new RestClient("http://dev-api.harmony.cashdesk.nl/v1/stores/150A/orders/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "Basic ineedtobechanged");
request.AddHeader("content-type", "application/json");
request.AddParameter("undefined", ""{\"OrderInfo\":{\"ExternalToken\":\"TESTTOKEN009\",\"StoreCode\":\"150A\",\"ASAP\":false,\"CustomerComment\":\"Test order\",\"CustomerPickupDateTime\":null,\"RiderPickupDateTime\":null,\"ExternalLogisticsJobTrackingID\":null,\"ExpeditionType\":2,\"CreatedDateTime\":\"2017-10-03T16:05:51.8706132+02:00\",\"ExpiryDateTime\":\"2017-10-03T16:10:51.8711135+02:00\",\"DeliveryDateTime\":\"2017-10-03T16:40:00+02:00\",\"ForcedClientOrderStatus\":null},\"Products\":[{\"BindingID\":\"1337\",\"Quantity\":1,\"SingleProductPrice\":96.0,\"RowPrice\":98.0,\"CategoryName\":\"Test product group\",\"Name\":\"Test product\",\"ProductComment\":\"This is a test product\",\"Choices\":[{\"BindingID\":\"a1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test addon\"},{\"BindingID\":\"t1337\",\"Quantity\":1,\"Price\":1.0,\"Name\":\"Test topping\"}],\"BoundProducts\":null,\"Discounts\":[{\"Name\":null,\"Price\":0.10}],}],\"CostInformation\":{\"SubTotal\":98.0,\"DeliveryFee\":2.5,\"ServiceFee\":0.0,\"GrandTotal\":100.50},\"LocalInfo\":{\"PlatformName\":\"TEST\"},\"Customer\":{\"Email\":\"spam@cashdesk.nl\",\"FirstName\":\"Bas\",\"LastName\":\"Tester\",\"CompanyName\":\" CashDesk\",\"PhoneNumber\":\"0612345678\"},\"WaiterDetails\":null,\"DeliveryDetails\":{\"ZipCode\":\"1111AA\",\"Latitude\":0.0,\"Longitude\":0.0,\"FlatNumber\":null,\"Room\":null,\"Number\":\"50\",\"Street\":\"Test straat\",\"Structure\":null,\"Entrance\":null,\"Floor\":null,\"District\":null,\"City\":\"TestCity\"},\"PaymentDetails\":{\"CustomerCashAmount\":2.7,\"Code\":\"iDEAL\",\"ElectronicalPaid\":true},\"Discounts\":[{\"Name\":null,\"Price\":0.0}]}"", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);