Skip to content

Latest commit

 

History

History
889 lines (796 loc) · 26.2 KB

purchase.adoc

File metadata and controls

889 lines (796 loc) · 26.2 KB

Purchase API reference guide

About Purchase API

Provides read only information about purchases made through Zettle. Purchase represents a receipt, it’s immutable and contains information about sold items. The purchase information includes one or several payments received, taxes, discounts and so on. Refunds are represented by the same model, but with negative quantity and refund-related flags/fields.

OAuth scope

  • READ:PURCHASE

See OAuth2 API for more information about access tokens.

Fetch a list of purchases

Returns a list of purchases for a merchant. Purchases up to three years old are available for fetching.

GET /purchases/v2

See [example1].

Parameters

Parameters
Name Type In Required/Optional Description

lastPurchaseHash

string

query

optional

A value from "lastPurchaseHash" from the result of a previous request to retrieve next page of purchases.

startDate

string

query

optional

The start date UTC(inclusive) for purchases to be retrieved from until today or endDate if provided. For example "2020-01-01", "2020-01-01T17:00".
By default startDate is resolved to three years back.

endDate

string

query

optional

The last date UTC(exclusive) for purchases to be retrieved until. For example "2021-01-13", "2021-01-13T12:30".

limit

integer

query

optional

The maximum number of records to return. Value range 1–1000.

descending

boolean

query

optional

When set to true, most recent purchases are returned first. Defaults to false if not specified.

Responses

Response codes
HTTP Status code Description

200 OK

Successful.

401 Unauthorized

You were not authorized to execute this operation.

429 Too Many Requests

You hit the rate limit. Retry request later.

Response attributes
Name Type Description

purchases

array

List of purchases. See Response attributes in "Fetch a purchase" section for more information.

firstPurchaseHash

string

Reference to the first purchase in the list returned.

lastPurchaseHash

string

Reference to the last purchase in the list returned. Use it as parameter for the next page with purchases.

linkUrls

array

List of links to pages.
Example:

"linkUrls": [
    "<https://purchase.izettle.com/purchases/v2?limit=4&startDate=2021-01-01T00%3A00%3A00.000Z&descending=true&lastPurchaseHash=1610019370783OWXebOK1QKmwcwSyhCQkzA>; rel=\"next\""
]

Fetch a purchase

Returns a purchase with given UUID.

GET /purchase/v2/{purchaseUuid}

See [example4].

Parameters

Parameters
Name Type In Required/Optional Description

purchaseUuid

string

path

required

Unique ID of the purchase as UUID within the Zettle system.

Responses

Response codes
HTTP Status code Description

200 OK

Successful

401 Unauthorized

You were not authorized to execute this operation.

404 Not found

Purchase with given UUID not found.

429 Too Many Requests

You hit the rate limit. Retry request later.

Response attributes
Table 1. Purchase attributes
Name Type Description

source

string

Source of purchase, value can be one of the following:

  • "POS" - purchase made with Zettle Go app

  • "WEB_SHOP" - purchase made online

  • "SDK" - purchase made through SDK

purchaseUUID

string

Unique ID of a purchase. Deprecated.

purchaseUUID1

string

Unique ID of a purchase as UUID version 1.

timestamp

string

Created timestamp according to the ISO 8601 format. For example "2019-12-03T17:05:06.123+0000".

purchaseNumber

integer

Incremental receipt number.

globalPurchaseNumber

integer

Incremental receipt number, only different from purchaseNumber if several cash registers are used by the merchant.

amount

integer

Gross amount (inc VAT) in minor currency units. For example €9.95 EUR, amount will be 995. Is negative in case of refund.

vatAmount

integer

VAT amount for the whole purchase in minor currency units. FOr example €5 EUR, amount will be 500.

country

string

Two-letter country code for country the merchant operates in. Examples "SE", "NO", "GB", "FR", "DE", "DK".

currency

string

Currency code ISO 4217. Examples "SEK", "NOK", "GBP", "EUR".

products

array

List of items that were sold. See section Product attributes for more information.

payments

array

Payments that were processed/received. See section Payment attributes for more information.

discounts

object

Discounts applied on the whole purchase. See section [Discounts] for more information. Example:

"discounts": [
        {
            "name": "4 for £12",
            "amount": 200,
            "quantity": 1,
            "value": 200
        }
    ]
or
"discounts": [
        {
            "name": "Staff",
            "percentage": 50,
            "quantity": 1,
            "value": 2000
        }
    ]

