Introduction to commercetools Checkout

In today's commerce landscape, delivering a smooth and secure checkout experience is essential. commercetools Checkout is a pre-built checkout solution that's designed to simplify this process.

Ask about this Page
Copy for LLM
View as Markdown

After completing this page, you should be able to:

  • Explain what commercetools Checkout is and why it's used in modern commerce solutions.

  • Identify the key components and features of the Checkout product.

  • Describe how Checkout works at a high level in Complete Checkout and Payment Only modes.

commercetools Checkout is a pre-built checkout solution that handles the payment and order completion flow for Composable Commerce. It provides a pre-built UI and backend logic that integrates with Payment Service Providers (PSPs) through Connect and manages Cart-to-Order conversion.

Checkout features

Checkout simplifies the complexity of payment integration and implementation of the checkout flow:

  • PSP integration through Connect: use prebuilt Connectors for Stripe, Adyen, PayPal, and other payment providers without writing integration code.
  • Hosted UI: render checkout forms in your application by using the Browser SDK, with full customization of styles and labels.
  • Cart and Order management: Checkout reads Cart data from Composable Commerce and creates Orders upon successful payment.
  • PCI DSS compliance: Checkout and PSPs manage sensitive payment data in a secure manner, reducing your compliance scope.
  • Multi-region support: Checkout Applications are hosted in the same region as your commercetools project (Europe, America, Australia).
  • Localization: built-in support for multiple currencies and languages.
  • Event messaging: subscribe to Checkout events for tracking and analytics.

Checkout reduces the time that's required to implement payment processing by providing the infrastructure, PSP integrations, and UI components needed for a complete checkout flow.

Checkout modes: Complete Checkout and Payment Only

commercetools Checkout operates in two modes: Complete Checkout and Payment Only. The mode you choose determines which parts of the checkout flow Checkout manages.

Complete Checkout mode

Complete Checkout mode delegates the entire checkout UI and flow to Checkout. Your application creates a Cart in Composable Commerce, and then Checkout manages all the following steps of the checkout process:
  • Shipping and billing address forms
  • Selection of the shipping method
  • Selection of the payment method and entry of payment data
  • Acceptance of terms and conditions
  • Order summary
  • Checkout success and failure pages

Payment Only mode

Payment Only mode uses Checkout exclusively for payment processing. This mode is appropriate when you either have a custom checkout flow or existing implementation and want to use Checkout's PSP integrations without delegating the entire checkout.

Your application manages address collection, shipping method selection, and Cart updates. Checkout renders only the payment method selector and captures payment data through PSP-provided secure forms. The Cart must have shipping and billing information before initializing the payment flow.

Checkout architecture

Checkout contains several components that work together to process payments and manage the checkout flow.

Checkout Application (Backend Service)

This is the commercetools-hosted service that runs the checkout logic. The Checkout Application orchestrates everything during a customer's checkout; it reads or updates Cart and Order data in Composable Commerce, communicates with payment providers, and enforces the configurations you set.

Depending on the Checkout mode, you can create two types of Applications:
  • Complete Checkout: corresponds to the complete checkout mode. In addition to the general settings, you can activate the discount code functionality on your checkout, add user agreements, and add Payment Integrations.
  • Payment Only: corresponds to the payment-only mode. You can configure only the general settings and add Payment Integrations.

You can create and configure Checkout Applications through the Merchant Center, and then integrate with them by using the Checkout APIs/SDK from your code.

Checkout Applications are deployed in the same region (like Europe, America, Australia) as the commercetools Project to which they belong.

Connectors

Connectors are integrations between Checkout and third-party systems, primarily Payment Service Providers (PSP) and gift card systems. Connectors provide an abstraction layer, and handle the heavy lifting, when interacting with external payment APIs.

commercetools provides a marketplace of Public Connectors, such as Adyen, PayPal, Stripe, that you can install and use. You can also use custom (Organization) Connectors if you need your own integration; for example, to a PSP that isn't provided.

Connectors determine the Payment Integration Types and supported payment methods based on the PSP. For example, an Adyen connector can provide you with methods like credit card, Klarna, and Apple Pay, whereas a PayPal connector offers only PayPal payments.

Before setting up a Checkout Application, you must install at least one Connector.

Merchant Center Configuration

In the Merchant Center, you can manage Checkout settings, such as connecting payment providers (through Connectors) and creating Applications. An Application in this context represents a specific checkout configuration; think of it as an instance of Checkout configured for a certain context or purpose; for example, an Application for a specific brand or country.

