We don't seem to be raising a sales order saveend event when a sales order is processed, which is why the webhook is not firing. We have other events in the business logic to respond to a process event - but out of the box not a webhook.
Ideally you probably want to create a new event - salesorder.processed so you can subscribe to that and know that only when a sales order is processed is that subscription going to be pushed.
You do that by adding to the WebHookEvents collection of the REST API:
- Code: Select all
JiwaFinancials.Jiwa.JiwaServiceModel.RESTAPIPlugin.WebHookEvents.Add(new JiwaFinancials.Jiwa.JiwaServiceModel.WebHookEvent { Name = "salesorder.processed", Description = "Occurs when a sales order is processed" });
And then you want to handle the Processed event of the sales order business logic and in there trigger the webhook:
- Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)JiwaBusinessLogic;
salesOrder.Processed += SalesOrder_Processed;
}
private void SalesOrder_Processed(object sender, System.EventArgs e)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
string body = salesOrder.DTO_Serialise().ToJson<JiwaFinancials.Jiwa.JiwaServiceModel.SalesOrders.SalesOrder>();
JiwaFinancials.Jiwa.RESTAPIPlugin.BusinessLogicPlugin.Webhook(salesOrder.Manager, body, "salesorder.processed", "REST API");
}
Attached is a plugin which does this - tested with Jiwa 7.2.1. SR 17 and the REST API plugin version 7.2.1.52.
Note that you'll need to create a subscription which subscribes to the salesorder.processed event, and not the salesorder.updated event like you currently are. You can also subscribe to both if you like.