name attribute is optional, not always present. For more information see section [Discounts].

serviceCharge

object

Service charge added to a purchase, for example delivery charge.
Example:

 "serviceCharge": {
    "amount": 499,
    "title": "Standard Shipping",
    "vatPercentage": 16.0,
    "quantity": "1"
  }

created

string

Created timestamp according to the ISO 8601 format. For example "2019-12-03T17:05:06.123+0000".

refund

boolean

Indicates if given purchase is a refund.

refunded

boolean

Indicates if given purchase has been refunded.

refundsPurchaseUUID

string

Unique ID of the purchase that was refunded as string. Deprecated.

refundsPurchaseUUID1

string

Unique ID of the purchase that was refunded as UUID version 1.

refundedByPurchaseUUIDs

array

List with IDs of purchases that refunded this particular one. Deprecated.

refundedByPurchaseUUIDs1

array

List with IDs of purchases that refunded this particular one as UUIDs version 1.

"refundedByPurchaseUUIDs1": [
    "3d221367-1c92-498d-9e94-ef5cc4f45d61",
    "e37d63c2-97af-4bec-b6ac-1cf212f97d90"
]

groupedVatAmounts

object

Contains VAT amounts grouped by percentage.
Example:

"groupedVatAmounts": {
    "25.0": 70000,
    "12.0": 5000
  }

userDisplayName

string

Name of the merchant/employee that took the payment.

gpsCoordinates

object

Contains GPS coordinates of the location where purchase was made.
Example:

"gpsCoordinates": {
    "longitude": 19.80452501310729,
    "latitude": 66.609375,
    "accuracyMeters": 165
  }

cashRegister

object

For internal use. There is no public API available for cash register.

Note: More attributes can potentially be added. Make sure your integration is built in a tolerant way.

Table 2. Product attributes
Name Type Description

quantity

string

Quantity of items. Can be a whole number or a decimal number, and negative in case of refund.

type

string

Describes the type of item that was purchased.
Enumeration values:

  • "PRODUCT" - Indicates that the item sold was predefined in product library.

  • "CUSTOM_AMOUNT" - Indicates that the item sold was a custom amount entered in the app at the time of purchase.

  • "GIFTCARD" - Indicates that the item sold was a gift card.

details

object

May contain information related to the specific type, for example item lines of type GIFTCARD will have a giftcardUuid attribute pointing out what gift card that was sold/returned as part of purchases. Example:

"details": {
    "giftcardUuid": "290371f0-a8a5-11e5-b862-d6cb9f787e88"
}

Gift card details can be fetched through Gift Card API.

productUuid

string

Unique ID of product in product library as UUID.

name

string

Name of the product sold.

variantUuid

string

Unique ID of variant in product library as UUID.

variantName

string

Name of variant.

vatPercentage

number

VAT percentage of the item.

rowTaxableAmount

integer

Amount on which VAT is chargeable in minor currency units. For example £12.5 GBP will be 1250.

unitPrice

integer

Unit price of the item in minor currency units. For example €10 EUR will be 1000.

unitName

string

Name of unit, for example "kg", "hour".

comment

string

Comment for the item row.

discount

object

Discount for the item row.
Example:

 "discount": {
    "percentage": 20,
    "quantity": 1
}
or
"discount": {
    "amount": 1000,
    "quantity": 1
}

See section [Discounts] for more information.

discountValue

integer

Discount amount in minor currency units. For example €5 EUR will be 500.

libraryProduct

boolean

Indicates if product registered in merchant’s product library.

sku

string

SKU of product in inventory.

barcode

string

Barcode of the product in inventory.

fromLocationUuid

string

Supplier location ID as UUID (inventory context).

toLocationUuid

string

Store location ID as UUID (inventory context).

Table 3. Payment attributes
Name Type Description

uuid

string

Unique ID of the payment as UUID. Can be linked to transactions in Finance API.

type

string

Payment type used when making a purchase. See Payment types for more information.

gratuityAmount

integer

Corresponds to the tipping amount in the purchase. This feature is not available in all supported by Zettle countries. When the gratuityAmount is set, the payment amount will include the gratuity amount.

references

object

Other references.
Example:

"references": {
    "refundsPayment": "4647cd58-ebc6-4ef8-9572-559811c90b11"
    // UUID of original payment that was refunded or partially refunded.
}

attributes

object

Additional information about the payment. Different attributes are included depending on payment type.

Table 4. Payment types
Payment type Description

IZETTLE_CARD

Payment taken with Zettle card reader.

Example:

{
  "uuid": "165b88a0-07a3-11e6-9dae-43c30f1bff5b",
  "amount": 2000,
  "gratuityAmount": 0,
  "type": "IZETTLE_CARD",
  "attributes": {
    "cardHolderVerificationMethod": "None",
    "maskedPan": "535583******0000",
    "cardPaymentEntryMode": "CONTACTLESS_EMV",
    "referenceNumber": "B6MFKZTMKP",
    "authorizationCode": "429579",
    "cardType": "MASTERCARD",
    "terminalVerificationResults": "0000008001",
    "applicationIdentifier": "A0000000041010",
    "applicationName": "Debit MasterCard"
  }
}

IZETTLE_CARD_ONLINE

Payment taken with Zettle online, for example with payment link.

Example:

{
  "uuid": "3d38a2b4-3a02-11eb-bdbf-9f47e7b17f57",
  "amount": 18145,
  "type": "IZETTLE_CARD_ONLINE",
  "attributes": {
    "cardType": "MASTERCARD",
    "maskedPan": "517036******000",
    "cardPaymentEntryMode": "ECOMMERCE",
    "referenceNumber": "PKDBOSWWWW",
    "paymentlinkOrderUuid": "bb6d3b38-3a01-11eb-970c-e3b88c945415"
  }
}

IZETTLE_CASH

Cash payment registered with Zettle.

Example:

{
  "uuid": "ec138d2e-8e29-41c0-a4c4-17b2b4ab7f8b",
  "amount": 2000,
  "type": "IZETTLE_CASH",
  "attributes": {
    "changeAmount": 3000,
    "handedAmount": 5000
  }
}

IZETTLE_INVOICE

Zettle invoice is issued for a purchase with this payment type.

Example:

{
  "amount": 92250,
  "attributes": {
    "orderUUID": "52201c9a-1234-11eb-9909-5960351f9426",
    "invoiceNr": "iz18",
    "dueDate": "2020-10-29"
  },
  "type": "IZETTLE_INVOICE",
  "uuid": "52372638-1223-11eb-85a4-e6977798fc1e"
}

SWISH

Alternative payment method available in Sweden, has no additional attributes.

VIPPS

Alternative payment method available in Norway, has no additional attributes.

MOBILE_PAY

Alternative payment method available in Denmark, has no additional attributes.

PAYPAL

Payment made with PayPal wallet.

Example:

{
  "uuid": "74d528f1-1bd1-11ed-afd0-27740sse6511",
  "amount": 1200,
  "type": "PAYPAL",
  "attributes": {
    "paypalId": "5TW66818TP9560FFF"
  }
}

STORE_CREDIT

Store credit is usually a document offered by a store to a customer who returns an item not eligible for a refund. It can also be offered when a customer doesn’t want to get chargeback on the credit card that was used. Furthermore, it can be used to buy other goods at the same store.

GIFTCARD

Payment made with a gift card(certificate/voucher) issued by the merchant.

KLARNA

Payment made with Klarna.

Example:

{
      "uuid": "fab90e28-c666-4f60-a96b-1515deb88300",
      "receiverOrganization": "59ef0f5a-5416-11eb-ae93-0242ac130002",
      "amount": 180319,
      "type": "KLARNA",
      "currency": "SEK",
      "country": "SE",
      "referenceNumber": "6B2MFVVDXXX",
      "references": {
        "checkoutUUID": "3431ad48-3ba4-11eb-bc4c-f3c0af76e000"
      },
      "commission": {
        "totalAmount": 5621,
        "vatAmount": 0,
        "vatRate": 17.0,
        "modelId": "4656dbf8-5161-11e9-b86f-74970dafc264",
        "model": {
          "fixed": 590,
          "percentage": 2.79
        }
      },
      "createdAt": "2020-12-11T11:32:14.000+0000",
      "details": {
        "klarnaOrderId": "f7abd5be-04bd-1565-b557-df865f5ba7a0",
        "klarnaProduct": "PAY_LATER",
        "klarnaReference": "029TN5TTT",
        "acquiringChannel": "IN_STORE"
      },
      "attributes": {}
    }

Examples

Fetch all purchases for a merchant

Step 1: Send a request with the limit parameter to define the number of purchases to retrieve.

GET /purchases/v2?limit=50&descending=true

Step 2: At the bottom of the response, find the values of lastPurchaseHash.

