Passing Data After a Retail & E commerce Sale?

I am looking to pass a data after each sale is made into a 3rd party reputation marketing system.
Data needed would be:
Looking to set this up through Zapier but did't see anywhere in light speed to add a web-hook after a sales is made.
Can anyone point me in the right direction to accomplish this and would these be separate API's for E commerce and Retail Sale?
Thanks Scott
Data needed would be:
- Customer First Name
- Customer Email
- Customer Cell Phone
- Store Location Whether That Be An ID of some sort
- Employee Name That Made The Sale
Looking to set this up through Zapier but did't see anywhere in light speed to add a web-hook after a sales is made.
Can anyone point me in the right direction to accomplish this and would these be separate API's for E commerce and Retail Sale?
Thanks Scott
Tags:
37 comments
Just looking for that documentation and what all data can be passed after the sale.. Just needing the above 5 bullets basically.
Thanks for the help.
A sender could ping LS Retail's API to pull recent sales. Based on a polling period against a timestamp of the sale in LS Retail. Here's a link to the LS Retail Sales API --> https://developers.lightspeedhq.com/retail/endpoints/Sale/.
You would likely need to sort the sales in descending createTime order, and could restrict the createTime to a range within your polling period that makes sense. And you also would need to load_relations if you need to include additional data fields apart from the general sales data set. The employee and customer contact details come to mind there.
Hope this helps a little at least!
https://api.lightspeedapp.com//API/Account/{accountID}/Sale/{saleID}
@scott74 , as Greg has said you could set up a chron job to dynamically get sales data since Retail doesn't have webhooks
Also you can get your accountID from the account endpoint here:
https://developers.lightspeedhq.com/retail/endpoints/Account/
Adrian Samuel
Software Developer
Lightspeed HQ
Looks like that requires a token. I only saw something in my account with tokens when I enabled ecom. Do I have this with the retail side to connect to the API?
I had signed up for a trial account to test this but wondering if you have another way of testing for agencies seeing what they might be able to do for clients or best way to go about that? My trial is 14 days and have one of my guys who is a little better with the API stuff look at this.
Another option is if you guys have SFTP where you can generate a list of fields and a URL to send that to each day. Is that possible with the system?
https://developers.lightspeedhq.com/retail/authentication/authentication-overview/
If you login to your account could simply pass the API URL in the browser. Something like this:
We don't have a SFTP but you can just use the API to replicate the same process.
Adrian Samuel
Software Developer
Lightspeed HQ
Not looking to use this for myself, just a demo account to setup integrations for future clients who use this system.
Thanks, Scott
Adrian Samuel
Software Developer
Lightspeed HQ
The redirect URI will be the page that Lightspeed will redirect you to send the access token once you authenticate your account with the app. If you're in testing you could use https://localhost otherwise you want to use the hosted IP/domain that your app is associated to
An example of this can be found here: https://developers.lightspeedhq.com/retail/authentication/authentication-overview/#requesting-a-temporary-token
Adrian Samuel
Software Developer
Lightspeed HQ
I used the Employee:all scope but wondering which permissions would be needed just to pull the register name, customer data and employee that made the sale for scopes instead of using all. This way if the correct way is sending the client a link it doesn't show as full access. Or is it best they make you a user on the account temporarily ?
I have setup a test in postman using local host and just used my agency domain for the first URL. Just trying to get a grip on what I need to do if making this work live for a client and how to go about creating it for them if I need to login their account as a user or create these apps in my account. Please advise
https://api.lightspeedapp.com/API/Account/{Account_ID}/Sale?load_relations=["Customer.Contact"]
But looks like it returns the RegisterID as register 1 and the employeeID as 1 as with the ShopId of 1
Anyway to get this to return full name of and email of employee and full name of register so I can send this data to the correct Reputation account and know/attache the correct employee?
Also I need to split this info into individual transactions and if I run a cron it will all be pulled in one big xml... Any ideas on this. See here
https://www.useloom.com/share/80f8127979a340f48359d7f559dde776
Q: Thanks..got token working but How do you keep it from expiring?
A: You can't stop the access token from expiring, you'll have to periodically refresh it in your application every 30 mins or so. This is explained in our documentation here: https://developers.lightspeedhq.com/retail/authentication/refresh-token/
If you try to make a request when the token expires receive a 401 error...you could use this to then re-authenticate your request. To make it easy for you, you could programatically create a timer for this event.
Q: I used the Employee:all scope but wondering which permissions would be needed just to pull the register name, customer data and employee that made the sale for scopes instead of using all. This way if the correct way is sending the client a link it doesn't show as full access. Or is it best they make you a user on the account temporarily ?
A: To limit your app access scopes, try these: employee:register, employee:customers_read.
You can read more about access scopes here: https://developers.lightspeedhq.com/retail/authentication/scopes/
You won't be able to set yourself on another account as a user temporarily because you'll need to be connected first to do that and it wouldn't serve any purpose for you connecting to their data via the API.
Q: I planned on setting this up in zapier so still a little confused on what URL's you would use. We would not be have any website associated, just using to pass customer data after a sale through zapier.
I have setup a test in postman using local host and just used my agency domain for the first URL. Just trying to get a grip on what I need to do if making this work live for a client and how to go about creating it for them if I need to login their account as a user or create these apps in my account. Please advise
A: Well you need a URL to authenticate the app in the first place, after that it isn't going to be useful, it's only to get the access token to connect your app to the API for their account. If you have other customers in future you'll want to have a link that people can click on and connect to in order to have the same level of access
As long as you have an ongoing server hosted somewhere running your app you shouldn't need to worry. You'll refresh the tokens in the app programatically as well.
To get the Employee/Register/Shop name you'll need to make a read/GET request to the relevant endpoints like so:
You can read more about this here: https://developers.lightspeedhq.com/retail/endpoints/Employee/
You'll need to split the XML/JSON data in an array containing the data from each sale.
From the video you've shared, it looks like you've manually inserted the token for the app to work in Zapier and you're letting zapier do all the heavy lifting regarding the cron job.
You should create a middleware between the zapier apps you want to connect with so that you can automate the process of collecting the employee, shop and register data as well as splitting the data back in chunks.
Unless there are tools out there that I'm not aware of, you'll need to use the Zapier CLI instead of the web builder to do this.
You can read more about this here:
https://zapier.com/developer/documentation/v2/cli-vs-web-builder/
Adrian Samuel
Software Developer
Lightspeed HQ
So to get the Register and Employee name, you have to know their ID first then do some filtering If EmployeeID is 1 "Look that up first via a get to see what it returns" then call/Pass it as John Doe
I seem to get an error when trying to use those links. Going to need to hire some help for this one. Zapier said it looks like someone, maybe you guys started an APP for lightspeed. If this was you guys, any time frame on finishing or implementing one if it was not you?
Adrian Samuel
Software Developer
Lightspeed HQ
so the full request would be
Adrian Samuel
Software Developer
Lightspeed HQ
1. Is there a way to pull sales only for todays date by entering something in this URL?
https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Sale.json?load_relations=["Customer","Customer.Contact"]
2. That URl pulls alot of data and was reading something about your API with bucket limit. Is there a way to only make that return the Customer data, register, employee etc.. instead of everything so I'm not hitting the API has hard or does that matter?
3. If leaving it the way it is should I have a problem with any limits if pulling the sales data each data just once for 22 store locations.
Guessing maybe 500 sales or so roughly. Would have to ask the business. Thanks.
Getting this going with Integromat btw. Seems to be doing the trick.
Thanks for the help again
And you can definitely pull sales by a specified date range. You provide that as a URL query parameter. See https://developers.lightspeedhq.com/retail/introduction/parameters/ for details. Here is specifics in terms of querying the Sale endpoint by date --> https://community.lightspeedhq.com/en/discussion/comment/5596#Comment_5596.
And as an FYI to @jamesratcliffe and crew, there appears to be an impacting systems issue aside from degradation in the LS Retail web client. Even my API client was getting the following HTTP response back when testing out the timeStamp scenario listed above. Just a heads-up!
And also getting this...
Looks like have to add a relation I guess. This seemed to work.
https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Employee/1.json?load_relations=["Contact"]
Got Employee and Shop URL's working but not Register to pull down the register name for some reason.
Thanks Scott
If you give full details of the request and the response, I might be able to help
Adrian Samuel
Software Developer
Lightspeed HQ
That's great to hear! An example for today's sales for that relation would be like this:
This will return all sales today from UTC time midnight through to midnight. If your shop is not on UTC you want to add an offset at the end of each timestamp
Make sure you encode your url (your software library might already do this for you)
Adrian Samuel
Software Developer
Lightspeed HQ
Id prefer to run this maybe every 5 minutes or so so the customers get their receipts through messenger and feedback request quicker but was not sure how that would look with the bucket limit and would have to figure out some sort of filter to only look for new sales which I think I can probably do but would that rack up the limit restrictions? Would be about 144 request a day as the stores are open from 9am to 9pm
Thanks for the help again
Let's say you pull sales every hour. And there are 80 sales. That's only a single page of results, since you can have up to 100 records in a single page pull. Let's say you have 250 sales in that hour. Then that would be a total of 3 page pulls. But even then that operation would only take a few seconds.
For our one company we have on LS Retail, we required a lot of extensive data to be used for enhanced sales, customer, and inventory reporting. So I pull records from numerous endpoints into a SQL Server DB on a daily basis. Usually pulling in all of this after-hours. We only have previous business day reporting, but at least the reports render quickly and there aren't any gotchas
PS.... I have this hooked up to send data to FB Messenger if the customer is a subscriber of the bot. Was looking to Grab the Title, Description and Image of the products bought in put in a Carasoel Card why a link button going back to the product.
Didn't see where in the API the Image of the product that the business has uploaded and description can be pulled. Did I overlook?
Was also wondering if receipts are housed anywhere online in a URL so could link to that from messenger instead of building one out?