You can create multiple Applications under one project, even combining full checkout and payment-only Applications as needed.

Browser SDK (frontend integration)

The Checkout Browser SDK lets you embed the checkout UI into your storefront. The Checkout Browser SDK, available through either an npm package or a JavaScript file, provides the methods to start the checkout process. When invoked, the SDK loads the Checkout Application's UI in either a full-screen overlay or inline within an element on your page.

Depending on the SDK method you call, you can launch the UI and flow for either the Complete Checkout or Payment Only mode.

Component relationships

The following diagram shows how Checkout components interact with each other and with your Application:

Checkout Sessions

Checkout Sessions authorize and configure individual checkout instances. You can create Sessions from your Backend for Frontend (BFF) by calling the Composable Commerce Sessions API.

A Session request requires the following:

  • An API Client access token with the manage_sessions scope
  • The Cart id or key
  • The Checkout Application id or key
The Sessions API returns a sessionId value, which you can provide to the Browser SDK when initializing the checkout flow.
Create a Checkout Session from your BFFtypescript
import fetch from "node-fetch";

async function createCheckoutSession(
  region: string,
  projectKey: string,
  token: string,
  cartId: string,
  applicationKey: string
) {
  const url = `https://session.${region}.commercetools.com/${projectKey}/sessions`;

  const body = {
    cart: {
      cartRef: {
        id: cartId,
      },
    },
    metadata: {
      applicationKey: applicationKey,
    },
  };

  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${token}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });

  if (!response.ok) {
    throw new Error(`Session creation failed: ${response.status}`);
  }

  const data = await response.json();
  return data.id; // This is the sessionId
}

Checkout workflows

The following sections describe the typical integration flows for Complete Checkout and Payment Only modes.

Complete Checkout workflow

Before initializing the Complete Checkout mode, you must make sure that a Cart exists in Composable Commerce (either an anonymous Cart or a Customer Cart). Checkout doesn't create Carts. For more information about how to prepare a Cart, see Cart preparation and review.

The following diagram shows the Complete Checkout initialization flow:

This sequence performs the following actions:

  1. Initializes the Checkout Session
  2. Associates a Customer Cart to it
  3. Specifies which Application to use for the checkout. This step, in turn, specifies the customization and localization settings that are to be used during checkout.
  4. Renders the Checkout UI directly in the browser. By default, the Checkout UI is rendered in full screen in an absolute positioned <div> element or inline to a specified <div> or <span> element.
Checkout UI displaying the shipping address form with fields for Customer information such as name, email, country selector, street address, ZIP code, city, and phone number. A summary panel on the right side shows the Cart item and total.

The Checkout UI guides the Customer to provide their shipping and billing addresses, apply discount codes, select the delivery method, and provide their payment information.

Checkout UI displaying available payment methods like credit card, PayPal, and other payment options for the Customer to select.
When the Customer completes the payment successfully, Checkout automatically creates an Order from the Cart and shows the Payment successful page.
The Payment successful page displaying the Order confirmation with a success message and Order details.

Payment Only workflow

Before initializing the Payment Only mode, make sure that the following conditions are met for the Cart:

Payment Only mode provides control over when and where the payment UI renders. Your application manages all checkout steps, except for payment capture.

The following diagram shows the Payment Only initialization flow:

This sequence performs the following actions:

  1. Initializes the Checkout Session
  2. Associates the Customer Cart to it
  3. Specifies which Application to use for the checkout, it must be of type Payment Only
  4. Renders the hosted payment UI directly in the browser (under a <div> or <span> element of your choice)
Payment Only UI displaying the Payment method selection embedded within a custom checkout flow.

Key takeaways

  • commercetools Checkout is a service that manages payment processing and checkout flows for Composable Commerce applications.
  • Checkout operates in two modes: Complete Checkout (full checkout UI and flow) and Payment Only (payment processing only).
  • Checkout Applications are configured in the Merchant Center and define the checkout behavior, localization, and payment methods.
  • Connectors integrate Checkout with Payment Service Providers like Stripe, Adyen, and PayPal without requiring custom integration code.
  • Checkout Sessions authorize individual checkout instances and are created from your BFF by using the Sessions API.
  • The Browser SDK embeds the Checkout UI in your application and handles communication with the Checkout service.
  • Complete Checkout mode requires only a Cart to exist before initialization, while Payment Only mode requires the Cart to have shipping and billing information.
  • Checkout manages PCI DSS compliance for payment data, reducing your security and compliance responsibilities.

Test your knowledge