{
  "purchases": [
    ....
  ],
  "firstPurchaseHash": "14233908814696HbDrnUNRji5iniGikNLiQ",
  "lastPurchaseHash": "1423390928355zj9yI1wyTvqP46AG8NEaYg",
  "linkUrls": [
        "<https://purchase.izettle.com/purchases/v2?limit=50&descending=true&lastPurchaseHash=1423390928355zj9yI1wyTvqP46AG8NEaYg>; rel=\"next\""
  ]
}

Step 3: Send another request with these settings: The limit parameter the same as in the initial request; lastPurchaseHash with the value from the previous response.

Step 4: Repeat step 2 and step 3 until the response is empty.

Purchases with partial refund

Request:

GET /purchases/v2?descending=true&limit=2

Response:

Status: 200 OK

{
  "purchases": [
    {
      "source": "POS",
      "purchaseUUID": "1x6BTNcFQ-esnIMUSdX8mQ",
      "amount": -10000,
      "vatAmount": -1071,
      "country": "SE",
      "currency": "SEK",
      "timestamp": "2021-01-13T21:34:22.069+0000",
      "gpsCoordinates": {
        ...
      },
      "purchaseNumber": 33,
      "globalPurchaseNumber": 33,
      "userDisplayName": "John Eriksen",
      "userId": 5428764,
      "organizationId": 37295469,
      "products": [
        {
          "quantity": "-1",
          "productUuid": "c8037b10-5381-11eb-a35d-4df8c9434273",
          "variantUuid": "f29e9da0-5381-11eb-b308-d53bdad1e1da",
          "vatPercentage": 12,
          "unitPrice": 10000,
          "rowTaxableAmount": -8929,
          "name": "T-shirt",
          "description": "",
          "variantName": "Small",
          "fromLocationUuid": "ab4b8ca6-c4d0-11e9-9f2e-2f9f3e29738c",
          "toLocationUuid": "ab4b8d0a-c4d0-11e9-a836-71d1917b51b2",
          "type": "PRODUCT",
          "libraryProduct": true
        }
      ],
      "discounts": [],
      "payments": [
        {
          "uuid": "5fdf1688-56ab-4686-857f-4ada4361a205",
          "amount": -10000,
          "type": "IZETTLE_CASH",
          "references": {
            "refundsPayment": "eb0db2eb-0ab0-4650-bd9c-492ebbe36938"
          },
          "attributes": {
            "handedAmount": -10000
          }
        }
      ],
      "refundsPurchaseUUID": "an16nO_YSpOw_0XVXSEndA",
      "receiptCopyAllowed": true,
      "references": {
        "checkoutUUID": "d51c834e-d507-41e5-ae9e-81164bd7fe9b"
      },
      "created": "2021-01-13T21:34:22.069+0000",
      "refunded": false,
      "purchaseUUID1": "d71e814c-d705-43e7-ac9c-831449d5fc99",
      "refundsPurchaseUUID1": "6a7d7a9c-efd8-4a93-b0ff-45d55d212774",
      "groupedVatAmounts": {
        "12.0": -10000
      },
      "refund": true
    },
    {
      "source": "POS",
      "purchaseUUID": "an16nO_YSpOw_0XVXSEndA",
      "amount": 20000,
      "vatAmount": 2142,
      "country": "SE",
      "currency": "SEK",
      "timestamp": "2021-01-13T21:34:10.968+0000",
      "gpsCoordinates": {
        ...
      },
      "purchaseNumber": 32,
      "globalPurchaseNumber": 32,
      "userDisplayName": "John Eriksen",
      "userId": 5428764,
      "organizationId": 37295469,
      "products": [
        {
          "quantity": "1",
          "productUuid": "c8037b10-5381-11eb-a35d-4df8c9434273",
          "variantUuid": "f29e9da0-5381-11eb-b308-d53bdad1e1da",
          "vatPercentage": 12,
          "unitPrice": 10000,
          "rowTaxableAmount": 8929,
          "name": "T-shirt",
          "description": "",
          "variantName": "Small",
          "type": "PRODUCT",
          "libraryProduct": true
        },
        {
          "quantity": "1",
          "productUuid": "c8037b10-5381-11eb-a35d-4df8c9434273",
          "variantUuid": "f29e9da0-5381-11eb-9178-f532eaf25a4b",
          "vatPercentage": 12,
          "unitPrice": 10000,
          "rowTaxableAmount": 8929,
          "name": "T-shirt",
          "description": "",
          "variantName": "Medium",
          "type": "PRODUCT",
          "libraryProduct": true
        }
      ],
      "discounts": [],
      "payments": [
        {
          "uuid": "eb0db2eb-0ab0-4650-bd9c-492ebbe36938",
          "amount": 20000,
          "type": "IZETTLE_CASH",
          "attributes": {
            "handedAmount": 20000
          }
        }
      ],
      "refundedByPurchaseUUIDs": [
        "1x6BTNcFQ-esnIMUSdX8mQ"
      ],
      "receiptCopyAllowed": true,
      "references": {
        "checkoutUUID": "6b7c7b9d-eed9-4b92-b1fe-44d45c202675"
      },
      "created": "2021-01-13T21:34:10.968+0000",
      "refunded": true,
      "purchaseUUID1": "6a7d7a9c-efd8-4a93-b0ff-45d55d212774",
      "refundedByPurchaseUUIDs1": [
        "d71e814c-d705-43e7-ac9c-831449d5fc99"
      ],
      "groupedVatAmounts": {
        "12.0": 20000
      },
      "refund": false
    }
  ],
  "firstPurchaseHash": "16105736620691x6BTNcFQ-esnIMUSdX8mQ",
  "lastPurchaseHash": "1610573650968an16nO_YSpOw_0XVXSEndA",
  "linkUrls": [
    "<https://purchase.izettle.com/purchases/v2?limit=2&descending=true&lastPurchaseHash=1610573650968an16nO_YSpOw_0XVXSEndA>; rel=\"next\""
  ]
}

