Ucommerce
  • Ucommerce Next Gen
    • Getting Started
      • Prerequisites
      • Licensing
      • Ucommerce Templates
      • Headless Template
      • MVC Template
    • Headless
      • Postman Collection
      • Headless API Authentication
        • Token endpoint - Authorization Header
        • Authorization Scopes
        • Refreshing the Access Token
      • Reference
        • Cart
        • Cart / Order Line Items
        • Shipment
        • Billing
        • Promotion Codes
        • Price Groups
        • Payment Methods
        • Countries
        • Shipping Methods
        • Catalogs
        • Cart Custom Properties
        • Line Item Custom Properties
        • Orders
        • Views for Cart modifying operations
      • Custom Headless APIs
      • Error Handling
      • Pagination
      • Deprecation
    • Backoffice Authentication
      • Microsoft Entra ID Example
      • Auth0 Authentication Example
    • Definitions
      • What is a Definition
    • Search and indexing
      • Configuration
      • Indexing
        • Index Definitions
        • Facets
        • Indexing Prices
        • Suggestions
        • Custom Data
      • Searching
    • Payment Providers
      • Stripe Provider Integration
      • Implementing a custom payment provider
    • Data Import
    • Miscellaneous
      • Media
      • Price Group Inheritance
      • Price Group Criteria
      • Soft Deletion Of Entities
      • Logging
      • OpenTelemetry
    • Extensions
      • Extending Pipelines
        • Order Processing Pipelines
        • Checkout Pipelines
      • Changing Service Behavior
        • Images
        • Content
      • Custom Headless APIs
      • Extend the Backoffice
        • Custom UI Components
      • Custom Editor UI
      • Custom Promotion Criteria
      • Custom Price Group Criteria
    • How-To
      • Migrate from Classic
        • Common database issues
      • Entities from code
        • Bootstrapping data on startup
        • Product Definitions & Fields
      • Discover pipelines and their tasks
      • Executing a pipeline
    • Integrations
      • Umbraco Media Delivery API
      • App Slices
        • Product Picker
  • Release Notes
  • Contact Us
Powered by GitBook
On this page
  • Prerequisites
  • Create a Cart
  • Parameters
  • Request
  • Response
  • Get Cart
  • Parameters
  • Request
  • Response
  • Converting a Cart to an Order
  • Parameters
  • Request
  • Response
  • Error Handling
  • Related Articles

Was this helpful?

  1. Ucommerce Next Gen
  2. Headless
  3. Reference

Cart

Prerequisites

  • access_token from Headless API Authentication

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

  • cartId from Create a Cart (string)

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

  • cartId from Create a Cart(string)

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

  • priceGroupId, from Price Groups

  • paymentMethodId, from Payment Methods

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

Error
Description

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

Related Articles

PreviousReferenceNextCart / Order Line Items

Last updated 1 year ago

Was this helpful?

Error Handling