- Learn how to read Voucherify API response
- Learn which data are relevant
- Learn which data could be shown to end-customers
You know which data to show to end-customers
Response analysis
A complete API response for validation or redemption includes many objects. In the example below, the response shows, among others, the following objects:- order – the order placed by the customer
- customer – the customer who placed the order
- voucher – a discount coupon redeemed in the order
- item – an item in the cart
The amount values in the request and response are multiplied by 100 to represent two decimal places, e.g. $100 is
10000
.Data to be shown
Voucherify supports many different use cases. Once the data are mapped correctly, the data can be shown to end-customers in various contexts. The following sections contain snippets of JSON responses from the Voucherify API redemption endpoint.Where to find required data?
The data to be shown is taken from theorder
object in a response. However, the response can have several order
objects.
The order
object to be used is in the root of the response. This order
object shows the final order and it includes all the applied discounts. It is usually located towards the end of the response. See the response example in the Response analysis.
The order
objects within the redemptions
array show how the order changed when the discounts have been applied one by one. As a result, they can include only some of the applied discounts.
The order
object used in the examples in the following sections is taken from the redemptions
object. See the comments in the code below to find suggestions as to which data should be shown to an end-customer.
Discounts
In the case of discounts, the end-customer can be shown the data as indicated in the code. This example covers any redeemed discount applied to the end-customer, whether it is applied from a discount coupon, cart promotion, gift card, or pay with points. In this example, two discounts are applied:- a discount that reduces each item subtotal by $20 and covers only the products with
"brand": "Adventure"
metadata, - a discount that reduces the cart’s total price by $25.

Free items
In the case of free item campaigns, there is additional data in the response which also can be shown to the end-customer, as indicated in the code. This example covers any type of campaign in which an item (here, an Adventure mug product) is added to the cart for free, whether it is applied from a voucher, cart promotion, gift card, or otherwise. In this section, two cases are covered:- the free item is already in the cart,
- the free item is not in the cart.
Free item already in the cart
In this example, the cart includes an Adventure mug and one mug is added for free. A Star thermal bottle is added as a reference item that is not covered by any discount. Check the request tab for reference.
Free item not in the cart
In this example, the cart does not include an Adventure mug, so one mug is added for free. A Star thermal bottle is added as a reference item that is not covered by any discount. Check the request tab for reference.