Basket retrieval
The retrieve basket call is executed when an OpenApp user wants to check out and scans the OpenApp barcode in OpenApp. This is visible as step 4 in the sequence diagram:
Request
Once the customer scans the barcode OpenApp retrieves the basket. This is a HTTP GET request from the OpenApp server to the endpoint configured in the control panel, with request parameter “basketId” equals to what was set in data-basket in webshop frontend:
GET <basket-url>?basketId=<data-basket>
So if you configured the value https://shop.example.com/api/openapp/basket and used the basketId value 6548654ef654d654aa, the request executed by OpenApp will be:
GET https://shop.example.com/api/openapp/basket?basketId=6548654ef654d654aa
Response
In response, the website should send the basket content and configured delivery options. This is shown in the example below. In this eample, the user has a quantity of 2 'Superb product' in his basket, each priced at 70.00 PLN. But since he has also applied a discount code to get 10 PLN discount, the total price is 130 PLN. The order can be delivered to an InPost APM without additional charge, or can be home delivered for a 10 PLN surcharge.
- Response
- Schema
{
"id": "basket-id",
"expiresAt": "2022-03-23T21:00:00Z",
"price": {
"currency": "PLN",
"discounts": [
{
"code": "discount-code-text",
"value": 1000
}
],
"basketValue": 13000
},
"deliveryOptions": [
{
"key": "INPOST_APM",
"cost": 0
},
{
"key": "DPD_COURIER",
"cost": 1000,
"timing": "next business day"
}
],
"products": [
{
"ean": "12312",
"id": "id123",
"name": "Superb product",
"images": [
"http://cdn.merchant.com/static/products/id123/1",
"http://cdn.merchant.com/static/products/id123/2"
],
"quantity": 2,
"unitPrice": 7000,
"linePrice": 14000,
"originalUnitPrice": 7000,
"originalLinePrice": 14000,
"policies": [
{
"type": "AGE",
"criteria": {
"minAge": 18
}
}
]
}
],
"loggedUser": "user-id-from-webshop"
}
idstringRequiredThe unique ID of the basket.
maxLength: 36
requestIdstringOptionalThe ID of the basket request as generated by OpenApp. Mandatory in case of an asynchronous connection through a queue in order to correlate the placed order with the response.
maxLength: 36
expiresAtstringRequiredThe moment until which the basket is valid. This can be used to indicate a basket needs to be ordered before a specific time in order to guarantee availability.
format: date-time
oaOrderIdstringOptionalThe OpenApp order ID (if known).
priceobjectRequiredShow child parametersHide child parameters3
currencystringRequiredbasketValueintegerRequiredThe price of the basket. Price is expressed as the number (integer) of 1/100s of the price.
minimum: 0
discountsarray of BasketPriceDiscountRequiredApplied discounts
Show child parametersHide child parameters3
codestringRequiredThe discount code.
maxLength: 36
valueintegerRequiredThe value of the discount. Value is expressed as the number (integer) of 1/100s of the currency.
minimum: 0
errorenumOptionalThe error code of the discount
Possible values: EXPIREDINVALIDNOT_APPLICABLEUSED
deliveryOptionsarray of BasketDeliveryOptionRequiredShow child parametersHide child parameters3
keyenumRequiredPossible values: DHL_COURIERDHL_PICKUPDPD_COURIERDPD_PICKUPELECTRONICFEDEX_COURIERGEIS_COURIERGLS_COURIERINPOST_APMINPOST_COURIERINSTORE_PICKUPORLEN_APMPOCZTA_POLSKA_APMPOCZTEX_COURIERUPS_COURIER
costintegerRequiredThe price of the delivery. Price is expressed as the number (integer) of 1/100s of the price.
timingstringOptionalThe estimation of the delivery time, i.e. 'next business day' or 'July 18th'.
maxLength: 40
productsarray of BasketProductRequiredShow child parametersHide child parameters11
namestringRequiredThe product name.
imagesarray of stringRequiredThe URLs of the product image
originalUnitPriceintegerRequiredThe original (before discount) price of a single product. Price is expressed as the number (integer) of 1/100s of the price.
originalLinePriceintegerRequiredThe original (before discount) price of the products. Price is expressed as the number (integer) of 1/100s of the price.
errorenumOptionalError code when the product request can not be accomodated in a recalculate request.
Possible values: OUT_OF_STOCKQUANTITY_TOO_BIG
eanstringOptionalThe ean (or other barcode on the product). Specifying this allows the user to search in his order history by scanning the barcode to do a re-purchase.
maxLength: 36
idstringRequiredThe unique ID of the product.
maxLength: 36
quantityintegerRequiredThe number of items in the purchase.
minimum: 0
unitPriceintegerRequiredThe price of a single product. Price is expressed as the number (integer) of 1/100s of the price.
linePriceintegerRequiredThe price of the products. Price is expressed as the number (integer) of 1/100s of the price.
policiesarray of ProductPolicyOptionalThe list of policies applied to the product.
maxItems: 1
Show child parametersHide child parameters2
typeenumRequiredPossible values: AGE
criteriaobjectRequiredShow child parametersHide child parameters1
minAgeintegerRequiredminimum: 0
invoiceAddressMandatorybooleanOptionalWhether an invoice address is mandatory
loggedUserstringOptionalThe unique ID of the user.
maxLength: 255
Raw JSON Schema
{
"description": "Basket returned on retrieval or recalculation",
"additionalProperties": false,
"type": "object",
"properties": {
"id": {
"description": "The unique ID of the basket.",
"maxLength": 36,
"type": "string",
"title": "id"
},
"requestId": {
"description": "The ID of the basket request as generated by OpenApp. Mandatory in case of an asynchronous connection through a queue in order to correlate the placed order with the response.",
"maxLength": 36,
"type": "string",
"title": "requestId"
},
"expiresAt": {
"description": "The moment until which the basket is valid. This can be used to indicate a basket needs to be ordered before a specific time in order to guarantee availability.",
"format": "date-time",
"type": "string",
"title": "expiresAt"
},
"oaOrderId": {
"description": "The OpenApp order ID (if known).",
"type": "string",
"title": "oaOrderId"
},
"price": {
"$ref": "#/definitions/BasketPrice",
"title": "price"
},
"deliveryOptions": {
"type": "array",
"items": {
"$ref": "#/definitions/BasketDeliveryOption"
},
"title": "deliveryOptions"
},
"products": {
"type": "array",
"items": {
"$ref": "#/definitions/BasketProduct"
},
"title": "products"
},
"invoiceAddressMandatory": {
"description": "Whether an invoice address is mandatory",
"type": "boolean",
"title": "invoiceAddressMandatory"
},
"loggedUser": {
"description": "The unique ID of the user.",
"maxLength": 255,
"type": "string",
"title": "loggedUser"
}
},
"required": [
"deliveryOptions",
"expiresAt",
"id",
"price",
"products"
],
"definitions": {
"BasketPrice": {
"title": "BasketPrice",
"type": "object",
"properties": {
"currency": {
"type": "string",
"title": "currency"
},
"basketValue": {
"description": "The price of the basket. Price is expressed as the number (integer) of 1/100s of the price.",
"minimum": 0,
"type": "integer",
"title": "basketValue"
},
"discounts": {
"description": "Applied discounts",
"type": "array",
"items": {
"$ref": "#/definitions/BasketPriceDiscount"
},
"title": "discounts"
}
},
"required": [
"basketValue",
"currency",
"discounts"
]
},
"BasketPriceDiscount": {
"title": "BasketPriceDiscount",
"type": "object",
"properties": {
"code": {
"description": "The discount code.",
"maxLength": 36,
"type": "string",
"title": "code"
},
"value": {
"description": "The value of the discount. Value is expressed as the number (integer) of 1/100s of the currency.",
"minimum": 0,
"type": "integer",
"title": "value"
},
"error": {
"description": "The error code of the discount",
"enum": [
"EXPIRED",
"INVALID",
"NOT_APPLICABLE",
"USED"
],
"type": "string",
"title": "error"
}
},
"required": [
"code",
"value"
]
},
"BasketDeliveryOption": {
"title": "BasketDeliveryOption",
"type": "object",
"properties": {
"key": {
"$ref": "#/definitions/MerchantDeliveryOptions",
"title": "key"
},
"cost": {
"description": "The price of the delivery. Price is expressed as the number (integer) of 1/100s of the price.",
"type": "integer",
"title": "cost"
},
"timing": {
"description": "The estimation of the delivery time, i.e. 'next business day' or 'July 18th'.",
"maxLength": 40,
"type": "string",
"title": "timing"
}
},
"required": [
"cost",
"key"
]
},
"MerchantDeliveryOptions": {
"title": "MerchantDeliveryOptions",
"enum": [
"DHL_COURIER",
"DHL_PICKUP",
"DPD_COURIER",
"DPD_PICKUP",
"ELECTRONIC",
"FEDEX_COURIER",
"GEIS_COURIER",
"GLS_COURIER",
"INPOST_APM",
"INPOST_COURIER",
"INSTORE_PICKUP",
"ORLEN_APM",
"POCZTA_POLSKA_APM",
"POCZTEX_COURIER",
"UPS_COURIER"
],
"type": "string"
},
"BasketProduct": {
"title": "BasketProduct",
"type": "object",
"properties": {
"name": {
"description": "The product name.",
"type": "string",
"title": "name"
},
"images": {
"description": "The URLs of the product image",
"type": "array",
"items": {
"type": "string"
},
"title": "images"
},
"originalUnitPrice": {
"description": "The original (before discount) price of a single product. Price is expressed as the number (integer) of 1/100s of the price.",
"type": "integer",
"title": "originalUnitPrice"
},
"originalLinePrice": {
"description": "The original (before discount) price of the products. Price is expressed as the number (integer) of 1/100s of the price.",
"type": "integer",
"title": "originalLinePrice"
},
"error": {
"description": "Error code when the product request can not be accomodated in a recalculate request.",
"enum": [
"OUT_OF_STOCK",
"QUANTITY_TOO_BIG"
],
"type": "string",
"title": "error"
},
"ean": {
"description": "The ean (or other barcode on the product). Specifying this allows the user to search in his order history by scanning the barcode to do a re-purchase.",
"maxLength": 36,
"type": "string",
"title": "ean"
},
"id": {
"description": "The unique ID of the product.",
"maxLength": 36,
"type": "string",
"title": "id"
},
"quantity": {
"description": "The number of items in the purchase.",
"minimum": 0,
"type": "integer",
"title": "quantity"
},
"unitPrice": {
"description": "The price of a single product. Price is expressed as the number (integer) of 1/100s of the price.",
"type": "integer",
"title": "unitPrice"
},
"linePrice": {
"description": "The price of the products. Price is expressed as the number (integer) of 1/100s of the price.",
"type": "integer",
"title": "linePrice"
},
"policies": {
"description": "The list of policies applied to the product.",
"maxItems": 1,
"type": "array",
"items": {
"$ref": "#/definitions/ProductPolicy"
},
"title": "policies"
}
},
"required": [
"id",
"images",
"linePrice",
"name",
"originalLinePrice",
"originalUnitPrice",
"quantity",
"unitPrice"
]
},
"ProductPolicy": {
"title": "ProductPolicy",
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/ProductPolicyType",
"title": "type"
},
"criteria": {
"$ref": "#/definitions/AgeCriteria",
"title": "criteria"
}
},
"required": [
"criteria",
"type"
]
},
"ProductPolicyType": {
"title": "ProductPolicyType",
"enum": [
"AGE"
],
"type": "string"
},
"AgeCriteria": {
"title": "AgeCriteria",
"type": "object",
"properties": {
"minAge": {
"type": "integer",
"minimum": 0,
"title": "minAge"
}
},
"required": [
"minAge"
]
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
Product policies (optional)
Product-level policies are optional and can be sent only when needed by the merchant.
For example, if a product is intended only for adult users, the merchant can include an age policy:
type: AGEcriteria.minAge: 18
If no extra product restrictions are needed, policies can be omitted.
expiresAt
The validity of the basket can be indicated by expiresAt. OpenApp allows the user to place the order until this time is reached (step 7 in the diagram above). After receiving the order from the user, OpenApp will execute the payment which might take up to 3 minutes. So OpenApp will send the order placement to the merchant at the latest 3 minutes after the time specified in expiresAt.
If no connection to the merchant is possible for 5 minutes (so in total at most 8 minutes after expiresAt), OpenApp will roll back the transaction and issue a refund to the user.
This example is an example of a simple basket. For a complete description of the basket response see the Schema tab above.