To Implement Webhooks for a Commerce Connector

In a commerce connector, you can implement real-time import through webhooks for particular entities. For these entities, you need to adjust the connector class and the processor classes that correspond to these entities.

For details about the connector class and processor classes, see Connector Class and Processor Classes. For information about the implementation of processor classes and the connector class, see Step 8: Implementing the Processor Classes and Step 9: Implementing the Connector Class of To Create a Connector for an External System.

Implementing Webhooks in the Connector

  1. Make sure that the connector class implements the following methods: StartWebhook(), ProcessHook(), and StopWebhook().
  2. For each processor class that needs to support real-time import through webhooks, make sure that the processor class supports the import of records from MYOB Advanced by making sure the following requirements are met:
    • The BCProcessor attribute of the processor has the Direction property set to SyncDirection.Bidirect or SyncDirection.Import.
    • The FetchBucketsForImport(), GetBucketForImport(), MapBucketImport(), SaveBucketImport(), and PullEntity() methods of the processor have been implemented.
  3. For each processor class that needs to support real-time synchronization through push notifications, modify the BCProcessorRealtime attribute of the processor so that the HookSupported property is set to true. In the WebHookType property, specify the type of the object to be used for deserialization of the JSON object received in the webhook. In the WebHooks property, specify the list of webhook scopes.

    The following code shows an example of the attribute for the customer processor class of a WooCommerce connector.

    ...
    [BCProcessorRealtime(PushSupported = false, HookSupported = true, 
            WebHookType = typeof(CustomerData),
            WebHooks = new String[]
            {
                "customer.created",
                "customer.updated",
                "customer.deleted"
            })]
    public class WooCustomerProcessor : BCProcessorSingleBase<WooCustomerProcessor, 
      WooCustomerEntityBucket, MappedCustomer>, IProcessor
    {
      ...
    }
  4. Build the project of the extension library.