Skip to main content
When the POS sends a customer’s return to POST /v1/discounted-purchases, Lobyco puts a recommended amount in each returned product’s price. It is what the customer paid for those units, less what earlier returns already paid back. The discount stays with the items the customer keeps. The POS can pay back that amount or a different one. The flow is on Returns and refunds.
A return cannot be priced together with a sale. If one request holds both returned products and products the customer is buying, the endpoint returns an error. Send the sale in a separate request.

What the customer paid

Lobyco starts from the original sale, as the POS recorded it.
  • A product-level discount is already taken off the product’s price.
  • A basket discount is not. Each product’s share of it is in discountAllocations.
  • What the customer paid for a line is its price, less its share of any basket discount.
  • A cancelled line (isCancelled: true) is netted out against the product’s other lines.

How the amount is split

  • Full-price lines first. When the same id is on several lines, returned units come from lines without a discount first.
  • Equal shares within a line. Units on one line share what is left on it, rounded down to the cent.
  • The last unit gets the rest. Rounding never loses or adds a cent.
  • Returns add up. Each recommendation counts the earlier returns of the sale, at the amount the POS actually paid back.
  • What was not paid back moves on. Lobyco assumes the units the customer paid for come back first. If the POS paid back less than recommended, the rest goes to the next units that come back.
  • Never more than was paid. If the POS paid back more than recommended, the next units are recommended at less, down to 0.00.

Examples

Each example is one sale, SALE-1, and what Lobyco recommends as the customer brings items back. The same sales are followed through to the coupons on Coupon refund.

A multi-buy returned in two visits

The 3 for 2 is taken off the line, so the customer paid 10.00 for 3 yoghurts. If the POS pays back 5.00 for the first yoghurt instead, the other two are recommended at 2.50 each. The refunds still add up to the 10.00 the customer paid.

The same multi-buy on separate lines

The discount sits on the third line only. The first two lines cost 5.00 each, and the third cost nothing. The first refund is 5.00 here, against 3.33 when the yoghurts are on one line. Lobyco keeps each line’s own price and does not merge lines. The sale is the one from the previous example, with the yoghurts on separate lines. The customer brings them back one at a time, and the POS pays back nothing for the first. Lobyco assumes the first yoghurt back was one the customer paid for, so the 5.00 the POS kept back moves to the next one. A cashier may expect 5.00 for the second yoghurt. If the POS pays back 5.00 instead, the last yoghurt is recommended at 5.00. Either way, the refunds add up to the 10.00 the customer paid.

A basket coupon

Each product carries a share of the basket discount: coffee 2.50, cheese 3.33 and wine 4.17. Once the coffee is back, the basket is below 50. The customer keeps the discount on the cheese and the wine anyway.

A product the coupon excludes

The coupon is “10% off when you spend 100 or more, tobacco excluded”.
The coffee carries a 15.00 share of the discount and the milk 2.00. The cigarettes carry none.

A Mix & Match meal deal

The coupon is a meal deal: “a sandwich, a drink and crisps for 6.00”. The customer also buys a second drink at full price.
In this sale the discount is split as 0.80 on the sandwich, 0.40 on the drink line and 0.30 on the crisps. It is taken off each line’s price.

Buy one, get one free

Two coupons of the same offer

If each coffee were on its own line, the two full-price coffees would come back first, at 50.00 each. The two free ones would follow at 0.00.

API reference

Endpoint documentation: Discounts and Purchases.
Last modified on October 29, 2026