I'm attempting to send orders to a third-party ERP system when orders are finalized (in the payment callback).
Normally this works fine when I synchronously fire my integration, but I wish to queue this using Hangfire.io (so that outages at the third-party don't result in lost orders).
This works by queueing a static method, but it looks like a licensing check within TeaCommerce fails when I try and save the order (with some info returned back from the ERP system), presumably because there's no request hostname set;
System.NullReferenceException: Object reference not set to an instance of an object.
at TeaCommerce.Api.Web.Infrastructure.Licensing.LocalHostLicense.IsFeatureLicensed(Feature feature)
at TeaCommerce.Api.Infrastructure.Licensing.LicenseService.ValidateLicenseFeatures(Feature[] features)
at TeaCommerce.Api.Models.Order.Save()
Does my diagnosis look correct, and is there a way round this?
You are right about that. What we normally do is to make a reqauest to a URL for a surface controller and then have a scheduled task run it over and over again to communicate with external systems but still have a request for the license check.
Thanks Anders... I'd normally do similar for scheduled tasks, but in this case I need to call an action when an order is finalized (as the payment callback happens).
I can't see a way to "get all finalized orders that haven't been sent to the ERP yet", if I were to run this from a controller? I already set a custom order property with the ERP order reference, but I can't see how to query unsent orders?
In the OrderFinalized event save the order id as a text file in a folder. Then have the service see which orders havent been send and delete the file on disk when send to ERP. Simple as that :)
Running outside a Request context
I'm attempting to send orders to a third-party ERP system when orders are finalized (in the payment callback).
Normally this works fine when I synchronously fire my integration, but I wish to queue this using Hangfire.io (so that outages at the third-party don't result in lost orders).
This works by queueing a static method, but it looks like a licensing check within TeaCommerce fails when I try and save the order (with some info returned back from the ERP system), presumably because there's no request hostname set;
Does my diagnosis look correct, and is there a way round this?
Phil
Hi Phil
You are right about that. What we normally do is to make a reqauest to a URL for a surface controller and then have a scheduled task run it over and over again to communicate with external systems but still have a request for the license check.
Thanks Anders... I'd normally do similar for scheduled tasks, but in this case I need to call an action when an order is finalized (as the payment callback happens).
I can't see a way to "get all finalized orders that haven't been sent to the ERP yet", if I were to run this from a controller? I already set a custom order property with the ERP order reference, but I can't see how to query unsent orders?
Phil
In the OrderFinalized event save the order id as a text file in a folder. Then have the service see which orders havent been send and delete the file on disk when send to ERP. Simple as that :)
Genius - I feel so stupid for not thinking of that!
is working on a reply...