Apply Customer Discount on Sale creation

aaronaaron Posts: 44Member
So I still can't quite figure out how to apply a discount when creating a sale through the API.

The user associated with the sale has a Discount. How do I make sure that his discount is applied when creating the sale?

2 comments

  • Adrian SamuelAdrian Samuel Posts: 416Moderator, Lightspeed Staff moderator
    Hey @aaron, thank you for your question!

    You'll need to make two calls. To do this efficiently I would suggest a GET and then a POST.

    You'll need to first do a GET to query the customer. You can do this with the following request url:

    https://api.lightspeedapp.com/API/Account/{{AccountId}}/Customer/{{CustomerId}}.json?load_relation=["Discount"]

    You'll then need to get the discountID object value from the response and then put that in your POST request body

    So your request url would be

    https://api.lightspeedapp.com/API/Account/{{AccountId}}/Sale

    {
        "employeeID": 1,
        "registerID": 1,
        "shopID": 1,
        "customerID": 16,
        "completed": true,
        "SaleLines": {
            "SaleLine": 
            {
                "itemID": 1,
                "unitQuantity": 1,
                "discountID": 10
            }
           
        },
        "SalePayments": {
        	"SalePayment": {
        		"amount": 100,
        		"paymentTypeID": 1
        	}
        }
    }


    Let's say the SalePayment.amount was greater than the value on the sale then the response body will return a Sale.change object which will tell you how much they've overpaid by.

    I hope this helps!






Sign In or Register to comment.