Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Handling baskets

This article will guide you through how to perform CRUD operations on your basket, using our headless API. The Postman collection will be used for all examples.

Prerequisites

Creating a basket

Additional Prerequisites

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

Create basket

Open the Create Basket request.

Provide the required request body properties - cultureCode and currency.

Request:

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

Response:

    
    
    {
        "basketId": "{basketId}"
    }
    
    

Getting your basket

Additional Prerequisites

  • basketId from the previous step (string)

Get basket

Open the Get Basket request.

Provide the mandatory path variable basketId.

Request:

    
    
    curl -D- -X GET {base_url}/api/v1/baskets/{basketId} \
    -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}",
                        "vat": "{vat}",
                        "vatRate": "{vatRate}",
                        "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}",
                "vat": "{vat}",
                "vatRate": "{vatRate}",
                "customProperties":[
                    {
                        "id":"{id}",
                        "key":"{propKey}",
                        "value":"{propValue}"
                    }
                ]
            }
        ],
        "orderTotal": "{orderTotal}",
        "paymentTotal": "{paymentTotal}",
        "shippingTotal": "{shippingTotal}",
        "subTotal": "{subTotal}",
        "vat": "{vat}"
    }
    
    

Converting a basket to an order

Additional Prerequisites

  • basketId from previous step (string)
  • cultureCode, e.g en-US (string)
  • priceGroupId either from your basket or from Get price groups. (string)
  • paymentMethodId from Get payment methods. (string)

Create payment

Open the Create Payment request.

Enter the basketId, priceGroupId, paymentMethodId and cultureCode properties in the appropriate places in the request body.

Request:

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

Response:

    
    
    {
    "paymentId": "string",
    "paymentUrl": "string"
    }
    
    

Possible errors that may occur

Error Description
BadRequest (400) Execution of the pipeline fails; Billing address is missing from the order; Basket does not below to Store; etc.
Unauthorized (401) The token is expired.
Forbidden (403) The token does not have access to this endpoint.
    
    
    {
    "errors": 
        [
            {
            "error-description": "Billing address is missing from the order.",
            "error": "BadRequest"
            }
        ]
    }
    
    

See Handling failures for more info.