Despatched / Cancelled Webhooks
It's possible to register a webhook or callback so that you can be notified when an order has been despatched or cancelled. This saves the need to poll the API for updates.
To do this after creating an order you will need to add a Connect action. This can be done using the Orders/ConnectionActions PUT method
https://api.mintsoft.co.uk/swagger/ui/index#!/Order/Order_UploadConnectAction
e.g use the order ID returned from CreateOrder
/api/Order/20285/ConnectActions - PUT
{ "Type": "API", "SourceOrderId": "202-0672909-5683525", "Complete": false, "ExtraCode1”: "https://api.yoursystem.com/callback/OrderDespatched",
"ExtraCode2": "https://api.yoursystem.com/callback/OrderCancelled",
}
SourceOrderId - The Order Number in the system that the order came from
ExtraCode1 - The URL to call when the order has been despatched
ExtraCode2 - The URL to call when the order has been cancelled
You will then get a POST request back to the specified address upon despatch with the same Order Json found on this call:
https://api.mintsoft.co.uk/swagger/ui/index#!/Order/Order_Get
Delivered Webhook - Specific Courier Support Only
If you use a courier that has delivery updates back into Mintsoft and you have the Tracking Events module enabled its also possible to get webhooks back when the Parcel is delivered. To do this you just need to populate ExtraCode3 when adding a connect action
e.g.
{ "ExtraCode3": "https://api.yoursystem.com/callback/OrderDelivered" }
The system will then call that URL once the parcel has been delivered with all the events relating to that delivery
Split Webhook
If an order is split at a point after creation you can register a webhook to split out about that split.
To do this you just need to populate ExtraCode5 when adding a connect action
e.g.
{ "ExtraCode5": "https://api.yoursystem.com/callback/OrderSplit" }
The system will then call that URL once an order is split into multiple parts.
You'll get JSON containing the orginal order and the new split order with all the details you need to see how the order has been split
[{
"Order": {}, // Full Details of the Order
"SplitOrder": {}, // Full Details of the Split Order
"OrderId": 78025,
"SplitOrderId": 78026,
"ID": 1,
"LastUpdated": "2020-10-05T23:36:31.5231781",
"LastUpdatedByUser": "groveslu"
}]
Additional Security Options:
When making the webhook calls you could provide an API key in the url to verify where its come from.
e.g
https://api.yoursystem.com/callback/OrderDespatched?APIKEY=fe14830f-0980-46c6-a540-04c20a26b01c
Alternatively we can provide a dedicated value in the Authorization header.
This will be taken from ExtraCode4
So if the Webhook handler was secured by Basic Auth you could supply that value in the ExtraCode4 to be used in the Authorization header.
username password
becomes then username:password
Base64 encoded = dXNlcm5hbWU6cGFzc3dvcmQ=
e.g.
{
"ExtraCode4": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
}
Comments
0 comments
Article is closed for comments.