Cart

Prerequisites

Create a Cart

Parameters

  • cultureCode, e.g. en-US (string)

  • currency, e.g. DKK (string)

Request

curl -D- -X POST <base_url>/api/v1/carts \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
    -d '{
        "cultureCode": "<cultureCode>",
        "currency": "<currency>"
    }'

Response

{
    "cartId": "fec4b401-6eb9-4af7-a907-73c817bcaf31"
}

Get Cart

Parameters

Request

curl -D- -X GET <base_url>/api/v1/carts/<cartId> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \

Response

{
    "billingAddress":{
        "addressName": "{addressName}",
        "attention": "{attention}",
        "city": "{city}",
        "companyName": "{companyName}",
        "country":{
            "cultureCode": "{cultureCode}",
            "id": "{id}",
            "name": "{name}"
        },
        "emailAddress": "{email}",
        "firstName": "{firstName}",
        "id": "{id}",
        "lastName": "{lastName}",
        "line1": "{line1}",
        "line2": "{line2}",
        "mobilePhoneNumber": "{mobilePhoneNumber}",
        "phoneNumber": "phoneNumber",
        "postalCode": "{postalCode}",
        "state": "{state}"
    },
    "billingCurrency":{
        "id": "{id}",
        "isoCode": "{isoCode}"
    },
    "customer": "{customer}",
    "discounts": "{[discount1, discount2]}",
    "shipments": [
        {
            "deliveryNote": "{deliveryNote}",
            "id": "{id}",
            "orderLines": [
                {
                    "discount": "{discount}",
                    "discounts": "{[discount1, discount2]}",
                    "id": "{id}",
                    "price": "{price}",
                    "priceGroupId": "{priceGroupId}",
                    "productCatalogId": "{productCatalogId}",
                    "productName": "{productName}",
                    "quantity": "{quantity}",
                    "sku": "{sku}",
                    "total": "{total}",
                    "unitDiscount": "{unitDiscount}",
                    "variantSku": "{variantSku}",
                    "tax": "{tax}",
                    "taxRate": "{taxRate}",
                    "orderLineProperties": "[]"
                }
            ],
            "shipmentAddress":{
                "addressName": "{addressName}",
                "attention": "{attention}",
                "city": "{city}",
                "companyName": "{companyName}",
                "country":{
                    "cultureCode": "{cultureCode}",
                    "id": "{id}",
                    "name": "{countryName}"
                },
                "emailAddress": "{email}",
                "firstName": "{firstName}",
                "id": "{id}",
                "lastName": "{lastName}",
                "line1": "{line1}",
                "line2": "{line2}",
                "mobilePhoneNumber": "{mobilePhoneNumber}",
                "phoneNumber": "{phoneNumber}",
                "postalCode": "{postalCode}",
                "state": "{state}"
            },
            "shipmentDiscount": "{shipmentDiscount}",
            "shipmentName": "{shipmentName}",
            "shipmentPrice": "{shipmentPrice}",
            "shipmentPriceTotal": "{shipmentPriceTotal}",
            "shippingMethod":{
                "defaultPaymentMethod": "{defaultPaymentMethod}",
                "eligiblePaymentMethods":[
                    {
                        "displayName": "{displayName}",
                        "feePercent": "{feePercent}",
                        "fees":[
                            {
                                "amount": "{amount}",
                                "priceGroupId": "{priceGroupId}"
                            }
                        ],
                        "id": "{id}",
                        "imageUrl": "{imageUrl}",
                        "name": "{name}",
                        "paymentMethodProperties":[
                            {
                                "id": "{id}",
                                "cultureCode": "{cultureCode}",
                                "value": "{value}"
                            }
                        ]
                    }
                ],
                "id": "{id}",
                "name": "{name}"
            },
            "tax": "{tax}",
            "taxRate": "{taxRate}",
            "trackAndTrace": "{trackAndTrace}"
        }
    ],
    "customProperties":[
        {
            "id":"{id}",
            "key": "{key}",
            "value": "{value}"
        }
    ],
    "createdDate": "{createdDate}",
    "cultureCode": "{cultureCode}",
    "discount": "{discount}",
    "discountTotal": "{discountTotal}",
    "id": "{id}",
    "note": "{note}",
    "orderLines":[
        {
            "discount": "{discount}",
            "discounts": "{[]}",
            "id": "{id}",
            "price": "{priceAmount}",
            "priceGroupId": "{priceGroupId}",
            "productCatalogId": "{productCatalogId}",
            "productName": "{productName}",
            "quantity": "{quantity}",
            "sku": "{sku}",
            "total": "{total}",
            "unitDiscount": "{unitDiscount}",
            "variantSku": "{variantSku}",
            "tax": "{tax}",
            "taxRate": "{taxRate}",
            "customProperties":[
                {
                    "id":"{id}",
                    "key":"{propKey}",
                    "value":"{propValue}"
                }
            ]
        }
    ],
    "orderTotal": "{orderTotal}",
    "paymentTotal": "{paymentTotal}",
    "shippingTotal": "{shippingTotal}",
    "subTotal": "{subTotal}",
    "tax": "{tax}"
}

Converting a Cart to an Order

Parameters

Request

curl -D- -X POST <base_url>/api/v1/payments \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
    -d '{
        "cartId": "<cartId>",
        "paymentMethodId": "<paymentMethodId>",
        "priceGroupId": "<priceGroupId>",
        "cultureCode": "<cultureCode>"
    }'

Response

{
    "paymentId": "fec4b401-6eb9-4af7-a907-73c817bcaf31",
    "paymentUrl": "<base_url>/api/v1/checkout?payment=fec4b401-6eb9-4af7-a907-73c817bcaf31&paymentMethod=5d7d4d0f-581c-408a-ae0d-c4a77d2d883c"
}

Error Handling

ErrorDescription

BadRequest (400)

Execution of the pipeline fails; the Billing address is missing from the order; the Cart does not belong to the Store, etc.

Unauthorized (401)

The token is expired.

Forbidden (403)

The token does not have access to this endpoint.

Error Response Example

{
"errors":
    [
        {
            "error-description": "Billing address is missing from the order.",
            "error": "BadRequest"
        }
    ]
}
Error Handling

Last updated