Checkout Events and Messages

Track, react to, and troubleshoot every step of the checkout journey.

Ask about this Page
Copy for LLM
View as Markdown

After completing this page, you should be able to:

  • Differentiate between Checkout Messages and Checkout Events.

  • Use the Checkout Browser SDK to react to in-session Messages.

  • Configure Subscriptions to consume backend events for Orders and Payments.

  • Handle both frontend and backend notifications to build observable, resilient Checkout flows.

This page explores how commercetools Checkout communicates key actions and State changes during the checkout process by using Messages and events. These mechanisms provide visibility across the entire Checkout journey from a Customer's browser to your backend systems.

Messages and events let you respond instantly to Payment or Session issues in the UI while ensuring your backend automates confirmations, ERP syncs, and Order reconciliations.

Messages and events overview

Checkout Messages provide real-time feedback that's generated inside the browser and tied to a Customer's active session. Messages include events like Payment method failures, gift card redemptions, and errors that prevent Order creation. They let you react instantly within the UI.
Checkout Events are notifications that provide real-time updates when changes occur during Order creation and Payment processing. These are published via commercetools Subscriptions for backend consumers.
Composable Commerce Messages are triggered by the Composable Commerce platform to reflect changes made to persistent entities like Products, Carts, Orders, or Payments. Use these Messages to trigger backend processes such as sending confirmation emails, syncing data to external systems, or updating analytics.
LayerToolDeliveryPurposeBest for
FrontendCheckout MessagesBrowser SDK callbacks (onInfo, onWarn, onError)Reflect real-time Session events.Real-time UI updates, user feedback, prompting user actions
BackendCheckout EventsMessage queues (like SQS and Pub/Sub)Track resource events related to Checkout Order creation and Payment processing.Checkout processes management, backend workflows, logging
BackendComposable Commerce MessagesMessage queues (like SQS and Pub/Sub)Track resource changes.Automation, logging, ERP sync

Implement Checkout Messages

Checkout Messages are short-lived signals that the Checkout Browser SDK generates. They provide real-time insights into the State of the Checkout flow, such as when the Session starts, when Payment fails, or when an Order completes.

Use Checkout Messages primarily to update the frontend UI or trigger local application logic. These messages help detect problems early, provide useful feedback to Customers, and support debugging or Customer service workflows.

Unlike Composable Commerce Messages, Checkout Messages aren't stored in the Composable Commerce platform. The platform scopes them to the Customer's active checkout Session and delivers them in-browser through event listeners.

Here's the schema of a sample Checkout Message:

{
  "severity": "info",
  "code": "order_created",
  "message": "Order {orderId} created.",
  "payload": {
    "order": {
      "id": "{orderId}"
    }
  },
  "correlationId": "spa/commercetools-checkout/1729263187262/565301612087128"
}
A good example of a useful Message is NonOrderableCartError. Checkout triggers this message if a Cart can't be converted into an Order after Payment authorization. It helps you quickly identify and resolve configuration issues, such as when the matching price for a line item can not be found.

The SDK provides the following handler callbacks:

  • onInfo: informational events (for example checkout_started, checkout_completed).
  • onWarn: non-critical warnings (for example payment_integration_not_available, deprecated_fields).
  • onError: recoverable and fatal issues (for exampleexpired_session, non_orderable_cart_error, payment_failed).
For more information about Checkout Message definitions, see the Checkout Messages reference page.

The following sample code blocks show how to wire your Checkout Message handlers in JavaScript and the Checkout Browser SDK:

Handle Checkout Messages with browser scriptts
<script>
  ctc('paymentFlow', { // Or `checkoutFlow`
    projectKey: '{projectKey}',
    region: '{region}',
    sessionId: '{sessionId}',
    locale: 'en',
    onInfo: function (evt) {
      console.log('[info]', evt.code, evt.payload);
    },
    onWarn: function (evt) {
      console.warn('[warn]', evt.code, evt.payload);
    },
    onError: async function (evt) {
      console.error('[error]', evt.code, evt.payload);
    },
    logInfo: true,
    logWarn: true,
    logError: true,
  });
</script>
Handle Checkout Messages with npm modulets
import { checkoutFlow } from '@commercetools/checkout-browser-sdk';

