Webhooks
- Martin Fransson
- josefin.kvillert (Unlicensed)
- Anton Bildh
Introduction
You can create webhooks in Extend Commerce Backend. The webhook will make a call based on the events (triggers) that you define on the webhook.
Add / edit Webhooks
You find Webhooks under the gear wheel in the top right corner in Extend Commerce Backend.
To edit Webhooks, click on the pen on the webhook you want to edit.
To create a new Webhook, click on the blue button 'Create Webhook'.
In this view you can then create or edit the Webhook.
Name: | The name is a public name that you add to the hook, used in the list of hooks, so you can identify the hook. |
Tech contact (email): | A email to a technical contact for the webhook. |
Callback URL: | Here you add your URL to where we will send the webhook |
Secret: | Secret, here you add a secret. Extend Commerce will sign the body in the hook using SHA256 with your secret. The signed value is added in request header 'ms-signature'. The body should be verified before processing to avoid spam calls |
Filter event on: | Here you can limit the hook on different warehouses. If you for example need to have a hook on available balance, and your installation in Extend Commerce Backend handles several warehouses. you can limit the hook to only handle balances for a specific warehouse. |
Aktivt: | Sant / Falskt. True / False |
Trigger on events: | Here you mark on which events you want the Hook to fire on. Following triggers are available:
|
Example
The content in Notifications array will be different depending on the Action:
PurchasePartiallyDelivered:
{
"Id": "6e249eebb818463086ae0dda6eeba7b2",
"Attempt": 1,
"Properties":
{ "NotificationId": "3b3fd4a6-36d5-46fe-8a3f-e73532529db3" }
,
"Notifications": [
{
"Action": "PurchasePartiallyDelivered",
"Details":
{ "OrderNumber": "RP-101", "Warehouse": "GreenWarehouse" }
}
]
}
ProductCreated:
{
"Id": "13f078bcbe2243dc997655ed2cdbbdf7",
"Attempt": 1,
"Properties": {
"NotificationId": "90c6340b-1f5c-49e0-9cee-45df5dd145c2"
},
"Notifications": [
{
"Action": "ProductCreated",
"Details": {
"ProductNumber": "Financial Invoice"
}
}
]
}
Signing
To make sure the webhook is sent by Extend Commerce it is signed. It is optional to use the signature for verification.
Body is signed using SHA256 with clientsecret. The signed value is added in header 'ms-signature'
ClientSecret:
Body: the full request body
SignatureFromHeader: request header 'ms-signature'
Sample pseudo code:
byte[] secret = Encoding.UTF8.GetBytes(ClientSecret);
using (var hasher = new HMACSHA256(secret))
{
byte[] data = Body.ToByteArray();
actualHash = hasher.ComputeHash(data);
}
byte[] expectedHash = FromHex(SignatureFromHeader).ToByteArray()
if(IsSecretEqual(expectedHash, actualHash))
{
//process web hook
}
Sample
ClientSecret = secret123
Body = {'test':'test2'}
BodyAsHex = 7B2774657374273A277465737432277D
ms-signature = sha256= 25FB6994568A75CD233E04BA1C653AF1BF476041CC543AF04F82CAAC482C201A
Example - complete list
ActionName | Description | Sample Json |
AvailableBalanceChanged | Available balance updated | {"Details":{"ProductNumber":"8684","Warehouse":"YX","AvailableBalance":22}} |
BalanceChanged | Balance updated | {"Details":{"ProductNumber":"7495","Warehouse":"YX","Balance":43,"EventName":"ItemChangeST","EventType":"BalanceAdjustment"}} |
CustomerChanged | Customer updated | {"Details":{"CustomerNumber":"603271"}} |
CustomerCreated | Customer created | {"Details":{"CustomerNumber":"817472"}} |
CustomerInvoiceChanged | Customer invoice updated | {"Details":{"InvoiceNumber":"1000001"}} |
CustomerInvoiceCreated | Customer invoice created | {"Details":{"InvoiceNumber":"1000002"}} |
OfferChanged | Offer changed | {"Details":{"OfferNumber":"OFF-217530"}} |
OfferCreated | Offer created | {"Details":{"OfferNumber":"OFF-212423"}} |
OrderCancelled | Order cancelled | {"Details":{"OrderNumber":"3339977","OrderType":"NormalOrder"}} |
OrderCreated | Order created | {"Details":{"OrderNumber":"3339887","OrderType":"NormalOrder"}} |
OrderDeliveryDataChanged | Order delivery date updated | {"Details":{"OrderNumber":"OC-2319","OrderType":"NormalOrder"}} |
OrderPicked | Order is pricked | {"Details":{"OrderNumber":"333841","OrderType":"NormalOrder"}} |
OrderReserved | Order is reserved | {"Details":{"OrderNumber":"339887","OrderType":"NormalOrder"}} |
PickingStarted | Picking is started at warehouse | {"Details":{"Order":{"OrderNumber":"802624","Warehouse":"ADR-1","Row":{"Position":10,"SubPosition":0,"ProductNumber":"4340-001","Unit":{"Quantity":1}}}}} |
PriceListWebHook | Price list has been updated | {"Details":{"PriceListName":"B2B-EUR"}} |
ProductChanged | Product has been updated | {"Details":{"ProductNumber":"172488"}} |
ProductCreated | Product created | {"Details":{"ProductNumber":"265A9AA"}} |
PurchaseCancelled | Purchase cancelled | {"Details":{"OrderNumber":"RP-70002034","Warehouse":"ADR-1"}} |
PurchaseCreated | Purchase created | {"Details":{"OrderNumber":"RP-70002830","Warehouse":"ADR-1"}} |
PurchaseDelivered | Purchase received | {"Details":{"OrderNumber":"50002245","Warehouse":"B-1"}} |
PurchasePartiallyDelivered | Purchase partially received | {"Details":{"OrderNumber":"95510","Warehouse":"BA"}} |
På denna sida: |
---|