Skip to main content

Checkout for agents

Checkout in the Universal Commerce Protocol (UCP) enables buyers to complete purchases after product discovery. Agents can facilitate the checkout process, and even carry out the complete transaction on behalf of the buyer.

If the checkout requires buyer actions that aren't supported over MCP, the agent can open web checkout in any browser, or present it using Checkout Kit or Embedded Checkout Protocol for a native, embedded checkout experience.


After product discovery, your AI agent needs to transition buyers through the checkout flow. How you handle checkout depends on how much control your agent needs over the process:

  • Checkout MCP: Provides tools for creating and managing checkout sessions programmatically. Use this when your agent needs to track status, handle errors, update checkout details, or support complex multi-step flows. Checkout MCP requires authentication via JWT tokens.
  • Cart permalinks: URLs that take buyers directly to a merchant's checkout with pre-selected items. The Catalog returns a checkoutUrl for each product that you can open directly or embed in your application for simpler flows.

Anchor to Checkout sessions with MCPCheckout sessions with MCP

The Checkout MCP server implements UCP's checkout capability through these tools:

  • create_checkout: Initiates a new checkout session with line items and buyer information.
  • update_checkout: Modifies items, fulfillment options, or buyer information to resolve missing data.
  • complete_checkout: Finalizes the checkout and places the order.

Together, these tools enable a status-driven workflow where your agent iteratively builds the checkout until it's ready for completion:

  1. Create a checkout session with line items and buyer information
  2. Update the checkout to resolve any missing information, or escalate to a trusted UI for buyer input
  3. Complete the checkout when status reaches ready_for_complete

Anchor to Status-driven workflowStatus-driven workflow

After each tool call, check the status field to determine what action is required next:

StatusAction
incompleteRead messages array and call update_checkout to provide missing data.
requires_escalationRedirect buyer to continue_url for trusted UI input.
ready_for_completeCall complete_checkout to finalize the order.
complete_in_progressWait; merchant is processing the request.
completedOrder placed successfully.
canceledSession expired. Start a new checkout.

Anchor to Resolving incomplete statusResolving incomplete status

When status is incomplete, the messages array tells you what's missing (shipping address, contact information, or other required fields). Each message includes a severity field that indicates whether your agent can resolve it:

SeverityMeaningAgent action
recoverableAgent can fix via API.Call update_checkout with the missing data.
requires_buyer_inputMerchant requires input not available via API.Messages include actions for buyer to take, such as MERCHANDISE_NOT_AVAILABLE. Agent should surface error to direct buyer to choose another item.

Resolve all recoverable errors before initiating buyer handoff. After you've addressed the issues, the next response returns an updated status.

Anchor to Resolving escalationsResolving escalations

When status reaches requires_escalation, the checkout requires buyer input that can't be collected via API (for example, a business critical Checkout UI extension implemented by the merchant for age verification).

The response includes a continue_url that points to where buyers can complete these steps securely. You have two options for rendering this interaction:

  • In-app browser: Open the continue_url directly in a browser or web view. This is the simplest approach.
  • Embedded Checkout Protocol and Checkout Kit: Embed the checkout UI in your application and handle events like address changes and payment credential requests programmatically. This provides more control over the checkout experience. See the Checkout Kit reference and the ECP specification for protocol details.

Either approach ensures:

  • Security: Payment credentials are never exposed to agents.
  • Determinism: Given the same inputs, the merchant returns the same outputs.
  • Buyer control: The buyer always reviews and authorizes the final transaction.

Anchor to Completing the checkoutCompleting the checkout

When status reaches ready_for_complete, call complete_checkout to finalize the order. The response includes status completed when the order is placed successfully.

Payment handlers enable "N-to-N" interoperability between platforms, businesses, and payment providers. Rather than building custom integrations for each payment method, agents and merchants can work with standardized handler specifications that define how payments are configured, discovered, and processed.

When a checkout reaches ready_for_complete, the payment.handlers array in the response tells your agent which payment methods the merchant accepts. Agents can use this information to present appropriate payment options or delegate credential collection to a handler-specific flow.

For a complete framework on building and integrating payment handlers, see the UCP Payment Handler Guide.

Shop Pay (dev.shopify.shop_pay) is Shopify's native payment handler that provides accelerated checkout by securely storing buyer payment and shipping information. Agents can orchestrate Shop Pay payments through a delegated flow that collects payment authorization from buyers and returns a token for processing.


Anchor to Embed with Checkout KitEmbed with Checkout Kit

Checkout Kit embeds the purchase flow directly in your application. Buyers stay within your application from product discovery through payment completion. The kit provides native SDKs and a web component for handling presentation, lifecycle events, and authentication.


Cart permalinks are URLs that take buyers directly to a merchant's checkout with pre-selected items. Use this for simpler flows where you just need to redirect buyers to complete their purchase, rather than managing checkout sessions programmatically with Checkout MCP.

The Catalog returns a checkoutUrl for each product that you can open directly or embed in your application when calling the get_global_product_details tool.

Anchor to Get the checkout URLGet the checkout URL

When you call get_global_product_details, the Catalog MCP server returns a checkoutUrl in the response. This is a cart permalink that takes buyers to the merchant's checkout with the product variant they selected.

{
"product": {
"products": [{
"checkoutUrl": "https://example.myshopify.com/cart/70881412:1?_gsid=abc123&payment=shop_pay",
"selectedProductVariant": {
"id": "gid://shopify/ProductVariant/70881412"
}
}]
}
}

The URL includes tracking parameters for conversion attribution. You can append additional parameters to prefill buyer information, apply discounts, or add custom tracking data.

Anchor to Redirect to checkoutRedirect to checkout

Open the checkoutUrl to redirect buyers to the merchant's checkout. You can open the URL in a new tab to keep your agent interface available:

const checkoutUrl = productResponse.product.products[0].checkoutUrl;
window.open(checkoutUrl, "_blank");

Anchor to Handle multiple merchantsHandle multiple merchants

The Catalog can return products from multiple merchants in a single search. Cart permalinks work for products from a single merchant only. When your agent returns products from different merchants, create separate checkout URLs for each:

const productsByShop = {};
selectedProducts.forEach(product => {
const shopDomain = new URL(product.shop.onlineStoreUrl).hostname;
if (!productsByShop[shopDomain]) {
productsByShop[shopDomain] = [];
}
productsByShop[shopDomain].push(product);
});

Object.entries(productsByShop).forEach(([shopDomain, products]) => {
const variantIds = products.map(p => {
const id = p.selectedProductVariant.id.split('/').pop();
return `${id}:1`;
}).join(',');
const checkoutUrl = `https://${shopDomain}/cart/${variantIds}`;
console.log(`Checkout for ${shopDomain}: ${checkoutUrl}`);
});


Was this page helpful?