Posting Order Information to a Custom Script
One of the rule actions that you trigger on events is to send your order details to a third-party endpoint. This is very helpful if you are wanting to keep track of inventory or perform some custom function when something happens to an order (when a shipment is added or it’s put in the Completed folder, for example).
Order Data Format
The order data is sent in JSON format via POST to your custom url with the field name order. The format looks like this.
The easiest way to test this functionality and see the data returned is to setup a temporary request bin at http://requestb.in/. Then setup a rule and use the testing mechanism to send some order data to this url. You can then inspect it to see exactly what you’ll be getting. To send immediately, after you perform the test, go to View Appointments and run the pending “Send Order To Website” action. If there’s an error, you’ll see the response returned. While testing, you may want to set your response status code to 400 so that you can continue to run the appointment over and over while making sure everything returns correctly.
Order Desk expects your script to return a status code of 200 or 201. If your script returns a status code higher than 201, the post will be considered failed and will be retried up to five times over the course of two hours. After that, you’ll have to manually retry it from the View Appointments page.
Order Desk will pass in a “X-ORDER-DESK-STORE-ID” header with the ID of your store. You can use this to help avoid any spoofing. For extra security, set an API key (Order Desk Pro only) and another header will be set called “X-ORDER-DESK-HASH”. This will be an hmac encoded string of the order value being posted. Here’s some sample PHP code to ensure that the posted order details came from Order Desk: