Skip to main content

Adding discount metadata to sessions

When creating sessions with discounted items, you should write the price after discounts, as this is what the customer is paying.

If you want to add metadata to the sessions to signal that a discount has been given, you can use order.items[*].discount_lines if the discount is connected to a particular item or order.discount_lines if the discount is on the full order.

See the api spec for more details.

Example 1: Discount added per item

{
"amount": 20000,
"items": [
{
"id": "item-1",
"vat": 25,
"amount": 10000,
"line_id": "1",
"quantity": 1,
"description": "Item 1",
"discount_lines": [
{
"amount": 2000,
"line_id": 1,
"description": "Manually added 20 kroner off. // Original price 12000",
"discount_id": "manual-20-kroner-off",
"discount_type": "manual"
}
]
},
{
"id": "item-2",
"vat": 25,
"amount": 10000,
"line_id": "2",
"quantity": 2,
"description": "Item 2",
"discount_lines": [
{
"amount": 2500,
"line_id": 1,
"percentage": 20,
"description": "New customer 20% on item 2. // Original price 12500",
"discount_id": "new-customer-20-item-2",
"discount_type": "customer"
}
]
}
]
}

Example 2: Discount added on the order

{
"amount": 20000,
"items": [
{
"id": "item-1",
"vat": 25,
"amount": 10000,
"line_id": "1",
"quantity": 1,
"description": "Item 1"
},
{
"id": "item-2",
"vat": 25,
"amount": 10000,
"line_id": "2",
"quantity": 2,
"description": "Item 2"
}
],
"discount_lines": [
{
"amount": 5000,
"line_id": "dl1",
"percentage": 20,
"description": "20% off on the first order // The original sum was 25000",
"discount_id": "first-order-20-percent",
"discount_type": "customer"
}
]
}