WebHook sale

raphaelraphael Member Posts: 39


we are currently using web hook on order Paid so we can catch when a sale is done on eCom site to get the sale in retail.

However, the retail sale is not created "on the fly". The first time the Webhook call our endpoint, we can't find the retail sale. We catch this error, it's a pain. The seconde time the Webhook call it's OK.

Is there another web hook we should use? 

I guess the answer is no, as usual. Always a pain working with lightspeed.


  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 940 moderator

    Hi @raphael,

    Thank you for contacting us.

    I've tested this and when the webhook order/paid is sent the sale is created almost instantly in Retail. Here you can see the time of creation in Retail:

    and here the webhook time:

  • raphaelraphael Member Posts: 39

    @LucienVersendaal ,

    I confirm that we had to code an exception path for the first time we request the retail sale from that WebHook because most of the time we could not find the retail sale from the Ecom sale.

    Maybe the reference number in the retail sale is not fill on sale creation...

  • gregaricangregarican Member Posts: 715 

    @raphael if I were in this situation I'd just code in a slight pause in the routine, so that way the two systems have time to sync up. For example, if it only takes 2-3 seconds for them to sync up and your code is currently not pausing at all then that could lead to the disconnect. I'd just code in a 5-second delay before checking the other system...

  • raphaelraphael Member Posts: 39


    not a big fan of thread sleep.

    We prefer return an error to Lightspeed, and try it again on the next call. In other words, the payload goes to lightspeed server not our..

    If their end was properly code, we would not have that problem.

  • gregaricangregarican Member Posts: 715 

    Rarely will you encounter a real-time-to-the-millisecond update between two different systems. Your call regarding how you handle it, but keeping in mind Lightspeed's stingy API call limits (Retail is 1 GET/second if I'm not mistaken), if it were me I'd just sleep for 5 seconds to play it safe. And to not hit the API to hard with multiple calls for the same item.

  • raphaelraphael Member Posts: 39

    Yep, but they control their end, so, I think we should have an other webhook available.

    My question was.

    "Is there another web hook we should use? "


    They could only trigger the webhook after the retail sale creation completed *or sleep 5 sec ;)

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 940 moderator


    Maybe you can use the invoice/updated webhook and check for the status.

  • raphaelraphael Member Posts: 39



    what do you mean by "maybe"? Have you tried it? I mean, would it be the same as right now, as we are currently plugged on the paid event?

    Also as a support answer, this is not a great one if you provide a solution that you're not sure is working; what's the "maybe"?

    Can you please make escalade this problem? Sleeping thread on our side is not the right solution.

    Getting all invoice updated event neither, as it will consume way too many resources on each side.

    Right now, we are receiving a lot of false error because of this, and it's a pain for our bug report system. 

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 940 moderator


    Sorry, this is just a bad word choice from my side. In Dutch, we have a different meaning of the word "maybe", more like "you can also use".

    I agree on what @gregarican is saying, is to build a slight pause in the routine, so that way the two systems have time to sync up.

  • raphaelraphael Member Posts: 39
    edited January 12

    I see now why it's a mess working with all the different lightspeed systems.

    When all the time you patch instead fixing, this is what you got.

  • gregaricangregarican Member Posts: 715 
    edited January 12

    @raphael I'm not sure how it's "a mess" that two different systems communicate with each other. Since as far as I know, I'm assuming that Retail and Ecom are two separate platforms. A transaction posting against one system will logically need to update the other system. And this can't be instantaneous no matter how you slice it.

    Sure, if Lightspeed Omnichannel was a monolithic system with just a single datastore life would be easier. Similar to how Shopify POS and E-com are just presumably hitting a single datastore. But right now that's not the way things work.

    To me, simply inserting a C# one-liner like Thread.Sleep(1000) isn't too big of an inconvenience....

Sign In or Register to comment.