checkoutFlow({ // or paymentFlow
  projectKey: '{projectKey}',
  region: '{region}',
  sessionId: '{sessionId}',
  locale: '{locale}',
  onInfo: (evt) => console.log('[info]', evt.code, evt.payload),
  onWarn: (evt) => console.warn('[warn]', evt.code, evt.payload),
  onError: (evt) => console.error('[error]', evt.code, evt.payload),
  logInfo: true,
  logWarn: true,
  logError: true,
  // Other configuration properties.
});

The following list shows the recommended Checkout Messages to handle, sorted by priority:

  1. Handle session lifecycle: expired_session, failed_to_refresh_session
  2. Validate cart readiness: non_orderable_cart_error, no_shipping_methods
  3. Monitor payments: payment_failed, connector_error
  4. Handle gift cards: gift_card_redeem_error, gift_card_balance_error

Here are a few key UI actions:

  • Redirect on Order creation (checkout_completed)
  • Prompt Customers to correct shipping or address issues
  • Retry or offer alternative Payment methods

Subscribe to Checkout Events

While frontend messages provide real-time user feedback, system-level reliability comes from Checkout Events and Composable Commerce Subscriptions.
Composable Commerce triggers Checkout Events at the system level and delivers them asynchronously via Subscriptions. Use Checkout Events to trigger backend workflows such as Order confirmation emails, logging, or integrations with external systems.
When a relevant event (for example, CheckoutPaymentCharged) occurs, commercetools publishes a notification to your configured destination such as AWS SQS, Google Pub/Sub, or Azure Service Bus.
For more information about Checkout Events, see the Checkout Events page.
To subscribe to Checkout Events, create a SubscriptionDraft with the events field containing the EventTypes, and then post this SubscriptionDraft to the Create Subscription endpoint.
import { SubscriptionDraft } from '@commercetools/platform-sdk';

async function createSQSCheckoutSubscription(
  storeKey: string,
  sqsQueueUrl: string,
  sqsRegion: string,
  code: string
) {
  const draft: SubscriptionDraft = {
	key: 'orders-payments-subscription',
	destination: {
	    type: 'SQS',
	    queueURL: sqsQueueUrl
	    authenticationMode: 'IAM',
	    region: sqsRegion,
	},
  events: [
      { resourceTypeId: 'checkout',
		    types: [
		        'CheckoutPaymentRefunded',
		        'CheckoutPaymentRefundFailed',
		    ]
	    },
  ],
	messages: [
	    { resourceTypeId: 'order', types: [] }, // all order messages (e.g. OrderCreated, OrderPaymentAdded)
	    { resourceTypeId: 'payment', types: [] }, // all payment messages (transactions, state changes)
	],
  };
  return apiRoot
    .subscriptions()
    .post({ body: draft })
    .execute();
}
To subscribe to all Messages/Events under a specific resource type (for example, checkout, order, or payment Messages/Events), leave the types array empty for that resource type.

Build end-to-end Observability

Use both layers together for comprehensive control:

  • Frontend (SDK Messages): guide shoppers, recover from transient issues, and maintain real-time UI integrity.
  • Backend (Subscriptions and Events): automate post-checkout tasks and maintain consistency across systems.

Here are a couple of examples of this pairing in action:

  • Frontend reacts to checkout_completed by redirecting and confirming that the Order has been received.
  • Backend receives OrderCreated, and then triggers fulfillment and email workflows.

By combining Checkout Browser SDK Messages and backend Subscriptions, you can enable a resilient Checkout system that provides real-time visibility, immediate shopper guidance, and reliable backend synchronization across your commerce stack.

Key takeaways

  • Checkout Messages provide real-time, Session-scoped feedback through the Browser SDK for immediate UI reactions and user guidance.
  • Checkout Events are system-level notifications delivered through Subscriptions to trigger backend workflows like confirmations and integrations.
  • Composable Commerce Messages track persistent entity changes across the platform for automation and cross-system synchronization.
  • Handle frontend messages by using onInfo, onWarn, and onError callbacks to manage user experience and detect issues early.
  • Subscribe to backend events by creating Subscriptions with the Events API to automate post-checkout processes.
  • Combine both layers for end-to-end observability: frontend for immediate shopper guidance, backend for reliable workflow automation.

Test your knowledge