API purpose
In a Discount integration, Lobyco receives the user basket, evaluates the products, and applies the coupons based on the rules and basket content. Lobyco can return to the POS the coupons to be applied and their definition, or it can return the price calculation and final price as well. This approach is best when you want Lobyco to own the discount logic rather than replicating offer definitions in the POS.Not sure which approach to choose?
See Applying discounts: two options for how this compares with the Direct Coupon Service Integration, where the POS decides which coupons to apply.Flow
In this integration approach, Lobyco receives the user basket, evaluates the products, and applies the coupons based on the rules and basket content. Lobyco can return to the POS the coupons to be applied and their definition, or it can return also the price calculation and final price.
1
Send the purchase
Send the purchase to POST v1/discounted-purchases. Only purchases with a customer should be sent. No discounts are applied to anonymous purchases.2
Confirm coupon redemption
POST v2/customers/{customerId}/coupons/redeem — POS confirms that the purchase was finished and coupons were used. Coupons can be also redeemed based on coupon ids sent along with transaction data. Include store id and total basket value for better reporting.3
Cancel coupon reservation (optional)
POST /v1/customers/{customerId}/coupons/cancel-reservation — notify that the purchase was canceled and coupons should be available again on other POSes.How to apply the response from Discount API Purchase endpoint
Tip 💡: Before making any API calls directly to your assigned integration layer, make sure you have created at least one offer in the Lobyco Admin Portal and that you have activated that offer for the customer you are testing your API calls with. We suggest you set up an offer with redemption limit 999. In this way you’ll be able to retest with the same offer for a longer time period.
- Most of the fields from the request will be replicated in the response.
- The totalAmount will be decreased by the total discount amount applied to products in the basket.
- Product’s price will be decreased by the total discount amount applied to that product.
- The response discounts collection will be filled in with applied discounts.
Tip 💡: The appliedProducts property will only be populated for product-level discounts. For basket-level discounts, it will be empty.
How to apply the response from Legacy Discount API Basket endpoint
The Discount API response will contain several important aspects for POS to analyze:
- It will replicate the basketId from the request, for ease of identification.
- It will contain a field called finalTotal, containing the total amount of the basket after discount application.
Tip 💡: Notice that the discountCalculationAPI also replicates the basket total before discount application under the total field.
- It will contain a list of line items, where the discountCalculationAPI will replicate most of the product information (from the request) and will add:
-
A finalTotalSalePrice containing the line item total sale price after discount application.
-
A discounts field containing the discounts applicable to the respective line item (including the calculated discount amount value after each discount application).
-
A coupons field containing all the used coupons required to apply the discounts on the current line item.
-
A finalTotalSalePrice containing the line item total sale price after discount application.
- Besides line item discounts and coupons, the response may also contain basket-level discounts and coupons with a similar structure to those at line item level.
Tip 💡 The finalTotal field described above is calculated by taking into consideration all applied discounts regardless of whether they were applied at line item level or at basket level.