### Get Products Request (Node.js) Source: https://developer.zettle.com/docs/api/product-library/reference This Node.js example demonstrates how to fetch products using the 'request' library. Ensure you have the library installed and replace placeholders with your organization UUID and bearer token. ```javascript const request = require('request'); const options = { method: 'GET', url: 'https://products.izettle.com/organizations/{organizationUuid}/products/v2', qs: {sort: 'SOME_BOOLEAN_VALUE'}, headers: {Authorization: 'Bearer REPLACE_BEARER_TOKEN'} }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Get Product Image (Node.js) Source: https://developer.zettle.com/docs/api/image/reference This Node.js example demonstrates how to fetch a product image using the 'request' library. Ensure the 'request' library is installed. ```javascript const request = require('request'); const options = { method: 'GET', url: 'https://image.izettle.com/v2/images/product/{identifier}', qs: { w: 'SOME_INTEGER_VALUE', h: 'SOME_INTEGER_VALUE', c: 'SOME_BOOLEAN_VALUE', t: 'SOME_STRING_VALUE' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Get Products (Go) Source: https://developer.zettle.com/docs/api/product-library/reference Example of fetching products using Go's standard http package. Ensure you replace `REPLACE_BEARER_TOKEN` with your actual bearer token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/products" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Product Status (Kotlin) Source: https://developer.zettle.com/docs/api/inventory/reference Kotlin example using OkHttpClient to get product status. This snippet demonstrates setting up the request and executing it. ```kotlin val client = OkHttpClient() val mediaType = MediaType.parse("application/json") val body = RequestBody.create(mediaType, "[\"497f6eca-6276-4993-bfeb-53cbbbba6f08\" ]") val request = Request.Builder() .url("https://inventory.izettle.com/v3/products/status") .post(body) .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .addHeader("content-type", "application/json") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Retrieve Product Options (Java) Source: https://developer.zettle.com/docs/api/product-library/reference Java example using Unirest to get product options. Remember to replace `REPLACE_BEARER_TOKEN` with your valid token. ```java HttpResponse response = Unirest.get("https://products.izettle.com/organizations/{organizationUuid}/products/options") .header("Authorization", "Bearer REPLACE_BEARER_TOKEN") .asString(); ``` -------------------------------- ### Get Inventory Product Stock (Python) Source: https://developer.zettle.com/docs/api/inventory/reference This Python example uses the http.client library to make a GET request for product stock information. It demonstrates setting up the HTTPS connection, sending the request with authorization headers, and printing the response body. ```python import http.client conn = http.client.HTTPSConnection("inventory.izettle.com") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/v3/stock/{inventoryUuid}/products/{productUuid}?cursor=SOME_STRING_VALUE&limit=SOME_INTEGER_VALUE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get Products Request (Go) Source: https://developer.zettle.com/docs/api/product-library/reference A Go program demonstrating how to fetch products from the Product Library API. This example uses the standard net/http package. Replace placeholders as needed. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/products/v2?sort=SOME_BOOLEAN_VALUE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Inventory Product Stock (Node.js) Source: https://developer.zettle.com/docs/api/inventory/reference This Node.js example demonstrates how to make a GET request to retrieve product stock information. It includes options for setting the request method, URL, query parameters, and authorization headers. ```javascript const request = require('request'); const options = { method: 'GET', url: 'https://inventory.izettle.com/v3/stock/{inventoryUuid}/products/{productUuid}', qs: {cursor: 'SOME_STRING_VALUE', limit: 'SOME_INTEGER_VALUE'}, headers: {Authorization: 'Bearer REPLACE_BEARER_TOKEN'} }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Create Inventory using Node.js Source: https://developer.zettle.com/docs/api/inventory/reference Node.js example for creating an inventory. Ensure you have the 'request' library installed. Replace REPLACE_BEARER_TOKEN with your actual token. ```javascript const request = require('request'); const options = { method: 'POST', url: 'https://inventory.izettle.com/v3/inventories', headers: { Authorization: 'Bearer REPLACE_BEARER_TOKEN', 'content-type': 'application/json' }, body: {name: 'string', description: 'string'}, json: true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Get Product by UUID (Kotlin) Source: https://developer.zettle.com/docs/api/product-library/reference Kotlin code example using OkHttpClient to fetch product data. Remember to replace the bearer token and product UUID. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://products.izettle.com/organizations/{organizationUuid}/products/{productUuid}") .get() .addHeader("If-None-Match", "SOME_STRING_VALUE") .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Example Authorisation Initiation URL Source: https://developer.zettle.com/docs/api/oauth/user-guides/set-up-app-authorisation/set-up-authorisation-code-grant An example URL demonstrating how to initiate the authorisation flow for read and write access to the product library. ```URL https://oauth.zettle.com/authorize?response_type=code&scope=OFFLINE_ACCESS%20PRODUCT:R%20PRODUCT:WRITE&client_id=6adde977-c34d-4de1-99b2-f6ed3e65431a&redirect_uri=https%3A%2F%2Fwww.example.com%2Fzettle%2Freturn&state=abc123678 ``` -------------------------------- ### Get Product Status (Node.js) Source: https://developer.zettle.com/docs/api/inventory/reference Node.js example for retrieving product status. Ensure you have the 'request' library installed. ```javascript const request = require('request'); const options = { method: 'POST', url: 'https://inventory.izettle.com/v3/products/status', headers: { Authorization: 'Bearer REPLACE_BEARER_TOKEN', 'content-type': 'application/json' }, body: ['497f6eca-6276-4993-bfeb-53cbbbba6f08'], json: true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Get Reader Links (Node.js) Source: https://developer.zettle.com/docs/payment-integrations/reader-connect/reference Example of how to retrieve reader links using Node.js with the 'request' library. Requires the 'request' package to be installed. ```javascript const request = require('request'); const options = { method: 'GET', url: 'https://reader-connect.zettle.com/v1/reader/links', headers: { Authorization: 'RC challenge="2z+Dfy6LJczLGiMmpvGa1A==", signatures="01886cbd-cf64-7dce-bd19-d13dfbca9446:MEQCIHHWBro9OqFTP7JYkEAiiRCl31yYJ52xcN3OfWRXG74UAiBiWsMVfNFWIJyep8kCwRcyqSlpMNu/CH1fqE/8TmiuVg==;0188681e-d357-71e2-97f2-8d72fa08f16b:MEUCIHJcT9feXbek4+o/hHMiBec+U64+CTDDdlIrcCtS89kbAiEA8yu/+K5A/SIFiClTnQNVTVsWI0E4xsCqxzq+xMZ51gI="' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Create Inventory using Go Source: https://developer.zettle.com/docs/api/inventory/reference Go example for creating an inventory. Replace REPLACE_BEARER_TOKEN with your actual token. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://inventory.izettle.com/v3/inventories" payload := strings.NewReader("{\"name\":\"string\",\"description\":\"string\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Create Product (Go) Source: https://developer.zettle.com/docs/api/product-library/reference Example of how to create a new product using the Go HTTP client. ```APIDOC ## POST /organizations/{organizationUuid}/products ### Description Creates a new product in the product library. ### Method POST ### Endpoint /organizations/{organizationUuid}/products ### Request Body - **uuid** (string) - Required - Unique identifier for the product. - **name** (string) - Required - Name of the product. - **description** (string) - Optional - Description of the product. - **presentation** (object) - Optional - Visual presentation details. - **imageUrl** (string) - Optional - URL for the product image. - **backgroundColor** (string) - Optional - Background color for the product display. - **textColor** (string) - Optional - Text color for the product display. - **variants** (array) - Required - List of product variants. - **uuid** (string) - Required - Unique identifier for the variant. - **name** (string) - Required - Name of the variant. - **description** (string) - Optional - Description of the variant. - **sku** (string) - Optional - Stock Keeping Unit for the variant. - **barcode** (string) - Optional - Barcode for the variant. - **price** (object) - Required - Pricing information. - **amount** (number) - Required - Price amount. - **currencyId** (string) - Required - Currency identifier (e.g., "AED"). - **costPrice** (object) - Optional - Cost price information. - **amount** (number) - Required - Cost amount. - **currencyId** (string) - Required - Currency identifier (e.g., "AED"). - **vatPercentage** (number) - Optional - VAT percentage for the variant. - **options** (array) - Optional - Options for the variant. - **name** (string) - Required - Option name. - **value** (string) - Required - Option value. - **presentation** (object) - Optional - Variant presentation details. - **imageUrl** (string) - Optional - URL for the variant image. - **backgroundColor** (string) - Optional - Background color for the variant display. - **textColor** (string) - Optional - Text color for the variant display. - **externalReference** (string) - Optional - External reference ID for the product. - **unitName** (string) - Optional - Name of the unit for the product. - **vatPercentage** (number) - Optional - Default VAT percentage for the product. - **online** (object) - Optional - Online sales details. - **status** (string) - Required - Online status (e.g., "ACTIVE"). - **title** (string) - Optional - Title for online display. - **description** (string) - Optional - Description for online display. - **shipping** (object) - Optional - Shipping details. - **shippingPricingModel** (string) - Required - Shipping pricing model (e.g., "FREE"). - **weightInGrams** (integer) - Optional - Weight in grams. - **weight** (object) - Optional - Weight details. - **weight** (number) - Required - Weight value. - **unit** (string) - Required - Weight unit (e.g., "kg"). - **presentation** (object) - Optional - Online presentation details. - **displayImageUrl** (string) - Optional - URL for the main display image. - **additionalImageUrls** (array) - Optional - Additional image URLs. - **mediaUrls** (array) - Optional - Media URLs. - **seo** (object) - Optional - SEO details. - **title** (string) - Optional - SEO title. - **metaDescription** (string) - Optional - SEO meta description. - **slug** (string) - Optional - SEO slug. - **variantOptionDefinitions** (object) - Optional - Definitions for variant options. - **definitions** (array) - Required - List of definitions. - **name** (string) - Required - Name of the option definition. - **properties** (array) - Required - Properties for the option. - **value** (string) - Required - Value of the property. - **imageUrl** (string) - Optional - Image URL for the property. - **taxCode** (string) - Optional - Tax code for the product. - **category** (object) - Optional - Product category. - **uuid** (string) - Required - Category UUID. - **name** (string) - Required - Category name. - **metadata** (object) - Optional - Metadata for the product. - **inPos** (boolean) - Optional - Indicates if the product is in POS. - **source** (object) - Optional - Source information. - **name** (string) - Required - Name of the source. - **external** (boolean) - Required - Indicates if the source is external. - **taxRates** (array) - Optional - List of tax rate UUIDs. - **taxExempt** (boolean) - Optional - Indicates if the product is tax-exempt. - **createWithDefaultTax** (boolean) - Optional - Indicates if the product should be created with default tax. ### Request Example ```go package main import ( "fmt" "io/ioutil" "net/http" "strings" ) func main() { payload := strings.NewReader("{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"presentation\":{\"imageUrl\":\"string\",\"backgroundColor\":\"string\",\"textColor\":\"string\"},\"variants\":[{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"sku\":\"string\",\"barcode\":\"string\",\"price\":{\"amount\":0,\"currencyId\":\"AED\"},\"costPrice\":{\"amount\":0,\"currencyId\":\"AED\"},\"vatPercentage\":100,\"options\":[{\"name\":\"string\",\"value\":\"string\"}],\"presentation\":{\"imageUrl\":\"string\",\"backgroundColor\":\"string\",\"textColor\":\"string\"}}],\"externalReference\":\"string\",\"unitName\":\"string\",\"vatPercentage\":100,\"online\":{\"status\":\"ACTIVE\",\"title\":\"string\",\"description\":\"string\",\"shipping\":{\"shippingPricingModel\":\"FREE\",\"weightInGrams\":2147483647,\"weight\":{\"weight\":0,\"unit\":\"kg\"}},\"presentation\":{\"displayImageUrl\":\"string\",\"additionalImageUrls\":[\"string\"],\"mediaUrls\":[\"string\"]},\"seo\":{\"title\":\"string\",\"metaDescription\":\"string\",\"slug\":\"string\"}},\"variantOptionDefinitions\":{\"definitions\":[{\"name\":\"string\",\"properties\":[{\"value\":\"string\",\"imageUrl\":\"string\"}]}]},\"taxCode\":\"string\",\"category\":{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\"},\"metadata\":{\"inPos\":true,\"source\":{\"name\":\"string\",\"external\":true}},\"taxRates\":[\"497f6eca-6276-4993-bfeb-53cbbbba6f08\"],\"taxExempt\":true,\"createWithDefaultTax\":true}") url := "https://products.izettle.com/organizations/{organizationUuid}/products?returnEntity=SOME_BOOLEAN_VALUE" req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ``` -------------------------------- ### GET Product Library (Go) Source: https://developer.zettle.com/docs/api/product-library/reference This Go program demonstrates how to make a GET request to the product library. It prints the response status and body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/library?eventLogUuid=SOME_STRING_VALUE&limit=SOME_INTEGER_VALUE&offset=SOME_STRING_VALUE&all=SOME_BOOLEAN_VALUE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Inventory Stock with Pagination (Python) Source: https://developer.zettle.com/docs/api/inventory/reference Use Python's http.client to get inventory stock data. This example demonstrates making a GET request and printing the response body. ```python import http.client conn = http.client.HTTPSConnection("inventory.izettle.com") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/v3/stock/{inventoryUuid}?cursor=SOME_STRING_VALUE&limit=SOME_INTEGER_VALUE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Create Product (Kotlin) Source: https://developer.zettle.com/docs/api/product-library/reference Example of how to create a new product using the Kotlin OkHttp client. ```APIDOC ## POST /organizations/{organizationUuid}/products ### Description Creates a new product in the product library. ### Method POST ### Endpoint /organizations/{organizationUuid}/products ### Request Body - **uuid** (string) - Required - Unique identifier for the product. - **name** (string) - Required - Name of the product. - **description** (string) - Optional - Description of the product. - **presentation** (object) - Optional - Visual presentation details. - **imageUrl** (string) - Optional - URL for the product image. - **backgroundColor** (string) - Optional - Background color for the product display. - **textColor** (string) - Optional - Text color for the product display. - **variants** (array) - Required - List of product variants. - **uuid** (string) - Required - Unique identifier for the variant. - **name** (string) - Required - Name of the variant. - **description** (string) - Optional - Description of the variant. - **sku** (string) - Optional - Stock Keeping Unit for the variant. - **barcode** (string) - Optional - Barcode for the variant. - **price** (object) - Required - Pricing information. - **amount** (number) - Required - Price amount. - **currencyId** (string) - Required - Currency identifier (e.g., "AED"). - **costPrice** (object) - Optional - Cost price information. - **amount** (number) - Required - Cost amount. - **currencyId** (string) - Required - Currency identifier (e.g., "AED"). - **vatPercentage** (number) - Optional - VAT percentage for the variant. - **options** (array) - Optional - Options for the variant. - **name** (string) - Required - Option name. - **value** (string) - Required - Option value. - **presentation** (object) - Optional - Variant presentation details. - **imageUrl** (string) - Optional - URL for the variant image. - **backgroundColor** (string) - Optional - Background color for the variant display. - **textColor** (string) - Optional - Text color for the variant display. - **externalReference** (string) - Optional - External reference ID for the product. - **unitName** (string) - Optional - Name of the unit for the product. - **vatPercentage** (number) - Optional - Default VAT percentage for the product. - **online** (object) - Optional - Online sales details. - **status** (string) - Required - Online status (e.g., "ACTIVE"). - **title** (string) - Optional - Title for online display. - **description** (string) - Optional - Description for online display. - **shipping** (object) - Optional - Shipping details. - **shippingPricingModel** (string) - Required - Shipping pricing model (e.g., "FREE"). - **weightInGrams** (integer) - Optional - Weight in grams. - **weight** (object) - Optional - Weight details. - **weight** (number) - Required - Weight value. - **unit** (string) - Required - Weight unit (e.g., "kg"). - **presentation** (object) - Optional - Online presentation details. - **displayImageUrl** (string) - Optional - URL for the main display image. - **additionalImageUrls** (array) - Optional - Additional image URLs. - **mediaUrls** (array) - Optional - Media URLs. - **seo** (object) - Optional - SEO details. - **title** (string) - Optional - SEO title. - **metaDescription** (string) - Optional - SEO meta description. - **slug** (string) - Optional - SEO slug. - **variantOptionDefinitions** (object) - Optional - Definitions for variant options. - **definitions** (array) - Required - List of definitions. - **name** (string) - Required - Name of the option definition. - **properties** (array) - Required - Properties for the option. - **value** (string) - Required - Value of the property. - **imageUrl** (string) - Optional - Image URL for the property. - **taxCode** (string) - Optional - Tax code for the product. - **category** (object) - Optional - Product category. - **uuid** (string) - Required - Category UUID. - **name** (string) - Required - Category name. - **metadata** (object) - Optional - Metadata for the product. - **inPos** (boolean) - Optional - Indicates if the product is in POS. - **source** (object) - Optional - Source information. - **name** (string) - Required - Name of the source. - **external** (boolean) - Required - Indicates if the source is external. - **taxRates** (array) - Optional - List of tax rate UUIDs. - **taxExempt** (boolean) - Optional - Indicates if the product is tax-exempt. - **createWithDefaultTax** (boolean) - Optional - Indicates if the product should be created with default tax. ### Request Example ```kotlin import okhttp3.* import okhttp3.MediaType.Companion.toMediaTypeOrNull fun main() { val client = OkHttpClient() val mediaType = "application/json".toMediaTypeOrNull() val body = RequestBody.create(mediaType, "{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"presentation\":{\"imageUrl\":\"string\",\"backgroundColor\":\"string\",\"textColor\":\"string\"},\"variants\":[{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"sku\":\"string\",\"barcode\":\"string\",\"price\":{\"amount\":0,\"currencyId\":\"AED\"},\"costPrice\":{\"amount\":0,\"currencyId\":\"AED\"},\"vatPercentage\":100,\"options\":[{\"name\":\"string\",\"value\":\"string\"}],\"presentation\":{\"imageUrl\":\"string\",\"backgroundColor\":\"string\",\"textColor\":\"string\"}}],\"externalReference\":\"string\",\"unitName\":\"string\",\"vatPercentage\":100,\"online\":{\"status\":\"ACTIVE\",\"title\":\"string\",\"description\":\"string\",\"shipping\":{\"shippingPricingModel\":\"FREE\",\"weightInGrams\":2147483647,\"weight\":{\"weight\":0,\"unit\":\"kg\"}},\"presentation\":{\"displayImageUrl\":\"string\",\"additionalImageUrls\":[\"string\"],\"mediaUrls\":[\"string\"]},\"seo\":{\"title\":\"string\",\"metaDescription\":\"string\",\"slug\":\"string\"}},\"variantOptionDefinitions\":{\"definitions\":[{\"name\":\"string\",\"properties\":[{\"value\":\"string\",\"imageUrl\":\"string\"}]}]},\"taxCode\":\"string\",\"category\":{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\"},\"metadata\":{\"inPos\":true,\"source\":{\"name\":\"string\",\"external\":true}},\"taxRates\":[\"497f6eca-6276-4993-bfeb-53cbbbba6f08\"],\"taxExempt\":true,\"createWithDefaultTax\":true}") val request = Request.Builder() .url("https://products.izettle.com/organizations/{organizationUuid}/products?returnEntity=SOME_BOOLEAN_VALUE") .post(body) .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .addHeader("content-type", "application/json") .build() val response = client.newCall(request).execute() println(response) println(response.body?.string()) } ``` ``` -------------------------------- ### Get Product Status (Java) Source: https://developer.zettle.com/docs/api/inventory/reference Java example using Unirest to get product status. This requires the Unirest library to be included in your project. ```java HttpResponse response = Unirest.post("https://inventory.izettle.com/v3/products/status") .header("Authorization", "Bearer REPLACE_BEARER_TOKEN") .header("content-type", "application/json") .body("[\"497f6eca-6276-4993-bfeb-53cbbbba6f08"]") .asString(); ``` -------------------------------- ### Example: Fetch Preliminary Account Balance and Response Source: https://developer.zettle.com/docs/api/finance/user-guides/fetch-account-balance Example request to fetch the preliminary account balance. The response indicates the total balance and currency. ```bash GET /v2/accounts/preliminary/balance ``` ```json { "data": { "totalBalance": 100, "currencyId": "GBP" } } ``` -------------------------------- ### Get Transactions (Kotlin) Source: https://developer.zettle.com/docs/api/finance/reference This Kotlin example uses OkHttpClient to make a GET request for transaction data. Ensure your bearer token is correctly provided. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://finance.izettle.com/v2/accounts/LIQUID/transactions?start=2022-04-01T11:42:10.452-01:00&end=2022-04-01T11:42:10.452-01:00&includeTransactionType=SOME_ARRAY_VALUE&limit=100&offset=3") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Fetch All Products Source: https://developer.zettle.com/docs/api/product-library/user-guides/manage-products/fetch-products This example demonstrates how to fetch all products available in your Zettle account. It returns a list of product objects. ```json [ { "online": { "status": "ACTIVE", "title": null, "description": null, "shipping": null, "presentation": null, "seo": { "title": null, "metaDescription": null, "slug": "gloves" } }, "variantOptionDefinitions": null, "taxCode": null, "category": null, "metadata": null, "taxRates": [], "taxExempt": null }, ... ] ``` -------------------------------- ### Get Products Request (Kotlin) Source: https://developer.zettle.com/docs/api/product-library/reference This Kotlin example uses OkHttpClient to make a GET request to the Product Library API. Remember to substitute your organization UUID and bearer token. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://products.izettle.com/organizations/{organizationUuid}/products/v2?sort=SOME_BOOLEAN_VALUE") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Fetch Purchases with Discounts Source: https://developer.zettle.com/docs/api/purchase/user-guides/fetch-purchases/fetch-purchase-with-discount This example demonstrates how to fetch a list of purchases, including those with various discount types applied. It shows how to query for purchases and interpret the discount information in the response. ```APIDOC ## GET /purchases/v2 ### Description Fetches a list of purchases. This endpoint can be used to retrieve purchase history, including details about discounts applied to individual items and the overall purchase. ### Method GET ### Endpoint /purchases/v2 ### Query Parameters - **limit** (integer) - Optional - The maximum number of purchases to return. - **descending** (boolean) - Optional - If true, returns purchases in descending order by timestamp. ### Response #### Success Response (200) - **purchases** (array) - A list of purchase objects. - **purchaseUUID** (string) - Unique identifier for the purchase. - **amount** (integer) - The total amount of the purchase in the minor currency unit. - **currency** (string) - The currency code of the purchase (e.g., SEK). - **timestamp** (string) - The date and time the purchase was made. - **products** (array) - A list of products included in the purchase. - **name** (string) - The name of the product. - **unitPrice** (integer) - The price of one unit of the product. - **discount** (object) - Details of a discount applied to this specific product row. - **percentage** (integer) - The discount percentage. - **amount** (integer) - The discount amount in the minor currency unit. - **quantity** (integer) - The quantity the discount applies to. - **discountValue** (integer) - The total value of the discount for this product row. - **discounts** (array) - Details of discounts applied to the entire purchase. - **percentage** (integer) - The discount percentage for the entire purchase. - **value** (integer) - The total discount value for the entire purchase. ### Request Example ``` GET /purchases/v2?limit=10&descending=true ``` ### Response Example ```json { "purchases": [ { "source": "POS", "purchaseUUID": "9u9p8liUSmu9ZrH9NkzeOA", "amount": 15200, "vatAmount": 1628, "country": "SE", "currency": "SEK", "timestamp": "2021-01-15T12:17:03.164+0000", "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 } ] } ``` ``` -------------------------------- ### Get Product Updates (Python) Source: https://developer.zettle.com/docs/api/inventory/reference This Python example demonstrates fetching product updates using the http.client library. It establishes an HTTPS connection and sends a GET request with the necessary headers. ```python import http.client conn = http.client.HTTPSConnection("inventory.izettle.com") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/v3/products/updates?ts=SOME_STRING_VALUE&cursor=SOME_STRING_VALUE&limit=SOME_INTEGER_VALUE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Create Discount using Python Source: https://developer.zettle.com/docs/api/product-library/reference This Python example shows how to create a discount using the http.client library. Replace the placeholder token and organization UUID. ```python import http.client conn = http.client.HTTPSConnection("products.izettle.com") payload = "{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"amount\":{\"amount\":0,\"currencyId\":\"AED\"},\"percentage\":100,\"imageLookupKeys\":[\"string\"],\"externalReference\":\"string\"}" headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN", 'content-type': "application/json" } conn.request("POST", "/organizations/{organizationUuid}/discounts", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get Link ID Response (Success) Source: https://developer.zettle.com/docs/payment-integrations/reader-connect/reference Example of a successful response containing the link ID. ```json { "linkId": "009f739c-6620-43b0-978e-b245e723c57a" } ``` -------------------------------- ### Retrieve Product Options (Python) Source: https://developer.zettle.com/docs/api/product-library/reference Python example using http.client to fetch product options. Ensure your `REPLACE_BEARER_TOKEN` is correctly substituted. ```python import http.client conn = http.client.HTTPSConnection("products.izettle.com") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/organizations/{organizationUuid}/products/options", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Create Discount using Go Source: https://developer.zettle.com/docs/api/product-library/reference This Go program demonstrates creating a discount using the standard net/http package. Ensure you replace the placeholder token and organization UUID. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/discounts" payload := strings.NewReader("{\"uuid\":\"095be615-a8ad-4c33-8e9c-c7612fbf6c9f\",\"name\":\"string\",\"description\":\"string\",\"amount\":{\"amount\":0,\"currencyId\":\"AED\"},\"percentage\":100,\"imageLookupKeys\":[\"string\"],\"externalReference\":\"string\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Products Request (Java) Source: https://developer.zettle.com/docs/api/product-library/reference Example of making a GET request to the Product Library API using Unirest in Java. Remember to replace placeholders with your specific organization UUID and bearer token. ```java HttpResponse response = Unirest.get("https://products.izettle.com/organizations/{organizationUuid}/products/v2?sort=SOME_BOOLEAN_VALUE") .header("Authorization", "Bearer REPLACE_BEARER_TOKEN") .asString(); ``` -------------------------------- ### Create Product Online Slug (Go) Source: https://developer.zettle.com/docs/api/product-library/reference Go example for creating a product's online slug. Ensure `REPLACE_BEARER_TOKEN` is replaced with your actual token. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/products/online/slug" payload := strings.NewReader("{\"productName\":\"string\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Fetch Purchases by Date Range Source: https://developer.zettle.com/docs/api/finance/user-guides/fetch-purchase-information-for-transactions Use this GET request to retrieve purchase information starting from a specified date. Set `startDate` to the last time you fetched purchases to ensure you get new data. ```http GET /purchases/v2?startDate={startDate} ``` ```http /purchases/v2/?startDate=2020-11-19 ``` -------------------------------- ### Successful Response for Get Integrator Links Source: https://developer.zettle.com/docs/payment-integrations/reader-connect/reference Example of a successful JSON response when retrieving integrator links. ```json [ { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "organizationUuid": "bc554ded-7e40-44a7-b397-48480793ad03", "readerTags": { "model": "Reader", "serialNumber": "123ABC" }, "integratorTags": { "name": "My speedy reader" } } ] ``` -------------------------------- ### Example: Create a STORE Inventory Source: https://developer.zettle.com/docs/api/inventory/user-guides/manage-inventories/create-inventories This example demonstrates creating a STORE inventory with specific name and description. The Authorization header must include your Bearer token. ```http POST /inventories ``` ```json { "name": "T-shirt with a start print", "description": "The inventory shows the stock balance of T-shirt with a start print." } ``` -------------------------------- ### Start Offline Payment Source: https://developer.zettle.com/docs/payment-integrations/android-sdk/user-guides/manage-offline-card-payments Initiate an offline payment by creating a `TransactionReference` and then using `CardReaderAction.OfflinePayment.charge` to get the payment intent. ```APIDOC ## Start offline payment To start an offline payment, use `CardReaderAction.OfflinePayment`. First, create a `TransactionReference` object: ```kotlin val internalTraceId = UUID.randomUUID().toString() val reference = TransactionReference.Builder(internalTraceId) .put("PAYMENT_EXTRA_INFO", "Started from home screen") .paypalPartnerAttributionId("bnCode") .build() ``` Then, start the offline payment: ```kotlin val intent: Intent = CardReaderAction.OfflinePayment( amount = amount, reference = reference, tippingConfiguration = tippingConfiguration ).charge(context = this) paymentLauncher.launch(intent) ``` ``` -------------------------------- ### Retrieve Product Options (Go) Source: https://developer.zettle.com/docs/api/product-library/reference Go program to retrieve product options. This example includes necessary imports and error handling for the HTTP request. Replace the placeholder token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://products.izettle.com/organizations/{organizationUuid}/products/options" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ```