Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phil Dye 149 posts 325 karma points
    Sep 22, 2015 @ 15:19
    Phil Dye
    0

    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;

    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?

    Phil

  • Anders Burla 2560 posts 8256 karma points
    Sep 24, 2015 @ 06:32
    Anders Burla
    0

    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.

  • Phil Dye 149 posts 325 karma points
    Sep 24, 2015 @ 08:01
    Phil Dye
    0

    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

  • Anders Burla 2560 posts 8256 karma points
    Sep 24, 2015 @ 08:46
    Anders Burla
    100

    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 :)

  • Phil Dye 149 posts 325 karma points
    Sep 24, 2015 @ 09:02
    Phil Dye
    0

    Genius - I feel so stupid for not thinking of that!

Please Sign in or register to post replies

Write your reply to:

Draft