Before you start
- The POS has the
memberIdof the checked-in customer and thecouponIdsthe sale applied, from whichever discount flow you use. - The POS has a
receiptIdfor the sale before it redeems. The same value is the idempotency key here and the receipt id on the recorded purchase, and the offline path depends on them matching.
The flow
1
Redeem the coupons
POST /v2/customers/{customerId}/coupons/redeemCall this once the sale has completed. Send four things:- The
Idempotency-Keyheader, set to thereceiptId. It makes a retry safe, lets multi-use coupons count correctly, and is what a later refund refers to. storeId, the store where the sale happened.coupons, each with thevalueit granted.basketValue, the basket total. Together with the store, it feeds the live statistics marketers see.
400 Bad Request listing the ones it could not find.2
[Optional] Release the reservation
POST /api/v1/customers/{customerId}/coupons/cancel-reservationIf the sale is abandoned before you redeem, release the coupons that were reserved for it. The customer can then use them at another POS or online straight away. Send thecouponIds and the same reservedBy the reservation was made with. A reservation made under a different reservedBy cannot be released this way. An unreleased reservation frees itself at its reservedUntil time.Returns and refunds
POST /api/v1/customers/{customerId}/coupons/cancel-redeem When a customer returns goods, the POS can give the coupons back, so the customer can use them again while the offer is still valid. Send theIdempotency-Key the coupons were redeemed with and the coupon ids to return. Lobyco does not work out which coupons a return affects. The POS decides, and it sends one request per original redemption, because a request cancels redemptions under one key only.
Offline redemption
Coupon retrieval and discount calculation need Lobyco online. Redemption does not. Sometimes the coupons were applied and the sale completed, but the POS cannot reach Lobyco to redeem them. Then put the coupon ids in thecouponIds field of the purchase you send to POST /v1/purchases. Lobyco redeems them when it loads the purchase.
For this to work, the purchase’s receiptId must equal the Idempotency-Key you would have used in the redeem call. The matching key is how Lobyco recognises coupons that were already redeemed online, so it redeems nothing twice.
Failure and edge cases
A redeemed coupon is one the redeem call returned in itscouponIds. Lobyco marks it as used and counts it against the offer’s redemption limits.
- The redeem call times out. Retry with the same
Idempotency-Key. Lobyco treats the retry as the same request and redeems nothing twice. - A coupon in the request is unknown. The response is
400 Bad Requestwith those ids, and the other coupons are redeemed. Log the ids. The sale itself is not affected. - The refund key does not match. A cancel-redeem under a different key than the redemption cancels nothing. Keep the
receiptIdwith the sale, so a return days later can still find it. - The offer has ended. A coupon can be given back only while its offer is still valid. After that, Lobyco does not return the coupon.
API reference
Endpoint documentation: Coupons (POS).Related
- Direct coupon service integration — the flow where the POS reserves and chooses the coupons it redeems here.
- Discount integration — the flow where Lobyco chooses and reserves the coupons it redeems here.
- Transaction data — the purchase that carries
couponIdson the offline path, and the call that records the sale.