Purchase with discounts

Request:

GET /purchases/v2?limit=10&descending=true

Response:

Status: 200 OK

{
  "purchases": [
    {
      "source": "POS",
      "purchaseUUID": "9u9p8liUSmu9ZrH9NkzeOA",
      "amount": 15200,
      "vatAmount": 1628,
      "country": "SE",
      "currency": "SEK",
      "timestamp": "2021-01-15T12:17:03.164+0000",
      "gpsCoordinates": {
        ...
      },
      "purchaseNumber": 34,
      "globalPurchaseNumber": 34,
      "userDisplayName": "Sara Eriksen",
      "userId": 5428764,
      "organizationId": 37295469,
      "products": [
        {
          "quantity": "1",
          "productUuid": "c8037b10-5381-11eb-a35d-4df8c9434273",
          "variantUuid": "f29e9da0-5381-11eb-b308-d53bdad1e1da",
          "vatPercentage": 12,
          "unitPrice": 10000,
          "rowTaxableAmount": 6786,
          "name": "T-shirt",
          "description": "Cool T-shirt",
          "variantName": "Small",
          "discount": {
            "percentage": 20,
            "quantity": 1
          },
          "discountValue": 2000,
          "comment": "20% off",
          "type": "PRODUCT",
          "libraryProduct": true
        },
        {
          "quantity": "1",
          "productUuid": "c8037b10-5381-11eb-a35d-4df8c9434273",
          "variantUuid": "f29e9da0-5381-11eb-80a8-3285f2ac85a4",
          "vatPercentage": 12,
          "unitPrice": 10000,
          "rowTaxableAmount": 6786,
          "name": "T-shirt",
          "description": "Cool T-shirt",
          "variantName": "Large",
          "discount": {
            "amount": 2000,
            "quantity": 1
          },
          "discountValue": 2000,
          "comment": "Fixed amount discount",
          "type": "PRODUCT",
          "libraryProduct": true
        }
      ],
      "discounts": [
        {
          "percentage": 5,
          "quantity": 1,
          "value": 800
        }
      ],
      "payments": [
        {
          "uuid": "624bbc18-93f9-4334-84c6-16c660bef366",
          "amount": 15200,
          ...
        }
      ],
      "receiptCopyAllowed": true,
      "references": {
        "checkoutUUID": "f7ee68f3-5995-4b6a-bc67-b0fc374ddf39"
      },
      "created": "2021-01-15T12:17:03.164+0000",
      "refunded": false,
      "purchaseUUID1": "f6ef69f2-5894-4a6b-bd66-b1fd364cde38",
      "groupedVatAmounts": {
        "12.0": 15200
      },
      "refund": false
    }
  ],
  ...
}

Fetch a specific purchase

Request:

GET /purchase/v2/589c2de6-3ee4-11eb-9e70-a2ac075b17fd

Response:

Status: 200 OK

