# Ka-ching Developers > Ka-ching is a cloud point-of-sale (POS) system. These docs cover its public APIs: a REST API for reading checkouts, customers, loyalty points, products, receipts and sales stats; import endpoints for pushing data (products, stock, customers, ...) into Ka-ching; export integrations (webhooks) for receiving sales and register close statements; runtime integrations the POS calls on your server; and CSV import. - Base URLs: `https://europe-west1-ka-ching-base.cloudfunctions.net` (EU) and `https://us-central1-ka-ching-base.cloudfunctions.net` (US). - REST API (`/rest/...`): pass `account=` as a query parameter and a REST API key in the `X-API-Key` header. REST API keys are created in the back office under Advanced -> REST API. - Import endpoints (`/imports/...`): pass `account`, `integration` (import queue ID) and `apikey` (import queue key) as query parameters. These keys are separate from REST API keys. - 404 responses have an empty body and mean "no data". --- Source: https://developers.ka-ching.dk/index.md # Ka-ching Developers > Documentation for integrating with the Ka-ching ecosystem. On this site you can find details about Ka-ching integration points, import and export of data, as well as integrations to provide extra functionality in the POS and related apps. Before you start reading the documentation, please have a look at our [Vocabulary](./vocabulary.md), which explains many terms that are referred to in the documentation. A lot of the concepts discussed in this documentation also has counterparts in the [Ka-ching Backoffice](https://backoffice.ka-ching.dk), so please have a look in there as well. On the [Resources](./resources.md) page, you can find sample requests that can be used with the `Postman` tool. Please contact us, if you would like use to provide you with account and api keys for testing. If you have any questions or would like to get in touch with us, please feel free to send an e-mail to . For more information about Ka-ching, please visit [https://ka-ching.dk](https://ka-ching.dk) --- Source: https://developers.ka-ching.dk/vocabulary.md # Vocabulary > Vocabulary of all the terms used on the Ka-ching developer site. ## Vocabulary In order to understand the overall documentation, it is necessary with a clear definition of the terms that we are using. This section aims to describe the entirety of the terms that we use in the system. Any oversights should be reported to ### Account When we talk about an account in Ka-ching, we are referring to your account in the Ka-ching system. An account may span several markets/countries and may contain many shops in each of these markets. Often an account will reflect an entire chain of shops. ### User An account is not directly coupled to a single user. Instead a user in the Ka-ching system simply refers to a validated identity - in other words an actual person. This de-coupling means that one user could for instance be an account owner (see definition for [Account Owner](#account-owner)) for several accounts - or shop owner (see definition for [Shop Owner](#shop-owner)) for several shops - even shops spanning different accounts. The de-coupling will have the advantage that the identity and credentials of a single user can be kept as a secret for that user, and not shared between many users. When for instance a shop owner leaves the company, the user access rights can just be withdrawn. ### Market A `market` in the Ka-ching system is a region in which the same currency is used and the same default taxes are used. In many situations a `market` will correspond to a country, but in some situations it may be beneficial to have several markets within the same country or alternatively one market spanning several countries. Since all shops in the same market share their currency, the `market` is also the largest entity in which we aggregate sales statistics and the like. ### Shop A `shop` in the Ka-ching system corresponds to a physical shop. As such, a shop belongs to a specific `market` (read: country), and from here the shop gets the currency and default taxes. ### Register When we speak about a register we mean a physicial cash register - represented by the Ka-ching POS app running on an iPad or an iPhone. Typically one register will have a cash drawer, a printer, a scanner and a credit card terminal. ### Cashier A `cashier` represents the person that completes the sale at a cash register. Note that `cashiers` do not log into the system. The `Shop Owner` logs into the system, and the `cashier` may change at any time after the `Shop Owner` has logged in. This means that the access rights to data in the system is determined by the `Shop Owner` credentials and not by the `cashier`. In the future we may add several mechanisms for verifying a cashier (pin-code, id card swipe, etc.), but it is important to know that the current cashier is still _just_ a property of the current sale, and not a `User` in the system as defined above. For sales statistical purposes, sales are grouped by the `cashier` so that KPIs and performance can be measured per `cashier`. ### Account owner The `account owner` is a role in our system that gives a `User` access to read and change all data for an `account`. It should be thought of as an administrative role in the system that has the power to invite or dismiss `shop owners` and make basic configuration choices on behalf of the entire `account`. ### Shop owner The `shop owner` is, as the name suggests, the owner of a `shop` who only has access to configuration and data pertaining to the specific `shop` - and also read (not write) access to shared data for the entire `account` like the product database and configuration of currencies and taxes. ### Pricing vocabulary Pervasive in the Ka-ching system is naturally the idea of a `sale` and the pricing of products. We have very clear definitions of the involved vocabulary: #### Retail price This is the price of a product to be sold. The precise definition is 'the price that you would print on a label attached to the product'. This means that in countries using VAT, the retail price should include the VAT, while in countries using sales tax, the price would not include the sales tax. #### Cost price This is the price that the shop paid for the product. This price is ALWAYS without tax. In our system the `cost price` is an optional value, but in case it is entered, we can calculate the margins earned from the sales. #### Sub total This is the result of subtracting all discounts from the `retail price`. Like the retail price it includes any VAT and excludes any sales taxes. #### Base price This is the result of excluding all taxes from the `sub total`, so that it can be compared to the cost price and used to calculate `margins`. This means that in markets using only sales taxes, the `base price` and `sub total` will correspond. #### Margin This is the `base price` minus the `cost price`. It is optional since it can only be calculated if the `cost price` is present. It may become negative in case the product is sold cheaper than the `cost price`. #### Total This is the total including all taxes (both VAT and Sales Tax). This means that in markets where only VAT is used, the `total` and `sub total` will correspond. #### Margin total Since not all products have `cost prices` associated with them, we can only calculate the `margins` from the ones that do. So when calculating the ratio between the total and the margin, we need to keep the total for products where we _can_ calculate margins separate from the totals where we _can not_. This consideration justifies the existence of the `margin total` which is equal to the `total` if the `margin` can be calculated and 0 if it cannot. This means that when summarizing values, we can always get the correct margin ratio by taking the `margin` and divide it by the `margin total`. If we need to find out the total amount for which we cannot calculate this ratio (due to missing cost prices), we can subtract the `margin total` from the `total`. #### Total VAT amount Tax types are split into `VAT` and `Sales Tax` types (see section about [Taxes](#taxes)), so this is the sum of the taxes that are of `VAT` type. #### Total Sales Tax amount This is the sum of the taxes that are of `Sales Tax` type. #### Total Tax amount This is the sum of all the taxes. ### Sale A `sale` may refer to the actual physical sale in progress in a shop, but more commonly it will refer to our representation of a sale when the sale is complete. Note that in the Ka-ching system, a `return` of items is also represented using the `Sale` entity, but clearly marked as being a return, and with negated values for pricing and the like. ### Taxes Our product model supports any number of taxes to be added to a product simultaneously - or different taxes on different products. The rules for calculating taxes when multiple taxes are present are defined by standard mathematics. Examples will be given below after our two main types of taxes have been explained: #### VAT VAT is a _value added tax_ which is common in Europe. For VATs, the tax amount is _included_ in the `retail price` of a product. For instance a product with a `retail price` of 100 DKK with a VAT rate of 25% has a `base price` of 80 DKK and a VAT of 20 DKK (and a `total` price matching the `retail price` of 100 DKK). #### Sales Tax Sales Tax is a tax that is added _at_ the point of sale. Sales Tax is used in the US. A product with a `retail price` of $100 and a Sales Tax of 17% will have a `total` price of $117 (and a `base price` matching the `retail price` of $100). #### Multiple taxes - example The rule for calculating taxes is very simple: **"Taxes are never taxed."** - meaning that you never apply a tax to an amount that already includes another tax amount. This means that we just need the base price - and this can be used to find the tax amount for each separate tax. Let us imagine a market where four separate tax rates were applied when selling a product. Two separate sales taxes and two separate VATs (the names of the taxes are completely imaginary): * VTX: 10% VAT * MTX: 5% VAT * STX: 7% Sales Tax * XTX: 3% Sales Tax In order to understand the tax calculation for this combination of taxes, imagine a product with a `retail price` of 230 DKK. Remember that `retail price` is the price that you would print on a label and put on the physical product and that it thus includes all VAT taxes. The total VAT is (10% + 5% = ) 15%, so the `base price` of the product is (230 / 1.15 = ) 200 DKK. From the base price we can now find all tax amounts: * VTX: (200 * 10%) 20 DKK * MTX: (200 * 5%) 10 DKK * STX: (200 * 7%) 14 DKK * XTX: (200 * 3%) 6 DKK So our summaries for the imaginary product are: * Base price: 200 DKK * VAT total: 30 DKK * Retail price: 230 DKK * Sub total: 230 DKK (same as retail price when we have no discounts) * Sales tax total: 20 DKK * Total: 250 DKK To verify we can see that our retail price calculation was correct and that applying the total tax amount (10 + 5 + 7 + 3 =) 25% to the base price gives the total: 200 * 1.25 = 250 DKK This may sound a bit complicated, but most likely you will only ever need to think about zero or one VAT rate or zero or one Sales Tax rate. :-) #### Discounts The Ka-ching system models discounts in a standard fashion while allowing discounts to come from a number of different sources. One basic kind of discount is the `manual discount` which is manually added by the `cashier` at the time of the sale. Another kind is the `sale discount` which is an easy-to-configure discount type that can be added directly when configuring the product in the Ka-ching Portal or when importing products to the Ka-ching system. `Sale discounts` give the products a new price while still showing the original price in the POS so that you can visualize the savings from the discount. Finally we have the discount campaign rules where you can configure advanced rules for triggering automatic discounts. Such campaign rules could be: "Give a 10% discount when adding three or more items of a specific type to the basket". Notice that only manual discounts can be edited and removed in the POS, the automatic ones are applied by system-defined rules and thus cannot be modified by the `cashier`. #### Discount applications Common for the discounts is how the discount is applied (or calculated). One is `new price` which basically changes the price of a product to the specified new price. Another application type is `percentage` which calculates the discount as a percentage of the price of the sold item. The `amount off` discount gives a fixed amount discount to an item. Common for all application types is that fact that a discount _cannot end up making the price negative_. The price _may_ become more expensive by applying a discount (and yes, there are use cases for this situation), but negatively priced products do not exist in the Ka-ching system, and as such any discount is capped to not making the product cheaper than 0. #### Multiple discounts Discounts are applied in order, and many discounts may modify the price of the same line item. For instance a product may have an automatic discount of 10%, but then get a manual `new price` discount and finally have an extra 5% discount that is applied to the entire basket. When we store records about our sales, we specify in detail how the discounts are applied to each line item. ### Register Close Statements When opening a register you enter an opening float (the amount of cash available in the register when it is opened). All sales, returns, cash drawer opens, etc. are registered and logged. When you close the register, all these events are stored as accumulated records for the total sales, total returns. All details of a single sale are accumulated into totals, so that the total taxes (grouped by tax type), total discounts, total cost prices etc. are represented in the `Register Close Statement`. Similar accumulated totals are also present grouped by the `product group` of the sold products. Finally, the `Register Close Statement` contains information about reconciliations of any payment type for which reconciliation is necessary (for instance for `cash`). ### Integration An `integration` in the Ka-ching system can refer to an [Import Integration](./import-integrations-overview.md), an [Export Integration](./export-integrations.md) or any of the integrations used by the POS system, which we call [Runtime Integrations](./runtime-integrations-overview.md). For instance we could refer to a `Product Import Integration`, a `Sales Export Integration` or an `E-commerce Product Search Integration`. ### Products and variants A `product` is the representation of a physical product to be sold in the Ka-ching system. Products may have associated attributes that describe the details of the product. Note that not every `product` in the system is sellable. Some products may have `variants` associated with it. A `variant` may describe the size of a t-shirt or it's color. As such `variants` describe attributes of the product that sets it apart from others, but when you still logically think of the different variations as being the same `product`. This is of course a modelling choice - you can also model differently sized t-shirts as entirely separate products if you so wish. ### Basket In the POS, the products that we are selling are added to the current `basket`. You can think of this as a physical shopping basket, which is emptied when the customer makes a purchase, and the `basket` is ready for the next customer. ### Line item When adding products to a shopping basket, the representation of the products are referred to as `line items`. This means that a line item will typically correspond to some product information and a quantity. For instance a single line item may describe 10 Cappucinos. ### External Order An external order is a model describing an order or reservation that's been made in a different location than the pick up point. It is used when using our Reserve & Collect and Click & Collect features. An external order contains information about items, quantities, prices and discounts. It can also contain basic information about the customer who's pickup up the order as well as information about whether it's already been paid or not. --- Source: https://developers.ka-ching.dk/models.md > A walkthrough of the different data models used in Ka-ching when importing and exporting data. # Models Please have a look at our [Vocabulary](vocabulary.md) for an explanation of the overall concepts used in the Ka-ching system. Each of the models described below have a lot of related concepts. For instance the `sale` describes recorded discounts _in context of a sale_. As such the description of this `discount` representation can be found in the documentation for the `sale`. Pervasive to the entire system is the concept of the _localizable string_, so this is explained here first: ## L10nString Many text properties in the Ka-ching system are localizable by default. As this is not always desirable or practical, we model this using the `L10nString` construct. This construct allows us to have either a plain string, which carries no additional information, or a localized string, which carries localizations for numerous languages. Examples: __Unlocalized__ ```json "Chair" ``` __Localized__ ```json { "da": "Stol", "de": "Stuhl", "en": "Chair" } ``` ## Market Price Every time you specify a price in Ka-ching you have to think about [markets](./vocabulary.md#market). If you have more than one market defined on your account, it's likely that you have different prices for each product in each market. For example a can of Coca Cola could be 10 kr in Denmark and 13 kr in Sweden. So there are to ways to specify a price in Ka-ching. Take a look at the examples below. __Same price for all markets__ ```json { "retail_price": 10 } ``` __Difference price for each market__ ```json { "retail_price": { "dk": 10, "no": 13, "se": 13 } } ``` ## Product First of all, an example of a product with localized name and description properties: ```json { "barcode" : "5714081000426", "cost_price" : 10, "description" : { "en" : "This is a really weird product. Transparent Cola must be a Danish speciality.", "da" : "Lækker og sund sportsdrik. Gør dig sandsynligvis til et bedre menneske." }, "id" : "-Kaw7xNDADAjHKSpWRqJ", "image_url" : "https://cdn.shopify.com/s/files/1/0017/4184/8641/files/ka-ching-logo_360x.png?v=1522756522", "name" : { "da" : "Klar cola", "en" : "Transparent Cola", }, "product_group" : "beverages", "retail_price" : 30, "taxes" : [ { "name" : "Speciel moms", "rate" : 0.13, "type" : "vat" } ] } ``` The only required properties of a product is `id` and `name`. If a product has no `retail_price`, it is interpreted to be a `variable price product`, where the price is entered at the time of sale. Taxes generally do not need to be specified, since the `market` in which a product is sold defines a default tax. Bar codes can be used for EAN, SKU, ISBN or other means of identifying a product by it's bar code. Cost prices are optional, and are not directly displayed in the POS, but since they are needed in order to calculate margins, we recommend to include this information whenever possible. Please refer to the [Import Integrations](./import-integrations-overview.md) for further details about the product model. ## Sale A __`sale`__ is a record of a completed sale (or return) in the system. The record contains all the data that is relevant to the sale, and the data in here also serves as a building block for generating receipts. In the root of the sale we define basic properties of the sale: ```json { "base_currency": "", "identifier": "", "payments": [...], "receipt_metadata": [...], "sequence_number": "", "source": [...], "summary": [...], "timing": [...], "voided": "" } ``` __`sale.payments`__ There will be one entry per payment method. For instance a sale that totals 100 DKK may be paid with 50 DKK on credit card and 50 DKK in cash. Two special payment entries will often occur when dealing with cash payments: rounding and cashback. Rounding is added in countries where the lowest currency denomination is greater than the lowest payable amount. For instance in Denmark the smallest denomination is 0.50 DKK (See the wikipedia entry: [Swedish Rounding](https://en.wikipedia.org/wiki/Cash_rounding)) ```json [ { "amount": "", "foreign_currency": "", "foreign_currency_amount": "", "identifier": "", "payment_type" : "", "success" : "", "error": "", "metadata: "", "receipts: "" } ] ``` The `metadata` and `receipts` fields are usually ignored by integrators as the content is usually only relevant in the Ka-ching system. If you need or want to parse it, please contact us for further info about the data. __`sale.receipt_metadata`__ Optional element containing receipt metadata. ```json { "footer": "", "header": "", "shop_address" : { "city": "", "name": "", "street": "", "zip": "" } } ``` __`sale.source`__ ```json { "market_id": "", "market_name": "", "shop_id": "", "shop_name": "", "register_id": "", "register_name": "", "cashier_id": "", "cashier_name": "" } ``` #### `sale.summary` This summary both contains sub totals, totals, taxes, discounts, etc. for the entire sale - and also for each of the line items in the sale. ```json { "base_price": "", "comment": "", "customer": [...], "is_return": "", "line_items": [...], "margin": "", "margin_total": "", "purchase_type": "<..., optional>", "return_reference": "", "sales_tax_amount": "", "sub_total": "", "taxes": [...], "total": "", "total_discounts" : "", "total_tax_amount" : "", "vat_amount" : "" } ``` Note that if the `is_return` flag is `true`, then the summary represents a return of goods. __`sale.timing`__ This is a representation of the point in time in which the sale was made - as well as the time zone. These two pieces of information are used to generate a few representations of the time stamp for convenience. See the [tz database wikipedia entry](https://en.wikipedia.org/wiki/Tz_database) for more information. ```json { "timestamp": "", "timestamp_string": "", "timezone": "", "timestamp_date_string": "", "timestamp_week_string": "", } ``` __`sale.summary.customer`__ The identifier of the customer that might be associated with a given sale. Due to GDPR compliance, name and address is only populated if the customer has an organization number, with the assumption that it's then a business customer. ```json { "identifier": "", "name": "", "street": "", "city": "", "postal_code": "", "city": "", "country": "", "country_code": "" "email": "", "phone": "", "organization_number": "" } ``` __`sale.summary.line_items`__ A line item contains information about the product that it represents: ```json { "barcode": "", "base_price": "", "behavior": [...], optional see below "cost_price": "", "dimensions": [...], optional see below "discounts": [...], optional see below "ecom_id": "", "id": "", "image_url": "", "line_item_id": "", "margin": "", "margin_total": "", "name": "", "product_group": "", "quantity": "", "retail_price": "", "sales_tax_amount": "", "sub_total": "", "tags": [...], optional see below "taxes": [...], optional see below "total": "", "total_tax_amount": "", "variant_id": "", "vat_amount": "", "comment": "" } ``` __`sale.summary.line_items[n].dimensions`__ If dimensions are used to describe the variant of this product, this will contain one or more dimensions. ```json { "id": "", "name": "", "value": { "id": "", "name": "", "color": "" } } ``` __`sale.summary.line_items[n].discounts`__ See [Discount Summary](#discount-summary) __`sale.summary.purchase_type`__ A purchase type can be a special price across all sold products. ```json { "name": "", "identifier": "" } ``` __`sale.summary.line_items[n].tags`__ List of associated tags. Products can be attributed with any number of informal `tags`. These are for instance currently being used for category filtering in the POS. These are included in the line item details as an array of strings for reference. __`sale.summary.taxes`__ and __`sale.summary.line_items[n].taxes`__ List of taxes in this sale / involving this line item. See [Tax Summary](#tax-summary) for details. __`sale.summary.line_items[n].behavior`__ If the behavior field is present it means that the line item has special behavior. Currently we have 8 different line item behaviors: * `shipping` * `giftcard` * `voucher` * `giftcard_use` * `voucher_use` * `expense` * `customer_account_deposit` * `container_deposit` Only one of these fields can be present on one line item. Not all accounts use all of these behaviors, so it's not always necessary to implement handling of all of them right away. __`sale.summary.line_items[n].behavior.shipping`__ ```json { "address" : [...], optional, "customer_info" : [...], optional, "method_id" : " } ``` The shipping data is related to all line items with the same value in `ecom_id` as the line item with the shipping behavior. At the moment we only support 1 ecommerce order per checkout in POS, but in the future it may be possible to have more than 1 per checkout. So to process an ecommerce order made in POS, find all items with `ecom_id` != null and group them per `ecom_id` value. In each group a line item with shipping behavior should be present. __`sale.summary.line_items[n].behavior.shipping.address`__ ```json { "city" : ", "country" : ", "country_code" : ", "name" : ", "postal_code" : ", "street" : " } ``` __`sale.summary.line_items[n].behavior.shipping.customer_info`__ ```json { "email" : ", "phone" : " } ``` __`sale.summary.line_items[n].giftcard`__ ```json { "code" : "", "integration_id" : "", "payment_type_id" : "giftcard.integration", "report": [...], optional, used by Ka-ching to generate receipt so it's safe to ignore } ``` __`sale.summary.line_items[n].voucher`__ ```json { "code" : "", "integration_id" : "", "payment_type_id" : "voucher.integration", "report": [...], optional, used by Ka-ching to generate receipt so it's safe to ignore } ``` __`sale.summary.line_items[n].giftcard_use`__ ```json { "code" : "", "integration_id" : "", "payment_type_id" : "giftcard.integration" } ``` __`sale.summary.line_items[n].voucher_use`__ ```json { "code" : "", "integration_id" : "", "payment_type_id" : "voucher.integration" } ``` __`sale.summary.line_items[n].expense`__ ```json { "identifier" : "", "image_urls" : } ``` __`sale.summary.line_items[n].customer_account_deposit`__ ```json { "customer_id": "", "payment_type_id": "" } ``` __`sale.summary.line_items[n].container_deposit`__ ```json { "product_id": "", "tag": "", "rule_id": "", "parent_line_item_id": "" } ``` An example of a complete sale: ```json { "base_currency_code" : "DKK", "identifier" : "DBC5D956-6945-414C-B872-90137F113CD8", "payments" : [ { "amount" : 500, "identifier" : "D2286271-4F30-4395-914F-5A98AA26C0B0", "payment_type" : "card.external", "success" : true }, { "amount" : 3310, "identifier" : "4547E098-57D5-4F40-9EA7-DE8557F2841C", "payment_type" : "cash", "success" : true }, { "amount" : 0.05, "identifier" : "E44E3F45-D9CC-4ED3-A3D3-CBA911068C69", "payment_type" : "cash.rounding", "success" : true } ], "receipt_metadata" : { "footer" : "Hav en god dag\nVarer ombyttes ikke.", "header" : "Tak for handlen!", "shop_address" : { "city" : "Aarhus", "name" : "Ka-ching, Aarhus", "street" : "Katrinebjergvej 115", "zip" : "8200" }, "vat_number" : "38683829" }, "sequence_number" : 1, "source" : { "cashier_id" : "01955FE1-A5DE-431F-ACBA-97B09F3FA6A3", "cashier_name" : "USC", "market_id" : "dk", "market_name" : "Danmark", "register_id" : "C2FD043D-4719-4A69-BBFD-5DDFF0EFB8DC", "register_name" : "iPad Pro (9.7-inch)", "shop_id" : "aarhus", "shop_name" : "Ka-ching, Aarhus" }, "summary" : { "base_price" : 3048.04, "is_return" : false, "line_items" : [ { "barcode" : "4210024", "base_price" : 2872, "dimensions" : [ { "id" : "color", "name" : "Color", "value" : { "id" : "warm_white_brass", "name" : "Warm white/Brass" } } ], "id" : "1048", "image_url" : "https://cdn.shopify.com/s/files/1/0017/4184/8641/files/ka-ching-logo_360x.png?v=1522756522", "line_item_id" : "E2B20A95-69E0-421A-9D2A-354CDFCC1A5A", "name" : { "da" : "Ambience Bordlampe", "en" : "Ambience Table lamp, Sparkling rose" }, "quantity" : 2, "retail_price" : 3590, "sales_tax_amount" : 0, "sub_total" : 3590, "tags" : [ "bordlamper", "belysning" ], "taxes" : [ { "amount" : 718, "name" : "Moms", "rate" : 0.25, "type" : "vat" } ], "total" : 3590, "total_tax_amount" : 718, "variant_id" : "1053", "vat_amount" : 718 }, { "base_price" : 136.04, "dimensions" : [ { "id" : "BB0440B7-993B-4D07-A83E-AD59BD5E1862", "name" : "Color", "value" : { "color" : "#AA8800", "id" : "7D72EC85-28BE-417F-9D3C-C5D7F66A4CF7", "name" : "Orange" } }, { "id" : "40982BAE-E1C9-4CB4-B639-3F678B19EF83", "name" : "Size", "value" : { "id" : "8D878328-10BE-4F02-ADC0-5C1A55A49A51", "name" : "M" } } ], "discounts" : [ { "amount" : 8.95, "discount" : { "application" : { "line_item" : "849D58D8-F0D4-45ED-B25B-C77BA2C6C388" }, "id" : "39973A80-17F5-4171-8101-FF3C964581C1", "mode" : { "manual" : true }, "type" : { "percentage" : 0.05 } } } ], "id" : "prodId-36601", "image_url" : "https://cdn.shopify.com/s/files/1/0017/4184/8641/files/ka-ching-logo_360x.png?v=1522756522", "line_item_id" : "849D58D8-F0D4-45ED-B25B-C77BA2C6C388", "name" : "Asics Dame Allover Graphic Kortærmet Top", "quantity" : 1, "retail_price" : 179, "sales_tax_amount" : 0, "sub_total" : 170.05, "taxes" : [ { "amount" : 34.01, "name" : "Moms", "rate" : 0.25, "type" : "vat" } ], "total" : 170.05, "total_tax_amount" : 34.01, "variant_id" : "6408E763-DF40-4A4F-8D24-36C65F6C1405", "vat_amount" : 34.01 }, { "base_price" : 40, "cost_price" : 70, "id" : "asteroids", "image_url" : "https://cdn.shopify.com/s/files/1/0017/4184/8641/files/ka-ching-logo_360x.png?v=1522756522", "line_item_id" : "30838E39-525D-4F66-9037-5321472EB997", "margin" : -30, "margin_total" : 40, "name" : "Asteroids", "quantity" : 1, "retail_price" : 50, "sales_tax_amount" : 0, "sub_total" : 50, "tags" : [ "retro" ], "taxes" : [ { "amount" : 10, "name" : "Moms", "rate" : 0.25, "type" : "vat" } ], "total" : 50, "total_tax_amount" : 10, "vat_amount" : 10 } ], "margin" : -30, "margin_total" : 40, "sales_tax_amount" : 0, "sub_total" : 3810.05, "taxes" : [ { "amount" : 762.01, "name" : "Moms", "rate" : 0.25, "type" : "vat" } ], "total" : 3810.05, "total_discounts" : 8.95, "total_tax_amount" : 762.01, "vat_amount" : 762.01 }, "timing" : { "timestamp" : 1.5471910861096148E9, "timestamp_date_string" : "2019-01-11-08-01", "timestamp_string" : "2019-01-11T07:18:06Z", "timestamp_week_string" : "2019-02", "timezone" : "Europe/Copenhagen" }, "voided" : false } ``` ### Discount Summary As a part of a `sale`, we record detailed information about all the discounts applied to a `sale`. This information includes the discount amount, but also information about the type of discount and how it was applied. All this can be used to trace the origin of the applied discounts. If you are only interested in the discount amount, please disregard all other fields than the `amount`. ```json { "amount" : "", "discount" : { "application" : [...], "id": "", "mode": [...], "name": "", "type": [...] } } ``` ```json { "application": "", "id": "", "mode": "", "name": "", "trigger": "" "type": "" } ``` __application__ This can take one of three values, and is what this discount is applied to. `basket` applies to the entire basket. ```json { "basket": "" } ``` `line_item` applies to each item in a line item ```json { "line_item": "" } ``` `items` applies to individual item ranges that may be part of several line items. For instance a reference to a line item with a quantity of three could reference just one of the three. This is done using a map from the line item identifier to either an index or a range index. ```json { "line_items": [ "": { "index": "" } }] } ``` ```json { "line_items": [ "": { "start_index": "", "end_index": "" } }] } ``` __mode__ Manual discount, added by cashier ```json { "manual": true } ``` Automatic discount, added by the system - either from a sale discount on the product or from a triggered discount rule. ```json { "automatic" : { "domain" : "", "identifier" : "" } } ``` `domain` can be one of the following: - `KX_SALE_PRICE_DOMAIN` if triggered by a product sale price - `KX_PROMOTION_DOMAIN` if triggered by a promotion campaign __discount type__ The type of discount given. - `amount` fixed discount. - `amount_per_item` fixed discount per item. - `percentage` percentage discount. - `percentage_with_max` percentage discount with a maximum value given. - `new_price` replaces the retail price of the line with a new price. - `new_price_per_item` replaces the retail price of every item in a line with a new price. __Trigger__ This optional element is present if the discount was triggered by a promotion campaign. ```json { items: "", count: "" } ``` `items` can be on of the following: - `basket` triggered by the entire basket - `line_item` triggered by an entire line item - `items` triggered by individual line items, that can be part of several line items ### Tax Summary As described in the [Vocabulary](./vocabulary.md), a tax has a type (VAT or Sales Tax). Furthermore it has a tax rate and a name. ```json { "amount": "", "rate": "", "tax_name": "", "type": "" } ``` ## Checkouts To understand the `Checkout` entity for existing integratores, we'll start with a brief history of the `Sale` entity ### First step - keeping separate concepts separate When we built the first version of the Ka-ching POS, we had some previous experience relating to fiscalization and the issues with having to identify sales and returns for the purpose of Electronic Journals and statistics. With this previous experience a ‘transaction’ or ‘checkout’ (the process of a customer making a purchase or a return or both) was identified as a ‘return’ in case the total was negative and a ‘sale’ otherwise. This was not a very accurate representation of the truth, so with Ka-ching we decided to be more detailed in our modelling of the world. We built the ‘Sale’ entity and this entity could either represent an actual sale or a return - but not both at once. With this we were much more explicit about logging and counting of what was going on. Initially we could actually also only handle either a sale or a return in a single ‘transaction’ or ‘checkout’ - so back then there was a 1 to 1 between the checkout and the ‘Sale’ entity created. ### Everything in a single checkout After a while we then got the possibility to handle both sales and returns in a single ‘transaction’ or ‘checkout’. In order to stay compatible with previous versions - and also with the fiscalization logging and journalling, we built this flow so that we still create ‘Sale’ entities, but from a single ‘checkout’ we then generate several ‘Sale’ entities where one may represent a return and another a sale. All sale entities are marked with the same ‘checkout_identifier’ to show that they come from the same checkout. ### Frozen baskets The concept of being able to produce several sales from a single checkout had further advantages. There is a key difference between the basket of an ongoing sale - and then a basket representing returned items. The former is ‘live’ and totals, taxes and discounts are evaluated continuously as the contents change. The latter is static or frozen - it actually represents a summary of a previous sale, so it does not make sense to apply discounts on the returned items or try recalculating taxes, etc. Other entities could take advantage of the concept of frozen baskets. For instance a sales quote that is added to the basket is basically an agreement between the customer and a sales person about a final price for a specific purchase of items. This means that these should again be kept separate from the live basket and always represent the sales quote from when the terms were agreed upon. ### The drawback With regards to external systems, not everyone are able to collect the separate sales that make up an entire checkout. We agree that the task of collecting these into one entity is indeed our responsibility - because otherwise all (or many) third party integrators end up having to implement this logic themselves. The current collection step is enabled by a flag on the sales export configuration. When this is present we have a service that groups sales together - and after a period of idle time the entity is exported if all sales are present. Unfortunately this heuristics about waiting for a certain time period is both error prone (things take different time based on a lot of external conditions) and a bit expensive (having microservices ‘wait’ for something basically means that we have to pay for the awaited idle time). We can do better. ### Introduction of the Checkout entity Having a dedicated Checkout entity is of course the answer to the problem. The first requirement is the definition of the entity and then being able to create it from a list of sales. Secondly we need to hook this entity up with our export engine, and that basically gives us the bare minimum to start deprecating the sales grouping mentioned above. But having a dedicated checkout entity is basically a more correct modelling of the environment, so there are many future steps we could take with this entity. __checkout__ ```json { "identifier": , "voided": , "timing": , "source": , "base_currency_code": "", "payments": , "receipt_metadata": , "sales": [array of sale parts] } ``` __checkout.sale__ Similar to the sale entity, but without the things that are already present on the checkout and would thus be redundant: ```json { "identifier": , "sequence_number": , "basket": , "fiscal_rules_data": } ``` Note the renaming of the 'summary' from a sale to the term 'basket' here. We think that this provides a better description of the contained data. ## Register Close Statement A `register close statement` is a record of a register close action in the POS, with any reconciliation details added. The record contains all the data that is relevant to the register close, and the data in here also serves as a building block for generating register close receipts (the Z-report). In the root of the `register close statement`, we define basic properties of the statement: ```json { "base_currency_code": "", "comment": "", "reconciliation_time": "", "sequence_number": "", "shop_info": [...], "source": [...], "register_summary": [...], "reconciliations": [...], "timing": [...] } ``` __`shop_info`__ Optional element containing shop information. ```json { "vat_number": "", "shop_address" : { "city": "", "name": "", "street": "", "zip": "" } } ``` __`reconciliations`__ An array of reconciliations - one per payment type configured for the account. For cash payments there will be an additional entry per foreign currency that has been used for cash payment in the current register period. ```json { "counted": "", "currency_code":", "deposited_amount": "", "depositing": "", "payment_type_identifier": "", "should_be_reconciled": "", "total": "", "credit": "", "debit": "", "transaction_count": "", "transaction_count_credit": "", "transaction_count_debit": "" } ``` Only certain payment types require reconciliation, this fact is represented by the 'should_be_reconciled' flag. For all payment types that do not require reconciliation, the 'counted' property will always equal the 'total'. Only cash payment needs depositing. Cash in base currency has manual depositing (the cashier describes how much is deposited) while currently all foreign currencies have automatic depositing (meaning that all foreign cash in the register is deposited at register close). Other payment types will have 'none' for the 'depositing' property. The payment type identifier is a reference to the payment type in the Ka-ching system. This can be one of (but not limited to): `cash`, `card.external`, `card.payex`, `card.izettle`, `giftcard.external`, `giftcard.integration`, `mobilepay.external`, `mobilepay.integration`. __`register_close_statement.register_summary`__ ```json { "all": "", "all_by_product_group": "", "sales": "", "sales_by_product_group": "", "returns": "", "returns_by_product_group": "", "expenses": "", "cash_drawer_open_count": "", "cash_total_at_open": "", "id": "", "number_of_aborted_sales": "", "number_of_initiated_sales": "", "opened_at": "", "voided_count": "", "event_counts": } ``` The `all` key contains a total summary of both sales, returns and expenses. Since the values in the `returns` and `expenses` summary are negative, the amounts in the `all` summary can be less than those in the `sales` summary. The `sales` key contains a similar summary, but only accounting for the sales, not the returns. The `returns` key contains a similar summary, but only accounting for the returns, not the sales. The `expenses` key contains a similar summary, but only accounting for expenses. The `*_by_product_group` contain a similar summary, but grouped into the ids of the sold items. Any sold items that do not belong to a product group are grouped into the special `__none__` group. __`sales summary`__ ```json { "base_price": "", "margin": "", "margin_total": "", "sub_total": "", "total": "", "total_discounts": "", "total_tax_amount": "", "vat_amount": "", "sales_tax_amount": "", "count": "", "item_count": "", "payments": [...], "tax_summaries": [...] } ``` __`sales summary.payments[n]`__ ```json { "totals": { "base_currency_total" : , "base_currency_total_credit" : , "base_currency_total_debit" : , "base_currency_transaction_count" : , "base_currency_transaction_count_credit" : , "base_currency_transaction_count_debit" : , "total" : , "total_credit" : , "total_debit" : , "transaction_count" : , "transaction_count_credit" : , "transaction_count_debit" : , "foreign_currencies": "", "foreign_currencies_credit": "", "foreign_currencies_debit": "", "foreign_currencies_transaction_count": "", "foreign_currencies_transaction_count_credit": "", "foreign_currencies_transaction_count_debit": "" }, "type": "" } ``` The payments array has an entry per payment type used in the register period. The `type` specifies the payment type in question. The `base_currency_total` specifies the total amount paid in the base currency, where the `foreign_currencies` map contain all totals for all foreign payments in the foreign currency. The `total` specifies the total value in the base currency when converting all totals to base currency and adding them together. The sales summary will also contain an entry for the `cash.rounding` pseudo payment type that is used to aggregate all rounding errors due to [Swedish Rounding](https://en.wikipedia.org/wiki/Cash_rounding) __`sales summary.tax_summaries[n]`__ ```json { "amount": "", "rate": "", "name": "", "type": "" } ``` The tax_summaries array has an entry per tax registered during the register period. The entries correspond to the [Tax Summary](#tax-summary) also used in the `sale` entity. __`sales summary.tax_summaries[n]`__ ```json { "amount": "", "rate": "", "name": "", "type": "" } ``` The tax_summaries array has an entry per tax registered during the register period. The entries correspond to the [Tax Summary](#tax-summary) also used in the `sale` entity. __`event_counts`__ ```json { "app_launch" : , "app_quit" : , "cash_drawer_opened" : , "cashier_selected" : , "discount_added" : , "expenses" : , "line_item_added" : , "line_item_summaries_added" : , "register_opened" : , "sale" : , "sale_initiated" : } ``` The event counts dictionary contains a number of counts of events that happened while the register was opened. These events are the same as those that you can find in the Electronic Journal in the POS. Here is the full list of events that are currently being counted: `cash_drawer_opened` `register_opened` `register_closed` `return` `void` `sale` `expenses` `sale_aborted` `sale_initiated` `x_report_generated` `line_item_added` `line_item_removed` `line_item_quantity_adjusted` `discount_added` `discount_removed` `customer_added` `customer_removed` `app_launch` `app_quit` `cashier_selected` `line_item_summaries_added` `line_item_summaries_removed` `sales_quote_given` `basket_saved` `post_payment_fiscal_event` `pre_copy_print_fiscal_event` `payment_reversal` `receipt_print_copy` __`register_close_statement.timing`__ ```json { "timestamp" : , "timestamp_date_string" : "", "timestamp_string" : "", "timestamp_week_string" : ", "timezone" : "" } ``` ## Expense An expense is represented by an `id`, a `name` and an optional list of `taxes`: ~~~json { "expenses": [ { "id": "0001", "name": "Forplejning", "taxes": [ { "name": "Ingen moms", "rate": 0, "type": "vat" } ] }, { "id": "0002", "name": "Forplejning ude af huset", "taxes": [ { "name": "Kvartmoms", "rate": 0.0625, "type": "vat" } ] }, { "id": "0003", "name": "Andet" } ] } ~~~ The `name` property is an `L10nString` and may thus optionally contain localization information. The `taxes` property is either a flat list of taxes or an object with lists keyed by a market identifier. ## Order An order is a model describing an order or reservation that's been made in a different location than the pick up point. It is used when using our Reserve & Collect, Click & Collect, Ship from Store and Online order features. Ka-ching can both receive incoming orders from external systems (or from other shops) and place orders to external systems (or to other shops). An order contains information about items, quantities, prices and discounts. It can also contain basic information about the customer who's pickup up the order as well as information about whether it's already been paid or not. ```json { "order_identifier": "", "basket": "", "customer": "", "payment": "", "shipping": " } ``` If an order does not have a payment reference, it is considered to be a 'Reserve & Collect' order which is paid upon collection in the shop. If an order has a payment reference, but no shipping information, it is considered to be a 'Click & Collect' order, which is pre-paid but must be collected in the shop. If an order has both payment and shipping information, it is considered to be a 'ship from store' order which is shipped to the customer by the shop receiving the order. __`order.customer`__ ```json { "customer_identifier": "", "name": "", "email": "", "phone_number": "", } ``` __`order.payment`__ ``` { "reference": "" } ``` A payment reference into an external system. __`order.shipping`__ ``` { "address": "
", "method_id": "", "method_title": "", "method_subtitle": "", } ``` This information is presented when the order is prepared in Ka-ching POS. The optional method id, title and subtitle may be used to suggest an alternative shipping method than the default. These values are also shown in POS along with the order, so they can be taken into account by the cashier that is shipping off the order. __`order.shipping.address`__ ``` { "name": "", "street": "", "city": "", "postal_code": "", "country": "", "country_code": "", } ``` __`order.basket`__ When placing orders in Ka-ching from external systems, we support a lean and simplified representation of a basket - as described below. When Ka-ching places orders in different shops internally, the full fledged [`sale.summary`](#salesummary) entity (described above) is being used instead. This is also the case when using the 'Outgoing order export' for receiving e-com orders. ```json { "currency": "", "line_items": [], "discounts": [] } ``` __`order.basket.line_items[n]`__ ``` { "product_identifier": "", "variant_identifier": "", "barcode": "", "image_url": "", "discounts": [], } ``` __`order.discount`__ ```json { "name": "", "type": "", "discounts": "" } ``` ## Customer The bare minimum information for a customer is the customer id. Any other details like name, address, email and phone number will be of extra help for the cashier. The `additional_info` may be used to present some custom free text to the cashier that may be of relevance. It will be displayed to the cashier and could for instance include information about birthdays, customer rating or similar details from the CRM system. ~~~json [ { "identifier": "", "name": "", "street": "", "city": "", "postal_code": "", "country": "", "country_code": "", "phone": "", "email": "", "additional_info": "", "organization_number": "", "balance": { // optional, DEPRECATED. This format is still supported, but the shorter version below without the identifier is the preferred. "identifier": "", "balance": }, "balance": , "balance_overdue": , "credit_limit": , "block_sales": , } ] ~~~ As can be seen, all properties other than the identifier are optional. The more of the properties that are filled out, the better the integration will be. ### Additional info The `additional_info` field is plain text that will be shown to the cashier when looking at the customer details. This can be used to convey useful extra information. Notice the `country_code` field. This may be used in conjunction with the `Shipping Options` integration, where the integration can limit the accepted `country codes` for shipping. ### B2B customers For B2B customers - or customers that represent other businesses, the system offers more customization: A customer is interpreted to be a 'B2B' customer if an 'organization number' is present. This value represents a VAT number or what in Danish is called a 'CVR' number. When a sale is made to a non-B2B customer, we only store the customer identifier on the sale in order to avoid any privacy issues. But when selling to businesses we store information like the name and address, so this can be added directly to the invoices that we produce. ### Credit limit and balance Often - and especially in B2B situations - a business may choose to give their customers credit. If they do, then the 'balance' and 'credit limit' become relevant. In case a customer has a credit limit of 1,000 DKK and a current balance of -500 (meaning that the customer owes your business 500 DKK), then the customer is still allowed a credit of 500 DKK. This means that purchases using the payment types 'Customer Account' and 'Invoice' (which are both considered to be payment types that give the customer credit) are blocked if the purchase amount exceeds 500. Or to put it more algorithmically: If the payment type is 'invoice' or 'customer account' and the PURCHASE AMOUNT - BALANCE > CREDIT LIMIT then the payment will be blocked and the customer needs to choose another method of payment. Example: Purchase amount: 501 Balance: -500 Credit limit 1000 501 - (-500) = 1001 1001 > 1000, so payment is blocked. ### Balance overdue and Customer Account In case your business uses the 'Customer Account' feature, then it is possible for the customer to make a deposit to the account in the shop. If a customer has a balance of -500 then this balance could be due to several unpaid invoices. For instance there may be an invoice for 300 and one for 200. If the invoice for 300 is overdue, then this could be represented as: ~~~ { "identifier": "1234", "balance": -500, "balance_overdue": -300 } ~~~ When adding this customer to a sale, the 'balance overdue' information will be used to prompt the cashier to ask the customer to make a 'customer account' deposit for the overdue amount of 300. ### Blocking sales Setting `block_sales` to `true` disallows sales to the customer entirely. This can be used to express that the customer has proven bad credit and dealings with the customer may be illegal. ## External Sale The external sale is represented by a bit of metadata along with all of the line items from the sale. ~~~json [ { "timestamp": , "source": "", "id": "", "line_items": [ { "product_id": , "variant_id": , "product_name": , "variant_name: , "quantity": , "total": , "vat": , "sales_tax": }, ... ] } ] ~~~ --- Source: https://developers.ka-ching.dk/import-integrations-overview.md # Import integrations overview > How to use the Ka-ching import integrations to import your own data. ## Overview The Ka-ching system contains a number of flexible APIs for importing various types of data in various use cases. Most of the examples shown here has been added to a Postman collection that you can download on the [resources](./resources.md#Postman collection) page. The data types that can currently be imported are: * [Attributes](attributes-import-integration.md) * [Attribute groups](attribute_groups-import-integration.md) * [Discount campaigns](discount-campaigns-import-integration.md) * [Expenses](expenses-import-integration.md) * [Incoming orders](incoming-orders-import-integration.md) * [Facets](facet-import-integration.md) * [Folders](folders-import-integration.md) * [Loyalty point events](loyalty-point-events.md) * [Product Assets](product-assets-import-integration.md) * [Product groups](product-groups-import-integration.md) * [Product recommendations](product-recommendations-import-integration.md) * [Product rules](product-rules-import-integration.md) * [Products](products-import-integration.md) * [Recommendation Categories](recommendation-categories-import-integration.md) * [Stock](stock-import-integration.md) * [Tabs](tabs-import-integration.md) * [Tags](tags-import-integration.md) The common way to perform the import is through our https import endpoints. We recommend that data is pushed to the Ka-ching system on every data change in the integrating system. This will provide for real-time data updates in the entire chain. An alternative to this solution is to batch import updated products periodically, but that naturally eliminates the real-time aspect of the integration. Some data can also be imported as CSV-files through our Back Office. This feature is only intended for a quick-start setup, since this requires manual steps, and the CSV format is not very well suited for hierarchically structured data like for instance our Products. This means that the flat CSV format cannot describe all available details for our products. Finally data can be imported through actions performed in our clients. Please refer to [Runtime integrations](runtime-integrations-overview.md) for documentation about these 'runtime' integrations. ## Image Import The Image Import varies from the above in that it has no direct endpoint. Instead an account can be configured to use image importing or not, and if image importing is enabled, then all referenced images will be processed by an image import queue and be placed in the Ka-ching system CDN. There are both advantages and disadvantages to enabling image importing: #### Advantages of using image importing * The Ka-ching system CDN is operated by Google and has nodes all over the world, so downloading resources is fast. * Images added to the Ka-ching system CDN will automatically have thumbnails generated * If content is deleted from your own CDN they will still be available in the Ka-ching CDN * The POS client lives in the iOS ecosystem where App Transport Security is enabled. This means that security for http requests are enforced, basically disallowing non-https request and https TLS versions that are deemed insecure. If your images are imported to the Ka-ching CDN, they will be served from a secure connection that is verified to run with App Transport Security. #### Reasons for not using image importing * We have set a size limitation of 2048x2048 pixels in our image importer, since the memory pressure for the image processing is expensive. Hosting your own images circumvents this limitation although having larger images will also be costly in traffic to each of the POS clients. * If you have a fast and stable CDN for hosting your images - and they are already in an appropriate format, then you may as well continue to use that. --- Source: https://developers.ka-ching.dk/import-queues-authentication.md # Shared Import Integration Authentication > Authentication for Ka-ching Import Integration Queues. ## Shared Import Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey` as parameters. ~~~ https://{BASE_URL}/imports/products?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ## Import Queues For each data type that can be imported, any number of import queues can be created. Using the import endpoints, it is possible to specify which import queue to target. This means that you could configure separate data sources and keep this distinct for the purpose of debugging and monitoring. When an item lands in the import queue, it will immediately be processed by the Ka-ching system. This processing may either fail or succeed. All successfully processed items will be placed in a success log and all failed imports will be placed in a failure log. At Ka-ching we can monitor the queues and logs if granted permission by you, and in the future it will also be possible for you to monitor these yourself. All items in the success and failure logs are annotated with time stamps and success or error messages. Since the processing happens asynchronously and per processed item, it is not currently possible to get the import status back through the import endpoint. The queue logs need to be examined to determine the success / failure of the import. ### Import Queue Security Model When posting data to an import endpoint you need to provide an `API key`. The `API key` identifies access to a specific `import queue`. For each import queue, any number of `API keys` can be created, but through our Back Office, we reuse API keys between integrations by default. The `API keys` determines the appropriate access rights for writing data into the import queues. All access to the import endpoints using a given `API key` are logged with the IP of the client and a timestamp in order to give us the possibility to monitor and prevent abuse. --- Source: https://developers.ka-ching.dk/customer-import-integration.md # Customers Import Endpoint > How to use the Ka-ching customers import endpoint. ## The `Customer` Import Endpoint ~~~ https://{BASE_URL}/imports/customers ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. E.g.: ~~~ https://{BASE_URL}/imports/customers ~~~ You may post a JSON array containing any number of `Customers` to the endpoint. Existing customer data is overwritten based on the identifier. Please have a look at the [`Customer`](./models.md#customer) entity model for more information. ####JSON Example ```json [ { "identifier": "1234", "name": "Morten Bek Ditlevsen", "street": "Hyggevej", "city": "Århus", "postal_code": "8123", "country": "Denmark", "country_code": "dk", "phone": "+45 12345678", "email": "morten@ka-ching.dk", "additional_info": "Likes single malt whiskies and would like a taste.", "organization_number": "34355878", "balance": -500, "balance_overdue": -300, "credit_limit": 1000, "block_sales": false }, { "identifier": "1235", "block_sales": true } ] ``` ### Deleting `Customers` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of all the identifiers for customers that you wish to delete. ~~~ [ "1234", "1235", "1236" ] ~~~ --- Source: https://developers.ka-ching.dk/customer_attributes-import-integration.md # Customer Attributes Import Endpoint > How to use the Ka-ching customer attributes import endpoint. ## The `Customer Attributes` Import Endpoint ~~~ https://{BASE_URL}/imports/customer_attributes ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Customer Attributes` to the endpoint. Existing attributes are overwritten based on their id. #### JSON Example ~~~json [ { "id": "member_type", "name": { "da": "Medlemstype", "en": "Member type" }, "type": { "options": { "gold": { "id": "gold", "name": { "da": "Guld", "en": "Gold" } }, "platinum": { "id": "platinum", "name": { "da": "Platin", "en": "Platinum" } } } } }, { "id" : "rating", "name" : "Rating", "type" : { "number" : { "scale" : 0, "suffix" : "points" } } }, { "id" : "note", "name" : "Note", "type" : { "text": { "text": true } } }, ... ] ~~~ ### Models The attribute model looks like this ~~~json { "id": "", "name": "", "type": "" } ~~~ [L10nString](models.md#L10nString) is a localized string. There are 3 types of attributes - options - number - text The simplest is the `text` type. Since we just need to specify that the attribute is a free text attribute, we just need a presence in the json. ~~~json { "text": { "text": true } } ~~~ For the `number` type you need to specify a decimal scale and a suffix that can be used in presentation. The suffix can be an empty string if you don't need any. ~~~json { "number" : { "scale" : "", "suffix" : "" } } ~~~ The `options` attribute type specifies a set of text options that a product can use. ~~~json { "options": { "denmark": { "id": "", "name": "" }, "france": { "id": "", "name": "" } } } ~~~ ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/customer_attributes?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Attributes` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Product Attribute` ids. ~~~json [ "country", "grape" ] ~~~ --- Source: https://developers.ka-ching.dk/discount-campaigns-import-integration.md # Discount Campaigns Import Endpoint > How to use the Ka-ching discount campaigns import endpoint. ## The `Discount Campaign` Import Endpoint ~~~ https://{BASE_URL}/imports/discount_campaigns ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. ### Advanced Discount Campaign Import Parameters When importing `Discount Campaigns` you can additionally specify which `Markets` you wish to import for. The default market is `dk` (Denmark) - signifying all `Shops` in the Danish market. The default can be overridden by the query parameter `markets`. The value is comma separated lists of markets. E.g.: ~~~ https://{BASE_URL}/imports/discount_campaigns?markets=dk,se,no&... ~~~ For further clarification of the `Market` concept, please read the [Vocabulary](./vocabulary.md). ### Importing Discount Campaigns Send a `POST` request to the endpoint with the parameters specified above. The body of the `POST` request must be a JSON object with the following layout: ~~~json { "campaigns": { [campaign A], [campaign B], ... } } ~~~ Common for all `Discount Campaign` types are the following properties: ``` { "id": "string, required", "type": "string, required", "name": "string, required", "display_name": "string, required", "priority": number, required } ``` `id` must be a unique identifier for this campaign `type` must match one of the supported discount campaign template types that can be seen below `name` is the internal name of the campaign `display_name` is the name of the discount when applied to a line item in the basket `priority` is the priority of the campaign. Campaigns with higher priorities are evaluated before campaigns with lower priorities. ~~~json { "campaigns": [ { "id": "0001", "type": "percentage_discount-count_or_more-single_product", "product_id": "jumper", "percentage": 0.42, "name": "Jumper discount week 42", "display_name": "Jumper Discount", "count": 3, "priority": 40 }, { "id": "0002", "type": "percentage_discount-tag", "tag": "clothing", "percentage": 0.42, "name": "Clothes discount", "display_name": "Clothes discount", "priority": 60 }, { "id": "0003", "type": "new_price_discount-single_product", "product_id": "pants-501", "new_price_per_item": {"dk": 42, "no": 60}, "name": "Pants sale week 42", "display_name": "New price discount", "priority": 80 }, { "id": "0004", "type": "percentage_discount-count_or_more-multiple_products", "product_ids": ["jumper", "pants"], "percentage": 0.5, "name": "Pants and jumpers half price week 42", "display_name": "Buy three half price", "count": 3, "priority": 40 }, { "id": "0005", "type": "new_price_discount-count_or_more-single_product", "product_id": "glove-one-size", "new_price_per_item": 42, "name": "New price discount", "display_name": "New price discount", "priority": 80, "count" : 2 }, { "id": "0006", "type": "percentage_discount-stair-single_product", "display_name" : "Discount", "name" : "Prgoressive zinfandel discount", "priority" : 40, "product_id" : "zinfandel", "steps" : [ { "count" : 3, "percentage" : 0.1 }, { "count" : 6, "percentage" : 0.15 }, { "count" : 9, "percentage" : 0.2 } ] }, { "id" : "0007", "type": "new_price_discount-stair-single_product", "continue_evaluation" : true, "display_name" : "Discount", "name" : "Progressive nail discount", "priority" : 50, "product_id" : "9-inch-nail", "steps" : [ { "count" : 3, "new_price_per_item" : { "dk" : 100, "norge" : 150 } }, { "count" : 6, "new_price_per_item" : { "dk" : 90, "norge" : 130 } }, { "count" : 9, "new_price_per_item" : { "dk" : 80, "norge" : 110 } } ] }, { "id" : "0008", "type": "percentage_discount-stair-tag", "display_name" : "Discount", "members_only" : true, "name" : "Progressive discount on all red wines", "priority" : 10, "steps" : [ { "count" : 3, "percentage" : 0.1 }, { "count" : 6, "percentage" : 0.15 }, { "count" : 9, "percentage" : 0.2 } ], "tag" : "red-wine" }, { "id" : "0009", "type": "percentage_discount-count_or_more-tag", "count" : 3, "display_name" : "Discount", "name" : "Percentage discount for all red wines at 3 or more", "percentage" : 0.1, "priority" : 2, "tag" : "red-wine" }, { "id": "0010", "type": "new_price_discount-single_product", "product_id": "10-m-cable", "new_price_per_item_if_cheaper": {"dk": 42, "no": 60}, "name": "10 m cables price if cheaper than normal price", "display_name": "Special price", "priority": 80 }, { "id": "0011", "type": "new_price_discount-count_or_more-single_product", "product_id": "10-m-cable", "new_price_per_item_if_cheaper": 42, "name": "10 m cables price if cheaper than normal price at 2 or more", "display_name": "Special price", "priority": 80, "count" : 2 }, { "id" : "0012", "type": "new_price_discount-stair-single_product", "continue_evaluation" : true, "display_name" : "Special price", "name" : "Progressive 10 m cables price if cheaper than normal price", "priority" : 50, "product_id" : "10-m-cable", "steps" : [ { "count" : 3, "new_price_per_item_if_cheaper" : { "dk" : 100, "norge" : 150 } }, { "count" : 6, "new_price_per_item_if_cheaper" : { "dk" : 90, "norge" : 130 } }, { "count" : 9, "new_price_per_item_if_cheaper" : { "dk" : 80, "norge" : 110 } } ] } ] } ~~~ > *NOTE* > > When discount campaigns are imported into the Ka-ching system, the `id` will be used as a unique key. > > One limitation in the database we are using (the Firebase real-time database) is that not all characters are valid to use in keys. > > This means that the following list of characters may not be used in the "id" field of a discount campaign: `.`, `/`, `#`, `$`, `*`, `[` and `]` ### Campaign Types: Percentage by condition on count If you wish to give a discount to one or more products based on the presence of a specific count (or more) of a product you can use the types `percentage_discount-count_or_more-single_product` and `percentage_discount-count_or_more-multiple_products`: ~~~json { "campaigns": [ { "id": "0001", "type": "percentage_discount-count_or_more-single_product", "product_id": "abc", "percentage": 0.42, "name": "ABC discount", "display_name": "Discount", "count": 3, "priority": 40 } ] } ~~~ This will give a 42% discount on the product with id `abc` if there are 3 or more of these in the basket. ~~~json { "campaigns": [ { "id": "0001", "type": "percentage_discount-count_or_more-multiple_products", "product_ids": ["abc", "def"], "percentage": 0.42, "name": "ABC discount", "display_name": "Discount", "count": 3, "priority": 40 } ] } ~~~ This will give a 42% discount on the products with either id `abc` or `def` if there are 3 or more of these in the basket in total. This will then trigger if there is 1 * abc and 2 * def. ### Campaign Types: Percentage by presence of tag ~~~json { "campaigns": [ { "id": "0002", "type": "percentage_discount-tag", "tag": "clothing", "percentage": 0.42, "name": "Clothes discount", "display_name": "Clothes discount", "priority": 60 } ] } ~~~ This will give a 42% discount unconditionally for products that contain the tag `clothing`. ### Campaign Types: Percentage by presence of tag with condition on count ~~~json { "campaigns": [ { "id": "0003", "type": "percentage_discount-count_or_more-tag", "tag": "clothing", "percentage": 0.42, "name": "Clothes discount", "display_name": "Clothes discount", "count": 3, "priority": 80 } ] } ~~~ This will give a 42% discount for products that contain the tag `clothing` but only if there are 3 or more items with that tag. ### Campaign Types: New price by product ~~~json { "campaigns": [ { "id": "0003", "type": "new_price_discount-single_product", "product_id": "abc", "new_price_per_item": 42, "name": "New price discount", "display_name": "New price discount", "priority": 80 } ] } ~~~ This will give a 'new price' discount unconditionally for the product with id 'abc'. This is similar to modelling a `sale price` directly on the product. ### Campaign Types: New price by product with condition on count ~~~json { "campaigns": [ { "id": "0003", "type": "new_price_discount-count_or_more-single_product", "product_id": "abc", "new_price_per_item": 42, "name": "New price discount", "display_name": "New price discount", "count": 3, "priority": 80 } ] } ~~~ This will give a 'new price' discount for the product with id 'abc', but only if there are 3 or more items that id. ### Campaign Types: New price 'stair' for a single product ~~~json { "campaigns": [ { "id": "0003", "type": "new_price_discount-stair-single_product", "product_id": "abc", "name": "Price stair", "display_name": "Price stair", "steps": [ { "count": 3, "new_price_per_item": 100 }, { "count": 6, "new_price_per_item": 90 }, { "count": 9, "new_price_per_item": 80 } ], "priority": 80 } ] } ~~~ This will create a 'new price' stair for the product with id 'abc'. This means that for 1 or 2 items, the price will be the default. For 3-5 or more it will be 100, for 6-8 it will be 90 and for 9 or more it will be 80. ### Campaign Types: Percentage discount 'stair' for a single product ~~~json { "campaigns": [ { "id": "0003", "type": "percentage_discount-stair-single_product", "product_id": "abc", "name": "Percentage stair", "display_name": "Percentage stair", "steps": [ { "count": 3, "percentage": 0.1 }, { "count": 6, "percentage": 0.15 }, { "count": 9, "percentage": 0.2 } ], "priority": 80 } ] } ~~~ This will create a 'percentage' stair for the product with id 'abc'. This means that for 1 or 2 items, the price will be the default. For 3-5 or more it will be discounted with 10%, for 6-8 it will be discounted with 15% and for 9 or more it will be discounted with 20%. ### Campaign Types: Percentage discount 'stair' for a products matching a certain tag ~~~json { "campaigns": [ { "id": "0003", "type": "percentage_discount-stair-tag", "tag": "clothing", "name": "Percentage stair", "display_name": "Percentage stair", "steps": [ { "count": 3, "percentage": 0.1 }, { "count": 6, "percentage": 0.15 }, { "count": 9, "percentage": 0.2 } ], "priority": 80 } ] } ~~~ This will create a 'percentage' stair for the products matching the tag 'clothing'. This means that for 1 or 2 items, the price will be the default. For 3-5 or more it will be discounted with 10%, for 6-8 it will be discounted with 15% and for 9 or more it will be discounted with 20%. ### Campaign Types: Amount off discount 'stair' for a products matching a certain tag ~~~json { "campaigns": [ { "id": "0003", "type": "amount_discount-stair-tag", "tag": "clothing", "name": "Amount off stair", "display_name": "Amount off stair", "steps": [ { "count": 3, "amount_per_item": 10 }, { "count": 6, "amount_per_item": 15 }, { "count": 9, "amount_per_item": 20 } ], "priority": 80 } ] } ~~~ This will create a 'amount off' stair for the products matching the tag 'clothing'. This means that for 1 or 2 items, the price will be the default. For 3-5 or more it will be reduced by 10, for 6-8 it will be reduced by 15 and for 9 or more it will be reduced by 20. ### Campaign Types: Free shipping by total amount ~~~json { "campaigns": [ { "id": "0003", "type": "free_shipping_by_amount", "name": "Free shipping", "display_name": "Free shipping", "amount_condition": 1000, "priority": 80 } ] } ~~~ This will create a discount campaign, that will reduce the price of all shipping line items to 0 in case the total (for all line items excluding shipping line items, and after applying all previous discounts) is greater than or equal to 1000,-. ### Only applying 'new price' if it is cheaper than the original price Example: ~~~json { "campaigns": [ { "id": "0010", "type": "new_price_discount-single_product", "product_id": "10-m-cable", "new_price_per_item_if_cheaper": {"dk": 42, "no": 60}, "name": "10 m cables price if cheaper than normal price", "display_name": "Special price", "priority": 80 } ] } ~~~ This will give a 'new price' discount only if the new price for the particular product is less than the calculated price in the basket. This is useful if you for example have different purchase types fx. "Member prices" and those prices are cheaper than the default prices with this discount applied. Using the "if cheaper" discount only applies the new price if it's cheaper than what's already calculated at that point in the basket. To use this, just specify the key `new_price_per_item_if_cheaper` instead of `new_price_per_item`. This is available for all the 'new price' discount rules: `new_price_discount-single_product`, `new_price_discount-count_or_more-single_product"` and `new_price_discount-stair-single_product` ### Discount Campaigns across multiple markets When using this type of campaign across different markets, it becomes necessary to specify the new price in each of the markets. This can be done as follows: ~~~json { "campaigns": [ { "id": "0003", "type": "new_price_discount-single_product", "product_id": "abc", "new_price_per_item": { "dk": 42, "no": 60 }, "name": "New price discount", "display_name": "New price discount", "priority": 80 } ] } ~~~ A discount stair could look as follows in multiple markets: ~~~json { "campaigns": [ { "id": "0002", "type": "new_price_discount-stair-single_product", "product_id": "abc", "name": "ABC discount", "display_name": "Discount", "steps": [ { "count": 3, "new_price_per_item": { "dk": 100, "norge": 150 } }, { "count": 6, "new_price_per_item": { "dk": 90, "norge": 130 } }, { "count": 9, "new_price_per_item": { "dk": 80, "norge": 110 } } ], "priority": 50 } ] } ~~~ ### Creating 'member only' discounts For any discount campaign template, you may specify 'members only' on the template. The interpretation of this field is that the discount will only apply if there is a customer attached to the current sale. ~~~json { "campaigns": [ { "id": "0003", "type": "percentage_discount-stair-tag", "tag": "vin", "name": "Member discount", "members_only": true, "display_name": "Member discount", "steps": [ { "count": 3, "percentage": 0.1 }, { "count": 6, "percentage": 0.15 }, { "count": 9, "percentage": 0.2 } ], "priority": 10 } ] } ~~~ The discount stair above will only apply when a customer is present on the sale. ### Allowing multiple discounts on the same item For any discount campaign template, you may specify 'continue evaluation' on the template. The interpretation of this field is that even after applying this specific discount, the same item can receive other discounts as well. ~~~json { "campaigns": [ { "id": "0003", "type": "new_price_discount-single_product", "product_id": "merlot", "new_price_per_item": 100, "name": "New price discount", "display_name": "New price discount", "members_only": true, "continue_evaluation": true, "priority": 80 }, { "id": "0004", "type": "percentage_discount-stair-tag", "tag": "wine", "name": "Percentage discount", "display_name": "Percentage discount", "steps": [ { "count": 3, "percentage": 0.1 }, { "count": 6, "percentage": 0.15 }, { "count": 9, "percentage": 0.2 } ], "priority": 10 } ] } ~~~ Imagine that you sell a bottle of wine with the product id: "merlot". The product is tagged with "wine" and it costs 150 DKK. The first discount (0003) will only trigger for members and will reduce the price to 100 per bottle. If you buy 6 of these, you will furthermore get a discount (from discount 0004) of 15% on top of the discountet price. The total will be (100 * 6) * (1 - 0.15) = 510 DKK (85 DKK per bottle) ### Deleting `Discount Campaigns` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Discount Campaign` ids. ~~~json [ "0001", "0003" ] ~~~ --- Source: https://developers.ka-ching.dk/expenses-import-integration.md # Expenses Import Endpoint > How to use the Ka-ching expenses import endpoint. ## The `Expenses` Import Endpoint ~~~ https://{BASE_URL}/imports/expenses ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. ### Advanced Expense Import Parameters When importing `Expenses` you can additionally specify which `Markets` you wish to import for. The default market is `dk` (Denmark). This default can be overridden by the query parameter `markets`. The value for the parameter is a comma separated lists of markets. E.g.: ~~~ https://{BASE_URL}/imports/expenses?markets=dk,se,no&... ~~~ For further clarification of the `Market` concept, please read the [Vocabulary](./vocabulary.md). ### Importing Expenses Send a `POST` request to the endpoint with the parameters specified above. The body of the `POST` request must be a JSON object with the following layout: ~~~json { "expenses": [ [expense A], [expense B], ... ] } ~~~ The definition of the `Expense` model can be found in the [Models](./models.md) document. The minimal data required for an expense is an `id` and a `name`: ~~~json { "expenses": [ { "id": "0001", "name": "Catering" }, { "id": "0002", "name": "External catering" } ] } ~~~ > *NOTE* > > When expenses are imported into the Ka-ching system, the `id` will be used as a unique key. > > One limitation in the database we are using (the Firebase real-time database) is that not all characters are valid to use in keys. > > This means that the following list of characters may not be used in the "id" field of an expense: `.`, `/`, `#`, `$`, `*`, `[` and `]` The only other property of an expense is a list of `taxes`. By not specifying any `taxes`, the default value added taxes for the relevant market will be used. Note that the value added taxes of an expense are 'incoming taxes' while taxes from sold goods are 'outgoing taxes'. They will be registered as such on the `Z-report`. Different countries have different value added taxes for different kinds of expenses. In Denmark we have a lowered VAT for dining out with clients ('repræsentation'). We have no VAT for catering at the shop - for instance when buying pizzas when doing stock counts. And finally we have regular VAT when buying items relevant to running the shop - paper, scissors, etc. In order to specify 'no VAT' you need to add a tax with 0% since just leaving out the tax means that the default tax for the market is being applied. #### Importing expenses with specific taxes ~~~json { "expenses": [ { "id": "0001", "name": "Forplejning", "taxes": [ { "name": "Ingen moms", "rate": 0, "type": "vat" } ] }, { "id": "0002", "name": "Forplejning ude af huset", "taxes": [ { "name": "Kvartmoms", "rate": 0.0625, "type": "vat" } ] } ] } ~~~ #### Importing expenses with market specific taxes If you import the same expenses for several different markets, you can specify an array of taxes per market as follows: ~~~json { "expenses": [ { "id": "0001", "name": "Forplejning", "taxes": { "da": [ { "name": "Ingen moms", "rate": 0, "type": "vat" } ], "no": [ { "name": "Lav moms", "rate": 0.01, "type": "vat" } ], } }, { "id": "0002", "name": "Forplejning ude af huset", "taxes": { "da": [ { "name": "Kvartmoms", "rate": 0.0625, "type": "vat" } ], "no": [ { "name": "Halvmoms", "rate": 0.125, "type": "vat" } ], } } ] } ~~~ ### Deleting Expenses Send an HTTP DELETE request to the endpoint with a body containing a JSON object containing expense ids to delete. ~~~json { "ids": ["0001", "0002"] } ~~~ --- Source: https://developers.ka-ching.dk/incoming-orders-import-integration.md # Incoming Order Import Endpoint > How to use the Ka-ching incoming order import endpoint. ## The `Incoming Orders` Import Endpoint ``` https://{BASE_URL}/imports/incoming_orders?...&stock_location={STOCK_LOCATION} ``` All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. In addition to this the incoming orders endpoint also requires you to specify a _stock location_ when creating an incoming order. >Since the nature of incoming orders are event-like, they __cannot__ be undone by deleting them. >It is currently __not__ possible to update an incoming order after creation. Queueing one or more incoming orders for import requires you to send a __`HTTP POST`__ request with the above parameters. The `Content-Type` should be `application/json`. The body of the request must contain one or more incoming orders. You can queue as many incoming orders as you would like (at least one). Upon success a __`HTTP 200 OK`__ reponse will be given with body looking something like this: ```json { "status": "OK", "message": "Import of 1 order(s) initiated" } ``` In general the endpoint reponse will let you know if any of the incoming orders posted was not queued for import. It will also (if possible) let you know which of the actually failed. ### Minimum incoming order import body A minimum incoming order must have an `order_identifier` that must be unique across all incoming orders on the given stock location and a `basket`. A minimum basket must have a `currency` and a non-empty array of `line_items`. ~~~json { "orders": [ { "order_identifier": "AKGJTHE", "basket": { "currency": "DKK", "line_items": [ { "product_identifier": "KGJFITK", "name": "Shiny product", "quantity": 1, "price": 10 } ] } } ] } ~~~ ### Full incoming order import body ~~~json { "orders": [ { "order_identifier": "AKGJTHE", "customer": { "customer_identifier": "FKSOEKD", "name": "Jane Doe" }, "basket": { "currency": "DKK", "discounts": [ { "type": "percentage", "amount": 0.05, "name": "5% off entire purchase" } ], "line_items": [ { "product_identifier": "KGJFITK", "name": "One product", "quantity": 1, "price": 10 }, { "product_identifier": "GJKRIGJ", "name": "Other product", "quantity": 10, "price": 50, "discounts": [ { "type": "amount_per_item", "amount": 5, "name": "5 DKK off every item" } ] } ] }, "payment": { "reference": "ASD-123" } } ] } ~~~ ## Models ### Order `order_identifier` must be a string that is unique across all incoming orders for the given stock location. `basket` must be a basket, see [Basket](#basket) for more information. `customer` is an optional _Customer_, see [Customer](#customer) for more information ```json { "order_identifier": "FHGJRIL", "basket": {}, "customer": {}, "payment": (optional), "shipping": (optional) } ``` ### Basket `currency` must be the ISO4217 currency representation for the basket. See Wikipedia article on the subject for more information. `line_items` must be a non-empty array of line items. `discounts` is an optional array of discounts applied to the entire basket. See [Discount](#discount) for more information. ```json { "currency": "DKK", "line_items": [], "discounts": [] } ``` ### Customer `customer_identifier` is an optional string. `name` is an optional string. This is user facing. `phone_number` is an optional string. This is user facing. `email` is an optional string. This is user facing. ```json { "customer_identifier": "NGJFITK", "name": "Lisa Kaching", "phone_number": "+45 12 34 56 78", "email": "lisa@ka-ching.dk" } ``` ### LineItem `product_identifier` must be a string. `variant_identifier` is an optional string. `barcode` is an optional string. `image_url` is an optional URL string pointing to a png or a jpg image. Please make sure that the server adheres to the Apple App Transport Security specification `name` must be a string. This is user facing. `quantity` must be a positive integer. `price` must be a positive float. `discounts` is an optional array of discounts applied to this line item. See [Discount](#discount) for more information. ```json { "product_identifier": "GJFIKEL", "variant_identifier": "DKFJIAL", "barcode": "9876483763526", "image_url": "https://some.url/image", "name": "Your new shiny product", "quantity": 2, "price": 10, "discounts": [] } ``` ### Discount A discount can be applied to a line item and/or a basket. `name` must be a string and is shown to the user. `type` must be one of the possible [DiscountType](#discounttype) values mentioned below. `amount` must be a number, if `type` is `percentage` it must be between 0 and 1 for the corresponding percentage. Example of a discount: ```json { "name": "20% discount", "type": "percentage", "amount": 0.2 } ``` ### DiscountType Can be one of the following: - `amount` - amount off on all items of a line item or a basket - `amount_per_item` - amount off per item of a line item, not usable on a basket - `percentage` - percentage discount on line item or a basket - `new_price` - new price for all items of a line item, or a basket - `new_price_per_item` - new price per item of a line item, not usable on a basket ### Payment It's optional to specify a payment. If there's a payment object specified the order is assumed paid on arrival to Ka-ching, which means that Ka-ching will handle it as a Click & Collect order, where the customer just picks it up at the store. If no payment is specified Ka-ching will handle the order as a Reserve & Collect order where the customer will pay for the items at during pick up in the store. ``` { "reference": "" } ``` ### Shipping In case the order is paid, it can also optionally have shipping information included. This will tell the receiving store that they should ship the order to the address present in the shipping information. In other words: If payment and shipping information is present, then the order is handled as a 'Ship from Store' order. ``` { "address": { "street": "", "city": "", "postal_code": "" }, "method_id": "", "method_title": "", "method_subtitle": "", } ``` The address information is presented to the cashier handling the order. The method specifies an optional alternative delivery method. The contents may custom defined and could for instance be: ``` "method_id": "express", "method_title": "1 day Express Delivery", "method_subtitle": "Free of charge" ``` or ``` "method_id": "package_box_02315", "method_title": "Package box", "method_subtitle": "Kiosk Stoppestedet, Stationsvej 2, 8732 Hovedgård" ``` This information is also presented to the order handler. --- Source: https://developers.ka-ching.dk/outgoing-order-state-changes-import-integration.md # Outgoing Order State Change Import Endpoint > How to use the Ka-ching outgoing order state change import endpoint. ## The `Outgoing Order State Changes` Import Endpoint ``` https://{BASE_URL}/imports/outgoing_order_state_changes?... ``` All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. >Since the nature of order state changes are event-like, they __cannot__ be undone by deleting them. Queueing one or more order state changes for import requires you to send a __`HTTP POST`__ request with the above parameters. The `Content-Type` should be `application/json`. The body of the request must contain one or more orders state changes. You can queue as many state changes as you would like (at least one). Upon success a __`HTTP 200 OK`__ reponse will be given with body looking something like this: ```json { "status": "OK", "message": "Import of 1 outgoing_order_state_change value(s) initiated" } ``` In general the endpoint reponse will let you know if any of the order state changes posted was not queued for import. It will also (if possible) let you know which of the actually failed. ### Minimum outgoing order state change import body A minimum order state change must have an `order_identifier` that must be unique across all outgoing orders on the given stock location and a `stock_location` representing the shop that placed the order. Finally the new state must be present. ~~~json [ { "stock_location": "xyz", "order_identifier": "9DC72082-2E44-4A18-883E-2D19787315D4", "state": "processing" } ] ~~~ The valid states are `created`, `processing`, `ready`, `completed`, `rejected`, `cancelled`. ### Full outgoing order state change import body ~~~json [ { "stock_location": "xyz", "order_identifier": "9DC72082-2E44-4A18-883E-2D19787315D4", "state": "processing", "comment": "Shipped using FedEx", "cashier": { "identifier": "abc", "display_name": "John Appleseed" } } ] ~~~ The cashier here refers to the handler of the order. We re-use our cashier entity here as a common use case in Ka-ching is shop-to-shop orders. ## Models ### Cashier The cashier object is defined as follows: ~~~json { "display_name" : "", "full_name" : "", "identifier" : "", "image_url" : "" } ~~~ --- Source: https://developers.ka-ching.dk/facet-import-integration.md # Facets Import Endpoint > How to use the Ka-ching facets import endpoint. ## The `Facets` Import Endpoint ~~~ https://{BASE_URL}/imports/facets ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Facets` to the endpoint. Existing facets are overwritten based on their id. ####JSON Example ~~~json [ { "id" : "brand", "name" : "Brand", "type" : { "attribute" : { "id" : "brand", "type" : { "options" : { "options" : true } } } } }, { "id" : "length", "name" : "Length", "type" : { "attribute" : { "id" : "length", "type" : { "number" : { "interval_count" : 5, "max" : 10, "min" : 0 } } } } }, { "id" : "price", "name" : "Price", "type" : { "price" : { "interval_count" : 5 } } }, { "id" : "tags", "name" : { "da" : "Mærker", "en" : "Tags" }, "type" : { "tags" : { "tags" : true } } } ] ~~~ #### Models The facets are described by an array of facet definitions like the example above. The facet model looks like this ~~~json { "id": , "name": , "type": } ~~~ [L10nString](models.md#L10nString) is a localized string. There are 3 types of facet types: - attribute - price - tags The simplest one is the `tags` type. Since it only specifies that the POS app should create a facet shows all tags found in the global tags list as options, we only need to provide a presence for it. ~~~json { "tags" : { "tags" : true } } ~~~ Next up is the `price` type. Here it's possible to specify how many price intervals you'd like to have. The POS app automatically calculates the intervals from the min and max prices in the shop that's logged in to. ~~~json { "price" : { "interval_count" : "= i <= 10>" } } ~~~ Finally we have the `attribute` type ~~~json { "attribute" : { "id" : "", "type" : "" } } ~~~ In Ka-ching we have 3 different types of product attributes that you can create a facet from - options - number The simplest one is `options`. Since it just specifies that the POS app should create a facet with all the options defined in the product attribute, we just need to provide a presence ~~~json { "options" : { "options" : true } } ~~~ For the `number` attribute facet type it's possible to specify how many interval options you want in the facet, based on a `min` value and a `max`value. ~~~json { "number" : { "interval_count" : "= i <= 10>", "max" : "", "min" : "" } } ~~~ ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/facets?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Facets` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Facet` ids. ~~~json [ "length", "tags" ] ~~~ --- Source: https://developers.ka-ching.dk/folders-import-integration.md # Folders Import Endpoint > How to use the Ka-ching folders import endpoint. ## The `Folders` Import Endpoint ~~~ https://{BASE_URL}/imports/folders ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. The folder hierarchy is just a single value containing the entire hierarchy. This means that any post to this endpoint will overwrite the current folder hierarchy with the newly posted one. ~~~json [ { "filter": { "tag": "usa" }, "children": [ { "filter": { "tag": "californien" }, "children": [ { "filter": { "tag": "anderson_valley" } }, { "filter": { "tag": "carneros" } } ] } ] } ] ~~~ The folders hierarchy is described by an array of filters. Along with each filter you may supply arrays of children of the same structure (a filter and an optional array of children). The filters can currently specify tags that much be matched for products to be included in the folder. This may be expanded upon in the future. ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/folders?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Folders` Sincere there only exists one hierarchy of `folders`, sendin an HTTP DELETE request to the endpoint without any contents will delete the folders. --- Source: https://developers.ka-ching.dk/loyalty-point-events.md # Loyalty point events import endpoint > How to use the Ka-ching loyalty point events import endpoint. ## Loyalty point events import endpoint ~~~ https://{BASE_URL}/imports/loyalty_point_events ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. You may post an object containing a JSON array of `Loyalty point events` to the endpoint. Based on the event types, the loyalty point balance will be overwritten or adjusted. ####JSON Example ```json { "events": [ { "currency_code": "DKK", "customer_id": "226DBB0D-E7AC-4901-8D56-57C94F84F7CC", "source": { "type": "external", "externalReference": "initial_points" }, "timestamp": "2023-01-16T15:28:39", "type": "overwrite", "overwrite": 10 }, { "currency_code": "DKK", "customer_id": "ABC_DEF", "source": { "type": "external", "externalReference": "id_of_event_in_your_system" }, "timestamp": "2023-01-16T14:28", "type": "earned", "adjustment": 15 } ] } ``` --- Source: https://developers.ka-ching.dk/product-assets-import-integration.md # Product Assets Import Endpoint > How to use the Ka-ching product assets import endpoint. ## The `Product Assets` Import Endpoint ~~~ https://{BASE_URL}/imports/product_assets ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. E.g.: ~~~ https://{BASE_URL}/imports/product_assets ~~~ For further clarification of the `Market` concept, please read the [Vocabulary](./vocabulary.md). You may post any amount of `Product Assets` to the endpoint. Existing product assets are overwritten based on their id. The order defined in the JSON is the order that is used in the presentation in the POS app. The below example shows all currently supported mime types in Ka-ching. Image assets are shown both in POS and TAS mode in the app. Documents and Video links are only shown in TAS mode in the app. Please note is that the YouTube and Vimeo links are socalled "embed" links. The model/usdz type allows you to show augmented reality models of your product in the app. Image assets are downloaded to Ka-ching storage if an image import is configured on the account. Video links are embedded into the product details page and the pdf documents are fetched via the URL reference when shown or shared with the customer. ####JSON Example ```json { "assets": { "ipad-pro-9-7": [ { "mime_type": "image/jpg", "name": "iPad Pro 9.7 Landscape", // L10nString "url": "https://example.com/ipad-pro-9-7.jpg" }, { "mime_type": "image/jpeg", "name": "iPad Pro 9.7 Portrait", "url": "https://example.com/ipad-pro-9-7-2.jpeg" }, { "mime_type": "image/png", "name": "iPad Pro 9.7 Back", "url": "https://example.com/ipad-pro-9-7-3.png" }, { "mime_type": "video/youtube", "name": "iPad Pro 9.7 Review", "url": "https://www.youtube.com/embed/pi3k3ZPiK7M" }, { "mime_type": "video/vimeo", "name": "iPad Pro 9.7 Video 2", "url": "https://player.vimeo.com/video/286871958" }, { "mime_type": "document/pdf", "name": "iPad Pro 9.7 Specs", "url": "https://example.com/ipad-pro-9-7.pdf" }, { "mime_type": "model/vnd.usdz+zip", "name": "Cosmonaut", "url": "https://developer.apple.com/augmented-reality/quick-look/models/cosmonaut/CosmonautSuit_en.reality" } ] } } ``` [L10nString](models.md#l10nstring) is a localized string. ### Deleting `Product Assets` Send an HTTP DELETE request to the endpoint with a ids query parameter with a comma separated list of product ids where you want to remove all assets ~~~ [ https://{BASE_URL}/imports/product_assets?ids=ipad-pro-9-7,ipad-mini,ipad-2 ] ~~~ --- Source: https://developers.ka-ching.dk/attributes-import-integration.md # Product Attributes Import Endpoint > How to use the Ka-ching product attributes import endpoint. ## The `Product Attributes` Import Endpoint ~~~ https://{BASE_URL}/imports/attributes ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Product Attributes` to the endpoint. Existing attributes are overwritten based on their id. #### JSON Example ~~~json [ { "id": "country", "name": { "da": "Land", "en": "Country" }, "type": { "options": { "denmark": { "id": "denmark", "name": { "da": "Danmark", "en": "Denmark" } }, "france": { "id": "france", "name": { "da": "Frankrig", "en": "France" } } } } }, { "id" : "length", "name" : "Length (meters)", "type" : { "number" : { "scale" : 0, "suffix" : " m" } } }, { "id" : "note", "name" : "Note", "type" : { "text": { "text": true } } }, ... ] ~~~ ### Models The attribute model looks like this ~~~json { "id": "", "name": "", "type": "" } ~~~ [L10nString](models.md#L10nString) is a localized string. There are 3 types of attributes - options - number - text The simplest is the `text` type. Since we just need to specify that the attribute is a free text attribute, we just need a presence in the json. ~~~json { "text": { "text": true } } ~~~ For the `number` type you need to specify a decimal scale and a suffix that can be used in presentation. The suffix can be an empty string if you don't need any. ~~~json { "number" : { "scale" : "", "suffix" : "" } } ~~~ The `options` attribute type specifies a set of text options that a product can use. ~~~json { "options": { "denmark": { "id": "", "name": "" }, "france": { "id": "", "name": "" } } } ~~~ ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/attributes?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Product Attributes` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Product Attribute` ids. ~~~json [ "country", "grape" ] ~~~ --- Source: https://developers.ka-ching.dk/attribute_groups-import-integration.md # Attribute groups Import Endpoint > How to use the Ka-ching attribute groups import endpoint. ## The `Attribute groups` Import Endpoint ~~~ https://{BASE_URL}/imports/attribute_groups ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Attribute groups` to the endpoint. Existing attribute groups are overwritten based on their id. #### JSON Example ~~~json [ { "id": "geography", "name": { "da": "Geografi", "en": "Geography" }, "attributes": ["country", "area", "region"] }, { "id" : "further_details", "name" : "Further details", "initially_collapsed": true, "attributes": ["size", "weight", "color"] }, { "id" : "hardwarespecs", "name" : "Specs" "attributes": ["ram", "cpu", "capacity"] }, ... ] ~~~ ### Models The attribute model looks like this ~~~json { "id": "", "name": "", "initially_collapsed": "", "attributes": [] } ~~~ [L10nString](models.md#L10nString) is a localized string. The `initially_collapsed` parameter allows you to control if the UI should be collapsed by default. This may be appropriate for groups containing multiple attributes with potentially large bodies of text. ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/attribute_groups?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Attribute groups` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Attribute Group` ids. ~~~json [ "geography", "further_details" ] ~~~ --- Source: https://developers.ka-ching.dk/product-groups-import-integration.md # Product Groups Import Endpoint > How to use the Ka-ching product groups import endpoint. ## The `Product Groups` Import Endpoint ~~~ https://{BASE_URL}/imports/product_groups ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Product Groups` to the endpoint. Existing product groups are overwritten based on their id. ~~~json [ { "group": "dairy", "name": { "da": "Mælkeprodukter", "en": "Dairy" } }, { "group": "misc", "name": "Misc." }, ... ] ~~~ The name is an `L10nString` and may thus be supplied with or without localizations. ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/product_groups?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Product Groups` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Product Group` ids. ~~~json [ "dairy", "misc" ] ~~~ --- Source: https://developers.ka-ching.dk/product-recommendations-import-integration.md # Product Recommendations Import Endpoint > How to use the Ka-ching product recommendations import endpoint. ## The `Product Recommendations` Import Endpoint ~~~ https://{BASE_URL}/imports/recommendations?recommendation_id=[RECOMMENDATION ID] ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. For `Product Recommendations`, you can define multiple integrations where each integration corresponds to a specific kind of recommendation. For instance you could model both `Upsale` recommendations and `Other customers also bought` recommendations. Note that these kinds are just visual groupings with corresponding labels, so you are free to create any kind of recommendation lists you wish. For instance you could have a `Curated`, hand made recommendation kind as well. So once the integration is configured, you can `POST` JSON data to the endpoint. ~~~json { "products": [ { "product_id": "0001", "recommendations": [ "0002", "0010", "1234" ] }, { "product_id": "0002", "recommendations": [ "0001", "0010", "1235" ] }, ... ] } ~~~ So if the above data is `POST`ed to the `curated` recommendation id, then when you show product details for the product with id "0001", you will see the curated recommendations for "0002", "0010" and "1234". Any products that don't exist at the time of presentation will be filtered away. ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/recommendations?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Product Recommendations` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Discount Campaign` ids. Note that you will still need the `recommendation_id` query parameter to specify the recommendation category. ~~~json [ "0001", "0003" ] ~~~ --- Source: https://developers.ka-ching.dk/product-rules-import-integration.md # Product Rules Import Endpoint > How to use the Ka-ching product rules import endpoint. ## The `Product Rules` Import Endpoint ~~~ https://{BASE_URL}/imports/product_rules ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. ### Advanced Product Rules Import Parameters When importing `Product Rules` you can additionally specify which `Markets` you wish to import for. The default market is `dk` (Denmark) - signifying all `Shops` in the Danish market. The default can be overridden by the query parameter `markets`. The value is comma separated lists of markets. E.g.: ~~~ https://{BASE_URL}/imports/product_rules?markets=dk,se,no&... ~~~ For further clarification of the `Market` concept, please read the [Vocabulary](./vocabulary.md). You may post any amount of `Product Rules` to the endpoint. Existing product rules are overwritten based on their id. ####JSON Example ~~~json { "product_rules": [ { "id": "pant-a", "type": "container_deposit", "name": "Pant A", "display_name": "Pant", "tag": "pant-a", "product_group": "pant-a", "price": 1 }, { "id": "pant-b", "type": "container_deposit", "name": "Pant B", "display_name": { "da": "Pant" }, "tag": "pant-b", "product_group": "pant-b", "price": { "dk": 1.5 } } ] } ~~~ #### Models At the moment there's only one type of product rules: `container_deposit` which is used to model POS behavior for products with container deposits, for example when a can of Coca Cola is sold in a Danish store, the customer pays a fixed container deposit amount (the amount depends on the container) which is then returned to the customer upon delivering the can back to a designated drop off point for recycling. The `container_deposit` rule basically specifies minimal product information that should added to the basket when a product with a specific tag is added to the basket. ~~~json { { "id": "", "type": "", "name": "", "display_name": "", "tag": "", "product_group": "", "price": "" } } ~~~ [L10nString](models.md#l10nstring) is a localized string. [MarketPrice](models.md#market-price) is a price specification for each market. ### Deleting `Product Rules` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Product Rule` ids. ~~~json [ "pant-a", "pant-b" ] ~~~ --- Source: https://developers.ka-ching.dk/products-import-integration.md # Products Import Endpoint > How to use the Ka-ching products import endpoint. ## The `Product` Import Endpoint ~~~ https://{BASE_URL}/imports/products ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. ### Advanced Product Import Parameters When importing `Products` you can additionally specify which `Markets` you wish to import for. The default market is `dk` (Denmark) - signifying all `Shops` in the Danish market. The default can be overridden by the query parameter `markets`. The value is comma separated lists of markets. E.g.: ~~~ https://{BASE_URL}/imports/products?markets=dk,se,no&... ~~~ For further clarification of the `Market` concept, please read the [Vocabulary](./vocabulary.md). There are two further query parameters that can be used when importing products. These are related to [partial product import](#partial-product-import). ### Importing Products Send a `POST` request to the endpoint with the parameters specified above. The body of the `POST` request must be a JSON object with the following layout: ~~~json { "products": [ [product A], [product B], ... ] } ~~~ The definition of the `Product` model can be found in the [Models](./models.md) document. The minimal data required for a regular product is an `id`, a `retail_price` and a `name`: ~~~json { "products": [ { "id": "0001", "name": "Coffee", "retail_price": 25 }, { "id": "0002", "name": "Tea", "retail_price": 20 } ] } ~~~ > *NOTE* > > When products are imported into the Ka-ching system, the `id` will be used as a unique key. > > One limitation in the database we are using (the Firebase real-time database) is that not all characters are valid to use in keys. > > This means that the following list of characters may not be used in the "id" field of a product: `.`, `/`, `#`, `$`, `*`, `[` and `]` Other basic properties of products include: * `description` * `short_description` * `image_url` * `barcode` The `description` will be shown when displaying product details. The `image_url` is a URL for an image that will be shown in the Product Grid, basket and Product Details. The `barcode` could be either an `EAN` number, a `SKU`, an `ISBN` number or any other means of identifying a product. The only thing that matters for the POS is that this is the bar code that you would scan in the shop in order to add the product to the basket. ### Advanced product models #### Importing products with prices for different markets All price information on a product will be interpreted to be in the currency of the market in which they are imported. If you are importing for multiple markets, then you naturally need to be able to specify prices for each of these markets. This can be done by supplying the pricing information as objects keyed by the market. Here is an example of importing a few products in the markets: Denmark, Norway and Sweden: ~~~json { "products": [ { "id": "0001", "name": "Coffee", "retail_price": { "dk": 25, "no": 35, "se": 30 } }, { "id": "000"", "name": "Tea", "retail_price": { "dk": 20, "no": 32, "se": 28 } }, ... ] } ~~~ #### Localizing product names and other details Throughout the Ka-ching system, data can be localized into multiple languages. This could for instance be used to display a chinese version of product names on a secondary, customer facing display. The way this is modelled is that all string data can either be a simple, non-localized string -or- an object containing localizations for various language codes. Localizing the product name could for instance be done as follows: ~~~json { "products": [ { "id": "0001", "name": { "da": "Kaffe", "en": "Coffee", "nb": "Kaffe" }, "retail_price": 25 } ] } ~~~ #### Variable priced products The Ka-ching system allows for `variable priced products`. These are products that do not have an explicit retail price, but rather need the product price to be entered when the product is added to the basket on the POS. `Variable priced products` can be created simply by not specifying a `retail price`. ~~~json { "products": [ { "id": "0001", "name": "Variable priced coffee" } ] } ~~~ #### Unit priced products The Ka-ching system allows for `unit priced products`. These are products that do not have an explicit retail price, but rather need the product price by weight, length, area or volume - where the unit countis entered when the product is added to the basket on the POS. `Unit priced products` can be created simply by not specifying a `retail price`, but specifying a `unit pricing` entry instead. ~~~json { "products": [ { "id": "0001", "name": "Candy", "unit_pricing": { "unit": "mass/g", "multiplicity": 100 "retail_price_per_unit": 7.5, } } ] } ~~~ The (optional) `multiplicity` above means that the unit price is per 100 * of the unit. In the example above, the candy costs 7.50 per 100 grams. The available units are: * `mass/g` * `mass/kg` * `volume/l` * `volume/dl` * `volume/cl` * `volume/ml` * `length/m` * `length/cm` * `length/mm` * `area/m2` * `area/cm2` * `area/mm2` You can also speciy an optional `cost_price_per_unit`, which will allow unit priced products to also count the costs. Examples: ~~~json { "products": [ { "id": "0001", "name": "Candy", "unit_pricing": { "unit": "mass/kg", "retail_price_per_unit": 100 } } ] } ~~~ Will show the product: `Candy` with the price description: `100,00 per kg`. Adding 2.5 `kg` of candy will result in the following line item: Candy (2.5 kg) - price: 250 You can also use multiplicities with decimal values - if appropriate for your use case. ~~~json { "products": [ { "id": "0002", "name": "Hummus", "unit_pricing": { "unit": "volume/dl", "retail_price_per_unit": 15, "cost_price_per_unit": 5, "multiplicity": 4.5 } } ] } ~~~ Will show the product: `Hummus` with the price description: `15,00 per 4.5 dl`. Adding 2 `dl` of hummus will result in the following line item: Hummus (2 dl) - price: 6.67 The cost price will be 2.22 (2 * 5 / 4.5) #### Taxes The market that your shop operates in defines a set of one or more default taxes. This means that in countries like Denmark, you never need to specify other taxes directly on the product. But in special situations you have the option to override the set of taxes for individual products. This can be done as follows: ~~~json { "products": [ { "id": "0001", "name": "Coffee", "retail_price": 25, "taxes": [ { "id": "coffee_tax", "name": "Coffee tax", "rate": 0.1, "type": "vat" } ] } ] } ~~~ Taxes can be either `vat` or `sales_tax`. This determines how the base price is calculated from the retail price. See the [Vocabulary](./vocabulary.md) for more on this. Notice that the taxes are specified as an array. This is because in some countries, multiple taxes can be in effect at the same time. For instance you could imagine taxation to be split into two rates defining 'city tax' and 'state tax'. Again the [Vocabulary](./vocabulary.md) has more details on this concept. #### Creating simple, fixed `sale` discounts Our `Discount Campaign` engine can be used to model powerful discount concepts in a very expressive manner, but sometimes this complexity is unneeded. So if a `product` is currently on sale, this `sale_price` can be added directly to the `product`. When a `product` with a `sale_price` is added to the basket, a `new price discount` is automatically applied to the item. ~~~json { "products": [ { "id": "0001", "name": "Coffee on sale", "retail_price": 25, "sale_price": 15 } ] } ~~~ #### Unlocking `Contribution Ratio` functionality in the POS In the Ka-ching Back Office, you can configure a desired `Contribution Ratio` for your sales. In order for this to work, you need to supply a cost price for all products. When a desired `Contribution Ratio` is configured, the `Action Button` in the bottom right of the POS will show a status indicating wether the `Contribution Ratio` is met (green) or not (orange) or if money are actually lost by performing the sale (red). This could be the case if too much of a discount is being applied to the sale. Note that retail prices in Ka-ching always represent the price that you would print on a price-tag (meaning including VAT, but excluding american style sales tax), but cost prices are always represented without any taxes. ~~~json { "products": [ { "id": "0001", "name": "T-shirt", "retail_price": 150, "cost_price": 40 } ] } ~~~ #### Purchase types The concept of purchase types exists to let pricing and tax details of a product vary with an aspect of the sales situation. Most often this would be used to model varying prices and taxes for 'eat in' and 'dine out' sales. For instance taxation in many states in the US varies exactly based on this choice. Currently the setup for the available purchase types needs to be performed by Ka-ching, but when the desired purchase types are added, you may specify price or tax variations for each purchase type in the manner shown below. Note that you can default to the base pricing and taxing, so if you are modelling 'eat in' vs. 'dine out', you only need to use once explicit purchase type. For the example below, imagine that we have defined the purchase type 'dine_out', and that the absence of 'dine_out' means 'eating in'. ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25, "retail_price_map": { "dine_out": 20 } } ] } ~~~ Similarly you can vary taxes by having both a 'taxes' and a 'taxes_map': ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25, "taxes": [ { "id": "coffee_tax", "name": "Coffee tax", "rate": 0.1, "type": "vat" } ], "taxes_map": { "dine_out": [ { "id": "coffee_tax", "name": "Coffee tax", "rate": 0.07, "type": "vat" } ] } } ] } ~~~ #### Product Groups `Product Groups` can be defined in the Ka-ching Back Office and are used to group sold goods on the X- and Z-reports. A `Product Group` is defined as an identifier and a display name. By adding the product group identifier to a product on import, this will make the grouping appear on the reports. A `Product` can belong to 1 or 0 `Product Groups` ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25, "product_group": "deserts" } ] } ~~~ More functionality may be added around the `Product Group` concept in the future. #### Tags `Tags` can be defined in the Ka-ching Back Office and are informal identifiers that can be added to a `Product`. A `Tag` is defined as an identifier and a display name. In the Ka-ching POS, the tags can be used to create the tab bar and a folder hierarchy. Tags can also be used in conjunction with Discount Campaigns as a means of triggering discounts in case a certain number of products bearing the same tag are in the shopping basket. Any number og tags can be added to one `Product`. ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25, "tags": { "deserts": true, "food": true, "popular": true } } ] } ~~~ More functionality may be added around the `Tag` concept in the future. #### Attributes `Attributes` can be defined in the Ka-ching Back Office. They are similar to tags, but allow you to define stronger semantics between values. Consider the tags `merlot`, `cabernet`, `denmark` and `france`. While all of these may be used for filtering purposes, there is nothing that binds `merlot` and `cabernet` to each other - and the same for `denmark` and `france`. One product could easily contain all four tags. Instead you may wish to define a more formal relationship where you let the system know that `merlot` and `cabernet` are both types of `grapes` - and `denmark` and `france` are both `countries`. From Ka-ching release 11 you may now specify an `Attribute` called `Grape` that can list all of the available grapes - and similarly for `Country`. For each of these two attributes, a product can only have a single value. From Ka-ching release 12 we've introduced two new attribute types, `text` and `number`, where the syntax is almost the same as for option references described above. Take a look at [Attributes import](./attributes-import-integration.md) for details on how to import definitions for all possible attribute types in Ka-ching. The value for a `number` attribute is just the number. The value for a `text` attribute is localizable string wrapped in an object keyed by `text`. Take a look below for an example. With these added semantics, each attribute can now be represented in Ka-ching POS as a search facet. Any number of attributes can be added to one `Product`. ~~~json { "products": [ { "id": "0001", "name": "2016, Grand Sud", "retail_price": 305, "attributes": { "grape": "merlot", "country": "france", "length": 1, "misc": { "text": { "en": "Store up to 10 years" } } } } ] } ~~~ More functionality may be added around the `Attribute` concept in the future. For instance, attributes can only be 'option sets' today. In the future they might also embrace numerical values and other data types. #### Product Variants In the Ka-ching system, a product can either be a stand-alone, sellable entity, but it can also be used to model the concept of `Product Variants`. If, for instance, a `product` can be sold in a `big` and a `small` variant, then this can be modelled as a `product` that has two `variants`. This basically means that the product itself is not a sellable entity (you cannot sell this product without knowing whether you are selling the big or the small variant), but each variant becomes a sellable entity instead. The variant can have it's own `name`, `barcode`, `image_url` and can also specify price variations. If it does not specify a `retail_price`, the `retail_price` of the `product` will be used. In the POS, tapping a product with variants will display the variant selector. Variants are displayed in a list unless `dimensions` are also specified (read more about dimensions below). If all variants of a product have the same price, this price will be displayed in the Product Grid. If the prices of the variants vary, then the prices will only be shown when the product is tapped. ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25, "variants": [ { "id": "small", "name": "Small" }, { "id": "big", "name": "Big", "retail_price": 50 } ] } ] } ~~~ #### Dimensions and dimension values Imagine the situation where you sell a shirt in sizes: S, M and L and colors: red, yellow and blue. This basically gives rise to 9 variants, so one way of modelling this would just be to include 9 variants with the names "S, red", "S, yellow", etc., etc. This would of course give a list of 9 variants to choose from in the UI, but conceptually, the cashier just needs to make one choice of the size and one choice for the color. These two choices will then uniquely identify one of the 9 variants. In the Ka-ching system we model this by a concept called `dimensions`. A `product` can contain any number of `dimensions` - and each of these `dimensions` can define a number of available `dimension values`. In the example above we could define the dimension: `size` with the values `S`, `M` and `L` and the dimension: `color` with the values `red`, `yellow` and `blue`. By defining these, and adding a dimension value for each dimension to each of the variants, the POS can now display a much nicer UI - namely a list of dimensions, each having a number of possible values to select from. In order to make the experience for the cashier even nicer, the dimension values can define both a color and also an image. Example of a product with variants and dimensions: ~~~json { "products": [ { "id": "0001", "name": "T-shirt", "retail_price": 150, "dimensions": [ { "id": "size", "name": "Size", "values": [ { "id": "s", "name": "S" }, { "id": "l", "name": "L" } ] }, { "id": "color", "name": "Color", "values": [ { "id": "red", "name": "Red", "color": "#FF0000", "image_url": "https://url.for/red_cloth.image" }, { "id": "blue", "name": "Blue", "color": "#0000FF", "image_url": "https://url.for/blue_cloth.image" } ] } ] "variants": [ { "id": "a", "dimension_values": { "color": "red", "size": "s" } }, { "id": "b", "dimension_values": { "color": "red", "size": "l" } }, { "id": "c", "retail_price": 200, "dimension_values": { "color": "blue", "size": "s" } }, { "id": "d", "retail_price": 200, "dimension_values": { "color": "blue", "size": "l" } } ] } ] } ~~~ Notice how the blue t-shirts in this example are more expensive than the red ones. #### Product quantity bundles In some cases, the most natural quantity of a product to sell is not one. If so, you can define 'quantity bundles' for your product. Example of a product with quantity bundles: ~~~json { "products": [ { "id": "0001", "name": "Domaine d'Angayrac Cuvée Prestige", "retail_price": 150, "bundles": [ { "id": "box", "name": "Kasse", "quantity": 6, "is_default": true }, { "id": "pallet", "name": "Palle", "quantity": 90 } ] } ] } ~~~ In POS, the default quantum will be used throughout when adding products or changing the quantity. With the product above, tapping the product will add 6 to the basket. Tapping "+" on the quantity picker, will add 6 more. Under Product Details you get a picker similar to the dimension picker that allows you to select the non-default quantums too. Note that the quantum '1' will always implicitly be added even if it's not in the defined list, as an escape hatch to allow adding a single product. If no products have the 'is_default' flag set, then '1' will be the default. Since the dimension picker UI is used, each quantum can also include a color and an image url - just like dimension values: ### Importing products to specific shops If the imported products should not be shared between all shops, you can specify a list of shop identifiers as follows: ~~~json { "products": [ { "id": "0001", "name": "Pie", "retail_price": 25 } ], "shops": { "shop_a": true, "shop_b": true, "shop_c": true } } ~~~ ~~~json { "products": [ { "id": "0001", "name": "Domaine d'Angayrac Cuvée Prestige", "retail_price": 150, "bundles": [ { "id": "box", "name": "Kasse", "quantity": 6, "is_default": true, "image_url": "https://url.to.a.box.image.jpg" }, { "id": "pallet", "name": "Palle", "quantity": 90, "color": "#328139" } ] } ] } ~~~ You may optionally add a name property to be shown in the basket and on the receipt for a nicer layout: ~~~json { "products": [ { "id": "0001", "name": "Domaine d'Angayrac Cuvée Prestige", "retail_price": 150, "bundles": [ { "id": "box", "name": "Kasse", "name_per_quantity": "kasser af", "quantity": 6, "is_default": true, "image_url": "https://url.to.a.box.image.jpg" }, { "id": "pallet", "name": "Palle", "name_per_quantity": "paller af", "quantity": 90, "color": "#328139" } ] } ] } ~~~ Without the 'name_per_quantity', adding two boxes will show: Quantity: 12, Domaine d'Angayrac Cuvée Prestige (2 x Kasse) With the 'name_per_quantity' set to 'kasser af', the same will show: Quantity: 12, Domaine d'Angayrac Cuvée Prestige (2 kasser af 6) ### Deleting Products Send an HTTP DELETE request to the endpoint with a body containing a JSON object containing product ids to delete. ~~~json { "ids": ["0001", "0002"] } ~~~ In order to delete shop specific products you may additionally specify an array of shop ids in the `DELETE` request: ~~~json { "ids": ["0001", "0002"], "shops": ["xxx", "yyy"] } ~~~ ### Partial product import In some situations there's not a single source of truth that defines all the properties for a product. In such a situation it can be relevant with multiple product imports that each deal with specific aspects of the product. In order to support this use case, we can add the query parameter `partial=true` to the product import. This means that the product data in the import will be merged with the existing product (if any). The merge is done at leaf value level, meaning that any properties not specified will be left untouched. If one import is marked as partial, and another is a regular import, then it follows that the latter will still override the products entirely. This is of course not desirable, so you could mark both imports as partial. This, however, has another complication, since partial imports are only additive. This means that it's not easy to delete values, like for instance removing a variant of a product. In order to solve this situation, there's a variation of the partial import that first filters the existing product by specified keys before merging. This means that this import will be overriding all values just like regular imports, except for a list of specific keys to ignore. These properties can be specified on the import using a sequence of `ignore` query parameters. For instance: `&ignore=cost_price&ignore=retail_price`. Example: Say that you have a product import (a) defining all values for a product except for the `retail_price` and the `cost_price`. And then another product import (b) that only defines `retail_price` and `cost_price`. Import `a` would use query parameters `&ignore=cost_price&ignore=retail_price` and send data like: ``` { "products": [ { "id": "AmeliaShellJacketSS20", "variants": [ { "id": "dark_grey-122_128", "barcode": "A89119", "dimension_values": { "color": "dark_grey", "size": "122_128" } }, { "id": "dark_purple-122_128", "barcode": "A89113", "dimension_values": { "color": "dark_purple", "size": "122_128" } }, { "id": "dark_grey-134_140", "barcode": "A89120", "dimension_values": { "color": "dark_grey", "size": "134_140" } } ] } ] } ``` Import `b` would use query parameter `&partial=true` and send data like: ``` { "products": [ { "id": "AmeliaShellJacketSS20", "variants": [ { "id": "dark_grey-122_128", "retail_price": 120, "cost_price": 80 }, { "id": "dark_purple-122_128", "retail_price": 125, "cost_price": 82 }, { "id": "dark_grey-134_140", "retail_price": 150, "cost_price": 90 } ] } ] } ``` And the final merged product would contain the values from both sources. --- Source: https://developers.ka-ching.dk/recommendation-categories-import-integration.md # Recommendation Categories Import Endpoint > How to use the Ka-ching recommendation categories import endpoint. ## The `Recommendation Categories` Import Endpoint ~~~ https://{BASE_URL}/imports/recommendation_categories ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Recommendation Categories` to the endpoint. Existing categories are overwritten based on their id. ~~~json [ { "id": "similar", "name": "Similar" }, { "id": "also_bought", "name": { "en": "Other customers also bought", "da": "Andre kunder købte også" } } ] ~~~ ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/recommendation_categories?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Recommendation Categories` Send an __HTTP DELETE__ request to the endpoint with a body containing a JSON array of `Recommendation Category` ids. ~~~json [ "similar", "upsale" ] ~~~ --- Source: https://developers.ka-ching.dk/stock-import-integration.md # Stock Import Endpoint > How to use the Ka-ching stock import endpoint. ## The `Stock` Import Endpoint ~~~ https://{BASE_URL}/imports/stock ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. The stock import endpoint is intended for the situation where the stock count needs to be overridden for one or more products. This can be necessary if the singular truth is placed in a third party system. You can, however, supply an additional query parameter: `adjustment=true`. This will cause the imported data to be interpreted as stock adjustments instead of as new values. Each stock count imported through the stock endpoint will, if successfully imported, become a stock event of the type **external_reset** - or in case `adjustment=true` is used, it will be **external_adjustment**. ### Importing stock counts The body of the `POST` request must be a JSON object with the following layout: Without variants: ~~~json { "stock_location_id": { "product1": 7, "product2": 7 } } ~~~ With variants: ~~~json { "stock_location_id": { "product1": 7, "product2": 7, "product3": { "variant1": 7, "variant2": 7 } } } ~~~ It is possible to import products that do not (yet) exist at a given stock location. It is __not__ possible to import stock numbers to a non existing stock location. Upon success a __HTTP 200 OK__ reponse will be given with body looking something like this: ```json { "status": "OK", "message": "Import of 2 stock value(s) initiated" } ``` The number of values that has been parsed from the request will be noted in the message (as seen in the example above). ### Deleting Stock Send an HTTP DELETE request to the endpoint with a body similar to stock registration. Since the format is shared between the DELETE and the POST requests, this means that there must be a stock count value. Note that this value is ignored as the purpose of the DELETE request is to remove the stock information for the product in question. Without variants: ~~~json { "stock_location_id": { "product1": 0, "product2": 0 } } ~~~ With variants: ~~~json { "stock_location_id": { "product1": 0, "product2": 0, "product3": { "variant1": 0, "variant2": 0 } } } ~~~ Please not the difference between setting the stock to 0 (sending the data above in a POST request) and removing the stock value (sending the data above in a DELETE request). The former means: This is a product that we sell, but currently the stock count is 0. The latter means: This is no longer a product that we keep in stock - and thus it will no longer be present when performing stock counts, etc. --- Source: https://developers.ka-ching.dk/tabs-import-integration.md # Tabs Import Endpoint > How to use the Ka-ching tabs import endpoint. ## The `Tabs` Import Endpoint ~~~ https://{BASE_URL}/imports/tabs ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. The tabs list is just a single value containing an array of filters. This means that any post to this endpoint will overwrite the current tabs with the newly posted one. ~~~json [ { "filter": { "tag": "new" } }, { "filter": { "tag": "popular" } }, { "filter": { "tag": "recommended" } }, { "filter": { "tag": "offers" } } ] ~~~ The tabs is described by an array of filters. The filters can currently specify tags that much be matched for products to be included on the selected tab. This may be expanded upon in the future. ### Shared Integration Queue Parameters For all integration queue import endpoints, you need to specify `account`, `integration` and `apikey`. Please read the [Import Queues](#import-queues) below for details about these parameters. ~~~ https://{BASE_URL}/imports/tabs?account=[ACCOUNT ID]&integration=[INTEGRATION QUEUE ID]&apikey=[INTEGRATION QUEUE API KEY] ~~~ ### Deleting `Tabs` Since there only exists one array of `tabs`, sending an HTTP DELETE request to the endpoint without any contents will delete the tabs. --- Source: https://developers.ka-ching.dk/tags-import-integration.md # Tags Import Endpoint > How to use the Ka-ching tags import endpoint. ## The `Tags` Import Endpoint ~~~ https://{BASE_URL}/imports/tags ~~~ All import integration endpoints use the same authentication parameters, please see [Authentication](import-queues-authentication.md) page for more details. Like the `Product` Import, this endpoint uses Import Queues to handle all imported data. You may post any amount of `Tags` to the endpoint. Existing tags are overwritten based on their id. ~~~json [ { "tag": "popular", "name": { "da": "Populære", "en": "Popular" } }, { "tag": "new", "name": { "da": "Nye varer", "en": "New products" } }, ... ] ~~~ The name is an `L10nString` and may thus be supplied with or without localizations. ### Deleting `Tags` Send an HTTP DELETE request to the endpoint with a body containing a JSON array of `Tag` ids. ~~~json [ "new", "popular" ] ~~~ --- Source: https://developers.ka-ching.dk/export-integrations.md > How to use the Ka-ching export integrations to export data to your own systems. # Export integrations This document describes the structure for our generic export integration mechanisms for sales, register close statements, product edit events, newsletter signups and future exportable entities. The data types that can currently be exported are: * Checkouts * Sales * Register Close Statements * Products Edit Events * Newsletter Signups * Stock Events * Incoming Order State Change Events * Outgoing Orders All exports happen through the same internal mechanism, namely the Export Queues. ## Export Queues Overview For each event that can be exported, the Ka-ching system can be configured to place the event entity in any number of queues. For instance, for each sale, the system can be configured to place the sale in two different export queues. The export happens in three steps: 1. Trigger 2. Transformation 3. Delivery ### Trigger Each queue can be configured to trigger an export to an external system in different ways: * Real time * By cron job If the queue is configured to trigger `real time`, then an export will be started for each entity in the queue. If the `cron job` trigger is used, then the export will be performed in batches either daily or hourly based on the trigger configuration. ### Transformation When an export is performed, the data in the queue is first passed through a `transformation` step. Here you can configure an optional transformation of the exported data. Note that the expression forms in this step do have some limitations, so it should be considered to export the full data as it is and transform it at the receiving system. ### Delivery When the data is transformed it is passed to the `delivery` step. Here a configuration can specify to deliver to a `web hook` (an `https` endpoint), send an email, push to an FTP server and more. ### Success / failure When items in the queue are processed, they will end up in either a failure log or a success log. In case of failures, an error message from the delivery will be included, in order to make debugging integrations easier. ## Trigger Types ### Real time The real time trigger takes a single element from the queue each time an element is added to the queue. The logical implication is that this trigger type will likely have a larger performance impact on the receiving end - since a request is made for each and every element. ### Cron This trigger can be configured to run once per hour or once per day and thus aggregates all the elements in the queue and process them in one go. ## Built-in transforms ### Identity No transform is applied, and the JSON model will be our internal model as described in the [Models](./models.md) documentation. ### Mustache / handlebars Mustache is a generic template language that can be used to output all sorts of data, like for instance JSON or HTML. Here is a link to the official Mustache template documentation [https://mustache.github.io](https://mustache.github.io). The handlebars export is similar to mustache, but is a bit more flexible. The documentation can be found here: [http://handlebarsjs.com](http://handlebarsjs.com). ### CSV The CSV export is quite elaborate and can be configured to provide a huge variety of content. Line items can be aggregated together and grouped by things like VAT. Payment transactions can be grouped together by type and currency. ### Simple JSON The Simple JSON transform lets you describe a simple, flat JSON output structure. ## Built-in delivery methods ### Email Configure this in order to send the transformed data as an attachment to a number of email recipients. ### Web hook The web hook integration is a simple and easy way for you to obtain real time updates of sales from the Ka-ching system without the need to build your own integration framework. Each sale can be transformed or left as is and be `POST`’ed to a URL. This would most likely require some kind of credentials or token to be added as part of the URL or set as an auth header when the `POST` is performed. ## Retry mechanism We've built a retry mechanism that kicks in under certain circumstances to avoid manual handling of failed exports that have a chance to succeed if tried again a bit later. We will attempt an export up 5 times total (including the initial attempt) if: - The trigger is realtime *and* - The delivery is web hook *and* - The response code is 503, 522 or 524 or if the error is a timeout or connection refused ## Exportable Content All exported elements will be wrapped in a JSON dictionary. If you're using a cron export there will potentially be more than 1 element in the dictionary, but if you're using realtime export you're guaranteed to only have 1 element in the dictionary. ```json { "": { ... }, "": { ... } } ``` ### Checkouts You can configure an export integration that will receive all `checkouts` from an entire `account` in the Ka-ching system. The `Checkout` entity is described in details in the [Models](./models.md) document. ### Sales You can configure an export integration that will receive all `sales` from an entire `account` in the Ka-ching system. The `Sales` entity is described in details in the [Models](./models.md) document and includes information about the line items in the sale, the payment transactions used to pay for the sale, the applied discounts and taxes, information about the source of the sale and the time of the sale. ### Register Close Statements You can configure an export integration that will receive all `register close statements` from an entire `account` in the Ka-ching system. The `Register close statements` entity is described in details in the [Models](./models.md) document and includes information about aggregated totals for sales, returns and grouped by product group. It also contains information about the reconciliations of payment types and information about the source of the register close statement and the time of the register close event. ### Product Edit Events You can configure the system to perform an export of product details every time they change in the system. This is useful for the situation where you use the Ka-ching system as the primary source for products and wish other systems to reflect any changes made to the products. Product creation, product changes and product deletion events are exported. ### Newsletter Signup Events It's possible to configure Ka-ching POS or SecondScreen apps to enable a very basic newsletter signup form asking for email address. This information can be sent to systems like Mailchimp using an export-configuration transforming the newsletter signup-event to the format required to sign up in Mailchimp. ### Stock Events It's possible to get all stock events in the system through exports. The exported element looks like this: ```json { "": { "adjustment" : , "new_stock_value": , "product_id" : "", "variant_id" : "", "sale_id" : "", "stock_location_id" : "", "stock_count_diff": , "stock_count_expected": , "stock_count_id": "", "timestamp" : "", "type" : "" } } ``` The stock event export can be filtered to ignore certain types of events. ### Incoming Order State Change Events When an incoming order changes state in Ka-ching it's possible to receive notification of this event. The exported element looks like this: ```json { "order": , "state": } ``` Definition of the order object kan be found on our [Models](./models.md) page. Here's the definition of order state: ```json { "created" : , "last_change" : , "last_change_by" : , "last_change_comment" : "", "order_state" : "" } ``` The cashier object is defined as follows: ```json { "display_name" : "", "full_name" : "", "identifier" : "", "image_url" : "" } ``` ### Outgoing Orders When an order is created in Ka-ching POS, and it is not being sent internally in the system to another shop, then it is exported as an 'outgoing order'. Previously e-commerce orders were only indirectly sent through a sale entity, and the receiver would have to do some filtering to find the e-commerce line items. Now an order entity is created instead - and the intergrating system can send 'outgoing order state changes' back into Ka-ching in order to keep the system in sync with what happens to the order. Definition of the order object kan be found on our [Models](./models.md) page. --- Source: https://developers.ka-ching.dk/runtime-integrations-overview.md ## Runtime integrations `Runtime integrations` is our name for configurable services, that are being activated by one of our apps. For instance the POS can perform an `E-com Product Search` and the Stock app can perform an `External Product Lookup`. Common to these are that they can all be implemented by adding HTTP(S) endpoints that can be called from the Ka-ching system. This means that commonly, they are configured with a set of HTTP request parameters as well as a transformation on the returned data (if the format does not already match what is expected by the integration). Runtime integrations can be configured in the [Ka-ching Backoffice](https://backoffice.ka-ching.dk) under Advanced settings. In the Backoffice you can configure basic HTTP requests. In case you need to do something more advanced - like adding a POST request body or transforming the result to the data format that Ka-ching expects - please reach out to us. --- Source: https://developers.ka-ching.dk/customer-lookup-runtime-integration.md ## Customer Lookup ### Background In the Ka-ching POS, a customer can be added to a sale. Doing this allows for some interesting functionality. First and foremost, the customer id will be available on the exported sale data, so that you may register these details in your own system. Secondly, if your system contains information about the customer address, phone, email, etc., this can be used for pre-filling shipping details for e-commerce orders, and pre-filling email address for the receipt. Thirdly, you can create discount campaign rules that only trigger when a customer is added to the basket, so this can be used to create customer discounts. ### Options for the configuration Like all of our 'runtime integrations', the actual endpoints and parameters for a http request can be configured in our system. Similarly, the returned response can be transformed in Ka-ching before being passed to the client (Ka-ching POS). This means that wether you prefer a GET request with query parameters or a POST request with a JSON body containing the parameters is less important. But of course the integration becomes easier if the response already matches what our client expects, because then we can skip a transformation step. #### Request parameters ~~~ search_term ~~~ ~~~ currency_code ~~~ The `search_term` is the string that is entered when performing the customer lookup in POS. Based on what the receiving system can do, you may consider this to be a search string for filtering by any or all properties in your customer database. For instance it is common to return matches on customer id, name, phone number, email or even address - this is basically up to you. You may also, for instance, consider it to be a lookup of a single customer by a customer id. The currency code of the active shop in POS may be passed along too - in case your system can report customer account balances in multiple currencies. #### Response The response will in the end be transformed to a list of `Customer` representations. Please have a look at the [`Customer`](./models.md#customer) entity model for more information. --- Source: https://developers.ka-ching.dk/customer-specific-discounts-runtime-integration.md ## Customer Specific Discounts ### Background It is possible to configure the system with discounts that only apply for a specific customer. If customer specific discount are enabled, the Ka-ching system will ask for a list of discounts for a given customer id. The response will be added to the list of discount campaigns that are processed whenever the basket content changes. ### Options for the configuration Like all of our 'runtime integrations', the actual endpoints and parameters for a http request can be configured in our system. Similarly, the returned response can be transformed in Ka-ching before being passed to the client (Ka-ching POS). This means that wether you prefer a GET request with query parameters or a POST request with a JSON body containing the parameters is less important. But of course the integration becomes easier if the response already matches what our client expects, because then we can skip a transformation step. #### Request parameters ~~~ customer_id ~~~ ~~~ currency_code ~~~ ~~~ market ~~~ The `customer_id` is the identifier of the customer (previously looked up using the `Customer Lookup` integration. Other parameters available to the endpoint are: the current `market` and the `currency_code` of the current base currency. Please refer to the [Vocabulary](vocabulary.md) to see the definition of a market. #### Response The response from this web service should be a json-encoded array of discount objects - similar to those described in the [Discount Campaign Import Endpoint](discount-campaigns-import-integration.md) chapter. But since the request is for a specific market and a specific currency code, it is only necessary to send new prices and the like for the specific market: ~~~json [ { "id": "0003", "type": "new_price_discount-single_product", "product_id": "abc", "new_price_per_item": 42, "name": "New price discount", "display_name": "New price discount", "priority": 80 } ] ~~~ In case you have an existing web service for returning customer discounts, we can perform some data transformation on the result. Reach out to us in case that is relevant. --- Source: https://developers.ka-ching.dk/giftcard-runtime-integration.md ## Gift card The current gift card integration consists of four actions: `create`, `activate`, `read` and `pay`. These will be called at appropriate times and allow for your server to control the creation and payment flow. All four integrations should return a full `Giftcard` entity with the new state: ~~~json { "amount": "", "code": "", "create_date": "", "currency_code": "", "expiry_date": "", "id": "", "status": "", "external_giftcard": "" } ~~~ Here `amount` is the currently available amount, `code` is the customer-displayed id of the gift card, which is used to create bar codes for printing, `create_date` and `expiry_date` are pretty self-explanatory, `currency_code` is required in order to prevent usage in the wrong market, `id` is an internal identification of the gift card, `status` is the current state of the gift card, and `external_giftcard` may be used by you to carry any information that is not directly relevant to the Ka-ching system, but may be required by your integration. ### Create From an action in the Ka-ching POS, you can create a gift card and add it to the basket. The gift card will be created in an inactive state, and only activated once the sale has been fully paid. ### Activate Called with the details of an inactive gift card once the gift card has been paid. ### Read Called from an action in the Ka-ching POS to let the customer know the balance. ### Pay Called from the Ka-ching POS when a gift card is being used for payment in the POS. ## Customer account payment The current customer account integration consists of two actions:`read` and `pay`. These will be called at appropriate times and allow for your server to control the payment flow. Both integrations should return an entity containing an amount: ~~~json { "amount": "", } ~~~ For the customer account `read` action, the `amount` should refer to the current balance of the customer account. For the `pay` action, the `amount` should contain the actual amount that was used. This could be different than the amount requested to be used, but if it is not possible to pay with the desired amount, a better option is probably to let the payment fail. Any non-200 response from the server will be treated as a failure to perform the payment. ### Read Called from an action in the Ka-ching POS to get the current balance. Parameters are `customer_id` and `currency_code`. ### Pay Called from the Ka-ching POS when a customer account is being used for payment in the POS. Parameters are `amount`, `customer_id` and `currency_code`. --- Source: https://developers.ka-ching.dk/shipping-runtime-integration.md ## Shipping Options When adding e-commerce products to the basket, the cashier will need to enter shipping details, that are included in the sale. By creating a `shipping options` integration, your server will be called with the address of the customer, the shop id and the currency code of the base currency in the shop. Your server can then reply with a list of shipping options, where each option contains a price for the delivery, an identifier of your own choice, a title and some details. The selected option will be included in the sale, and this allows your servers to process the delivery options when placing an order in your e-com system. ~~~json [ { "id": "", "price": "", "title": "", "subtitle": "" } ] ~~~ --- Source: https://developers.ka-ching.dk/csv-import-overview.md # CSV import > How to import your data into Ka-ching using the CSV import feature. ## CSV Importer The Ka-ching backend offers a convenient way of importing products to the POS. You can maintain a small 'database' of products in the form of a spreadsheet, and export this as a CSV document. This document can simply be drag/dropped to the import window, and the import will initiate. ### CSV format details The CSV format does not have any formal specification, but instead rely on conventions. The following details apply to our interpretation of the CSV format. * We try to auto-detect field delimiters and should be able to handle both semicolon (;) and comma (,) * Similarly for decimal delimiters. Note that you may not use comma for both field delimiter and decimal delimiter for obvious reasons * We use line breaks (\n) as row delimiters * The file is expected to be encoded as UTF-8 * The first line represents the fields to be imported. More about this below. * Field values may be surrounded by quotes (") in order to represent line breaks in the data (for instance for product descriptions). In order to represent a quote (") inside a quoted string, the quote must itself be escaped with an extra quote (""). --- Source: https://developers.ka-ching.dk/products-csv-import.md # Products CSV Import > How to use the Ka-ching products CSV import. ## `Products` CSV Import Simple products may be imported to the Ka-ching system through the Ka-ching Back Office using the CSV format. Since the CSV format is by nature very -flat-, and our product model is basically a hierarchical structure, there is not a very good fit between what we can express in CSV and what our products can express. The import itself is also a manual process, so this is only intended for getting started using the system real quick - or if you do not have an external PIM system and would like to use the Ka-ching system as the primary source for your products. ### Product format A product can be represented by as little as three values: #### Required values * Unique identifier * Name * Retail price The unique identifier is used to identify the product, so that if you import the CSV file repeatedly, then the product matching the identifier will be overwritten with the new values. The name is required in order to logically identify the product in the POS, and in statistics, etc. The retail price is required since otherwise we cannot sell the product. #### Optional values * Bar code * Product description * Short description * Cost price * Sale price * Image URL The bar code can be used to represent the textual value of the bar code on the physical product. This may correspond to an EAN code, an ISBN number or a SKU. If this value is present, the product can be added to the basket by scanning the bar code. The Product description is shown when long-pressing a product in the POS. If a cost price is added, then we can calculate the contribution margin when selling the product. This value is always represented without any taxes added. If a Sale price is added, then a discount will be added when the product is added to the basket. So if a product normally cost 100 DKK and the sale price is 80 DKK, then the POS will 'cross out' the 100 DKK and write 'New price: 80 DKK' You may import images for the products as described below, but if you already know of publically accessible URLs for the images on a CDN, you may also include the image URL directly. The images should be in JPEG or PNG format. #### Localizable values The product name and product description is localizable data. This means that instead of giving a product a fixed name, you may specify it in any of the 13 languages that we currently support: * Danish * English * French * Norwegian (Bokmål) To specify a field in multiple languages, you just postfix the field with a dot (.) and the language code. The codes for the languages are: * da * en * fr * nb So for instance, the 'product name' field is called 'field'. So the following imports two products with no localization of the name: ``` id;name;retail_price p001;Coffee;10.50 p002;Tea;9.50 ``` These products could be localized into Danish and English as follows: ``` id;name.da;name.en;retail_price p001;Kaffe;Coffee;10.50 p002;Te;Tea;9.50 ``` #### Tags You can tag a product with one or more categories. The identifiers for the tags can be seen under the 'Tags' editor in the Portal. To add two tags to your products you can use the fields `tags.0` and `tags.1`. Example: ``` id;name;retail_price;tags.0;tags.1 p001;Coffee;10.50;beverage;caffeinated p002;Tea;9.50;beverage;popular ``` #### Attributes You can add custom attributes to a product. Attributes are similar to tags, but you can define the attributes in the backend - thus creating custom properties on a product. For instance you could have a 'brand' attribute or a 'review'. Example: ``` id;name;retail_price;attributes.brand;attributes.review p001;Coffee;10.50;starbucks;A great coffee, and very cheap p002;Tea;9.50;earlgray;Nice tea - very popular ``` ### Field names Now we have described the overall product structure and the required and optional fields. Here is a list of all the currently supported field names: * id * name (localizable) * description (localizable) * short_description (localizable) * retail_price * cost_price * sale_price * image_url * tags.0, tags.1, tags.2, etc. * attributes.my_custom_attribute, attributes.*, etc. Finally an example with all the above values represented: ``` id;name.da;name.en;description.da;description.en;retail_price;cost_price;sale_price;image_url;barcode;tags.0;tags.1 p001;Kaffe;Coffee;"Kaffe er en sund og dejlig drik. Og denne beskrivelse strækker sig over flere linjer";"Coffee is a healthy and excellent beverage. And this description spans several lines";10.50;3.00;9.00;http://example.com/coffee.jpg;ABCDEFG;beverage;caffeinated p002;Te;Tea;"Te er en ""drik"" og dette er et eksempel på at bruge gåseøjne i et felt";"Tea is a ""beverage"" and this is an example of using quotes inside a field";9.50;1.50;8.00;http://example.com/tea.jpg;ABCDEFX;beverage;popular ``` ### Variants and dimensions It is generally hard to represent hierarchical data in a 'flat' CSV file, but we have made it possible to describe variants and dimensions on a product by having multiple lines for the same product in the CSV: #### Variants General format: ``` id;variant_id;name;retail_price p001;;Espresso;10 p001;single;Single shot; p001;double;Double shot;15 ``` The first line define the product with id: p001, name 'Espresso' and a default price of 10. The second line defines a variant (through the inclusion of a non-empty variant_id) on the same product (by referring to the same id) with an override of the name, but no override of the price. The third line defines a second variant that also overrides the price. #### Dimensions Dimensions and dimension values can be added in a similar fashion - using a special notation to refer to the dimensions and values from each variant: ``` id;variant_id;name;retail_price;dimension_id;dimension_value_id;dimension_values p001;;Dress;190;;; p001;small-red;;;;;size=s#color=red p001;large-blue;;200;;;size=l#color=blue p001;;Size;;size;; p001;;S;;size;s; p001;;M;;size;m; p001;;L;;size;l; p001;;Color;;color;; p001;;Green;;color;green; p001;;Red;;color;red; p001;;Blue;;color;blue; ``` Here's the same data presented as a table: |id|variant_id|name|retail_price|dimension_id|dimension\_value_id|dimension_values| |---|---|---|---|---|---|---| |p001||Dress|190|||| |p001|small-red|||||size=s#color=red| |p001|large-blue||200|||size=l#color=blue| |p001||Size||size||| |p001||S||size|s|| |p001||M||size|m|| |p001||L||size|l|| |p001||Color||color||| |p001||Green||color|green|| |p001||Red||color|red|| |p001||Blue||color|blue|| As in the previous example, the first line contains the product definition. The following two lines contain variant definitions (by the presence of the `variant_id`). We'll return to the variant-specific field `dimension_values` later. The fourth line defines the dimension named 'Size' with id 'size' (by the presence of the `dimension_id`). The three lines after that define three different sizes (by the presence of both `dimension_id` and `dimension_value_id`). Finally we repeat this concept to add the 'Color' dimension with the values 'Green', 'Red' and 'Blue'. Now let's return to the `dimension_values` field. This field points out the dimension values for each variant. There needs to be a valid value for each dimension. The format is a `#`-separated list of dimension_id to dimension_value_id pairs separated by an `=` sign. ## Batch uploading images You may drag/drop multiple images to be imported in one go. The image names should identify which product they should be attached to, so in the above example we could batch import images for the Coffee and Tea by naming the images p001.jpg and p002.jpg and drag/dropping both images to the product image import. ## Sample CSV files To get started, you may experiment with the following files: [Simple](./csv-import-resources/simple.csv) [Advanced](./csv-import-resources/advanced.csv) [Variants and dimensions](./csv-import-resources/variants_and_dimensions.csv) --- Source: https://developers.ka-ching.dk/stock-csv-import.md # Stock CSV Import > How to use the Ka-ching stock CSV import. ## `Stock` CSV Import Stock CSV Import is ONLY intended for initial setup. This is due to the fact that the Ka-ching system is built around traceability, and all stock modifications are logged with detailed information about the reasons for the stock change (e.g. sales, returns, reception of goods or resets due to a stock inventory count). The CSV Import is logged as 'stock import reset' event, so it basically overwrites the existing stock counts and does not provide a lot of detailed information as to the reason. For this reason it should be used very sparingly - ideally only when the system is initially configured. The format is very simple: Format description: ### Products without variants: ~~~ product_id,quantity 0001,11 0002,20 1234,1 ~~~ [Download sample](./import-integration-resources/stock-sample.csv) ### Products with variants: ~~~ product_id,variant_id,quantity 0001,blue,11 0001,red,2 0002,medium,20 0002,large,32 0003,,10 ~~~ Note that it is ok to leave out the variant id for products without variants in the latter form. [Download sample](./import-integration-resources/stock-variant-sample.csv) ### Taking products out of stock You can use a dash (-) in place of the quantity in order to remove the product from stock. Taking a product out of stock means that it will no more be a part of the stock reports or the stock counts. Taking a product out of stock is often performed together with removing the product from the product catalog. Example: ~~~ product_id,variant_id,quantity 0001,blue,- 0001,red,- 0002,medium,20 0002,large,32 0003,,10 ~~~ Here both variants of the product with id '0001' are taken out of stock. ### Performing stock adjustments You can also use the CSV import to make adjustments rather than setting the new stock value. To do just that, replace the `quantity` column with an `adjustment` column. Note that adjustments can be both positive and negative. ~~~ product_id,variant_id,adjustment 0001,blue,11 0001,red,-2 0002,medium,20 0002,large,-32 0003,,10 ~~~ --- Source: https://developers.ka-ching.dk/product-recommendations-csv-import.md # Product recommendations CSV Import > How to use the Ka-ching product recommendations CSV import. ## Product Recommendation CSV Import With the CSV format, you can target all configured recommendation categories at once. The rank describes the sorting order of the imported data for each product. Format description: ~~~ product_id,recommended_product_id,recommendation_category_id,rank 0001,0002,curated,1 0001,0010,curated,2 0001,1234,curated,3 0002,0001,curated,1 0002,0010,curated,2 0002,1234,curated,3 ~~~ [Download sample](./import-integration-resources/recommendation-sample.csv) --- Source: https://developers.ka-ching.dk/resources.md # Resources > Downloadable examples and resources to use when integrating with Ka-ching. ## Postman collection This Postman collection lets you play around with importing products, deleting them again, and adding product recommendations using the imports endpoint. After importing into Postman, you need to right edit the collection, go to the _variables_ tab and add appropriate values for the following variables: - account - api_key - integration Please contact contact us at support@ka-ching.dk for more information on how to obtain the above keys. [Download Postman](https://www.getpostman.com) Download collection --- Source: https://developers.ka-ching.dk/ai-tools.md # Building with AI tools > Use Claude and other AI coding assistants to build integrations with the Ka-ching APIs. ## Building with AI tools AI coding assistants such as Claude can write most of the code for a Ka-ching integration, provided they know how the API works. We publish this documentation in formats they can read directly. ### For any AI tool: `llms.txt` - [`llms.txt`](https://developers.ka-ching.dk/llms.txt) is an index of this site for language models, following the [llms.txt](https://llmstxt.org) convention. - [`llms-full.txt`](https://developers.ka-ching.dk/llms-full.txt) contains every page in one file. - Every page is also available as plain Markdown: replace `//` with `/.md`, for example [`/stock-import-integration.md`](https://developers.ka-ching.dk/stock-import-integration.md). - The [OpenAPI spec](https://developers.ka-ching.dk/openapi/openapi-bundled.json) describes the REST API, import endpoints and webhooks. You can also generate a typed client from it, for example with `swift-openapi-generator` or `openapi-typescript`. Point your assistant at these URLs, for example: *"Read https://developers.ka-ching.dk/llms.txt and build a script that exports yesterday's checkouts to CSV."* ### For Claude: the Ka-ching API skill The **ka-ching-api** [Agent Skill](https://docs.claude.com/en/docs/agents-and-tools/agent-skills/overview) teaches Claude the REST API: authentication, endpoints, stats time formats and buckets, common pitfalls, and client examples in TypeScript and Swift. Claude loads it automatically when a task involves Ka-ching. [Download ka-ching-api.zip](https://developers.ka-ching.dk/skills/ka-ching-api.zip) **Claude Code**: unzip into your skills folder, either for yourself or for one project: ~~~bash # For all your projects curl -sL https://developers.ka-ching.dk/skills/ka-ching-api.zip -o /tmp/ka-ching-api.zip unzip -o /tmp/ka-ching-api.zip -d ~/.claude/skills/ # Or only for the current project (commit it to share with your team) unzip -o /tmp/ka-ching-api.zip -d .claude/skills/ ~~~ **Claude apps (claude.ai, desktop)**: upload `ka-ching-api.zip` in the *Skills* section of Settings. Skills must be enabled for your account or organization. You can read the skill before installing it: [SKILL.md](https://developers.ka-ching.dk/skills/ka-ching-api/SKILL.md). ### Keep your API keys safe Give your assistant the account ID and API key through environment variables (for example `KACHING_ACCOUNT` and `KACHING_API_KEY`), not by pasting them into the chat or committing them to code. REST API keys can be disabled and recreated in the back office under *Advanced → REST API* if one is exposed.