Skip to main content

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.

{
"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"
}

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: AGE
  • criteria.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.