{
  "source": "POS",
  "purchaseUUID": "WJwt5j7kEeuecKKsB1sX_Q",
  "purchaseUUID1": "589c2de6-3ee4-11eb-9e70-a2ac075b17fd",
  "amount": 70000,
  "vatAmount": 14000,
  "country": "SE",
  "currency": "SEK",
  "timestamp": "2020-12-15T14:46:43.592+0000",
  "gpsCoordinates": {
    "longitude": 19.80452501310729,
    "latitude": 66.609375,
    "accuracyMeters": 165
  },
  "purchaseNumber": 1366,
  "globalPurchaseNumber": 1366,
  "userDisplayName": "Sara Johansson",
  "userId": 11111,
  "organizationId": 11111,
  "products": [
    {
      "quantity": "1",
      "productUuid": "2f2a8d60-9c76-11e5-8a3b-82916dc77adc",
      "variantUuid": "234ee5f0-b188-11e5-aa17-721c907d3875",
      "vatPercentage": 25,
      "unitPrice": 70000,
      "rowTaxableAmount": 56000,
      "name": "Haircut",
      "variantName": "1 hour",
      "fromLocationUuid": "4c03eec0-183c-11e7-a3f8-037fdcd360ec",
      "toLocationUuid": "4c03eec0-183c-11e7-a15a-cda93ab15db3",
      "autoGenerated": false,
      "id": "0",
      "type": "PRODUCT",
      "libraryProduct": true
    }
  ],
  "discounts": [],
  "payments": [
    {
      "uuid": "592b82f2-3ee4-11eb-9f71-a3ad065a16fc",
      "amount": 70000,
      "type": "SWISH",
      "attributes": {}
    }
  ],
  "receiptCopyAllowed": true,
  "references": {
    "checkoutUUID": "589c2de6-3ee4-11eb-9f71-a3ad065a16fc"
  },
  "created": "2020-12-15T14:46:43.592+0000",
  "refunded": false,
  "groupedVatAmounts": {
    "25.0": 70000
  },
  "refund": false
}

Discounts explained

Discounts can exist both on a specific row of items (products), as well as on the entire purchase. Discount on a row of items is applied on the whole amount of the row, can be set either as a percentage or as a fixed amount.

Items row discounts will be applied first, followed by the discount on the sum of the already discounted row prices.

VAT calculation on purchase with discounts

Since each row of items can have a separate VAT percentage the discount for the whole purchase is evenly distributed over all purchased items. VAT is calculated after all the discounts are deducted.

If the purchase discount is a fixed amount then that amount will be deducted from each row according the price of each row in relation to the total purchase price.

Examples

If the purchase discount is 20%, then the price of each row of item will be deducted with 20% before calculating the VAT for each row.

If a purchase has a total price of 100 and contains 2 rows with the first row priced at 40 and the second at 60, then 40% of the fixed purchase discount will be deducted from the first row and 60% from the other row before calculating the VAT.

  • Row discounts are expressed using the following JSON structure in the products list, containing either amount for fixed discounts or percentage for percentage discounts. The discountValue field following the discount structure contains the total discount amount for the row:

    "discount": {
        "name": "10% off",
        "quantity": 1,
        "percentage": 10
    },
    "discountValue": 1000

    Note: Currently only one discount per row of items is supported so the quantity field will always be set to 1. This could potentially change in the future.

  • Discounts for the whole purchase are expressed using the following JSON structure.

    They can contain either amount or percentage.

    "discounts": [
    {
        "amount": 2000,
        "quantity": 1,
        "value": 2000
    }

    Note: Currently only one discount for the whole purchase is supported, so the discounts list will only contain one item with quantity set to 1. This could potentially change in the future.

    See the following for a full response example containing discounts.

Discount calculation example

This example purchase contains both discounts on rows and on the whole purchase.

Nr

Product

Unit price

Quantity

Discount

1

Foo

20

2

5

2

Bar

10

10

10%

Purchase discount

 20%

  1. To calculate the total discount we start by calculating the discount per row:

    First row contains 2 items and a fixed discount amount of 5.

    Second row contains 10 items and a percentage discount of 10%.

    Row discounts = 5 + 10 × 10 × 0.1 = 15

  2. Then we calculate the purchase discount, based on the sum of the previously discounted rows:

    Sum of discounted rows = 20 × 2 + 10 × 10 − 15 = 125

    Purchase discount = 125 × 0.2 = 25

    So the total discount on this purchase is 15 + 25 = 40 and the total sum to pay is 140 − 40 = 100.

    A discount can never be greater than the actual amount of the row or purchase price.