Order costs
This guide presents examples of how to send the different costs associated with an order.
The relevant meta fields in the order
object are:
Field | Description |
---|---|
total | Total cost of the order, including discounts, shipping, and taxes. |
shipping | Total shipping costs of the order. |
totalDiscount | Total discounts of the order. Can be a single order-level field, or as the sum of discounts per line. |
totalTax | Total tax of the order. Can be a single order-level field, or as the sum of taxes per line. |
If you have the breakdown per order line, you can send it in each object on the order.lines
list:
Field | Description |
---|---|
| The type of line, useful if you allow applying many discounts or taxes to your order.
|
| Count of items per line. Should be "1" if |
| Unit price of the item. |
| Discount on the item. |
| Tax cost applied to the item. |
| Tax percentage that applies to the item. |
| Total cost of the item, including discount and taxes. |
Example
Let's say you have:
- Item 1, which costs $10, but has a discount of $1
- Item 2, which costs $3 per unit, and you order 2 units
- The cost of shipping for the order is $4
- A discount of $2 on the shipping (e.g. after a certain amount, your shipping cost is reduced)
- A "Voucher 1" of $3 that applies a discount on the entire order
- The total tax of $1 that applies to the entire order
- The total amount of your order (after including taxes, shipping, and applying discounts) is $15
So what you send as the order
meta field to Payrails looks like:
{
"lines": [
{
"type": "lineItem",
"name": "Item 1",
"quantity": 1,
"unitPrice": {
"currency": "EUR",
"value": "10"
},
"totalDiscount": {
"currency": "EUR",
"value": "1"
}
},
{
"type":"lineItem",
"name":"Item 2",
"quantity": 2,
"unitPrice": {
"currency": "EUR",
"value": "3"
}
},
{
"type":"discount",
"name":"Voucher 1",
"quantity": 1,
"unitPrice": {
"currency": "EUR",
"value": "3"
}
},
{
"type":"discount",
"name":"Shipping discount",
"quantity": 1,
"unitPrice": {
"currency": "EUR",
"value": "2"
}
}
],
"shipping": {
"currency": "EUR",
"value": "4"
},
"totalTax": {
"currency": "EUR",
"value": "1"
}
}
- If you don't need to specify different taxes or discounts as lines, you can use the
totalTax
ortotalDiscount
fields on the order level.- If you have the breakdown of items, you don't need to specify the
order.total
andlines[*].total
, we will calculate it for you.
Updated about 2 months ago