Webhooks

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:

  • OrderPicked (Order is picked or delivered via direct delivery from supplier)
  • OrderReserved (Order is send to warehouse for picking)
  • OrderCancelled
  • BalanceChanged
  • AvailableBalanceChanged
  • OrderDeliveryDataChanged (Order data for delivery has changed)
  • PurchasePartiallyDelivered
  • PurchaseCancelled
  • PurchaseDelivered
  • ProductCreated
  • ProductChanged
  • OrderCreated
  • CustomerCreated
  • CustomerChanged
  • OfferCreated
  • OfferChanged
  • CustomerInvoiceCreated
  • CustomerInvoiceChanged



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

ActionNameDescriptionSample Json
AvailableBalanceChangedAvailable balance updated{"Details":{"ProductNumber":"8684","Warehouse":"YX","AvailableBalance":22}}
BalanceChangedBalance updated{"Details":{"ProductNumber":"7495","Warehouse":"YX","Balance":43,"EventName":"ItemChangeST","EventType":"BalanceAdjustment"}}
CustomerChangedCustomer updated{"Details":{"CustomerNumber":"603271"}}
CustomerCreatedCustomer created{"Details":{"CustomerNumber":"817472"}}
CustomerInvoiceChangedCustomer invoice updated{"Details":{"InvoiceNumber":"1000001"}}
CustomerInvoiceCreatedCustomer invoice created{"Details":{"InvoiceNumber":"1000002"}}
OfferChangedOffer changed{"Details":{"OfferNumber":"OFF-217530"}}
OfferCreatedOffer created{"Details":{"OfferNumber":"OFF-212423"}}
OrderCancelledOrder cancelled{"Details":{"OrderNumber":"3339977","OrderType":"NormalOrder"}}
OrderCreatedOrder created{"Details":{"OrderNumber":"3339887","OrderType":"NormalOrder"}}
OrderDeliveryDataChangedOrder delivery date updated{"Details":{"OrderNumber":"OC-2319","OrderType":"NormalOrder"}}
OrderPickedOrder is pricked{"Details":{"OrderNumber":"333841","OrderType":"NormalOrder"}}
OrderReservedOrder is reserved{"Details":{"OrderNumber":"339887","OrderType":"NormalOrder"}}
PickingStartedPicking is started at warehouse{"Details":{"Order":{"OrderNumber":"802624","Warehouse":"ADR-1","Row":{"Position":10,"SubPosition":0,"ProductNumber":"4340-001","Unit":{"Quantity":1}}}}}
PriceListWebHookPrice list has been updated{"Details":{"PriceListName":"B2B-EUR"}}
ProductChangedProduct has been updated{"Details":{"ProductNumber":"172488"}}
ProductCreatedProduct created{"Details":{"ProductNumber":"265A9AA"}}
PurchaseCancelledPurchase cancelled{"Details":{"OrderNumber":"RP-70002034","Warehouse":"ADR-1"}}
PurchaseCreatedPurchase created{"Details":{"OrderNumber":"RP-70002830","Warehouse":"ADR-1"}}
PurchaseDeliveredPurchase received{"Details":{"OrderNumber":"50002245","Warehouse":"B-1"}}
PurchasePartiallyDeliveredPurchase partially received{"Details":{"OrderNumber":"95510","Warehouse":"BA"}}




På denna sida: