Search by

webmaster-ramos / module-agent-checkout-handoff

webmaster-ramos

Hands a cart that an AI shopping agent built over GraphQL back to the shopper's browser and opens Magento checkout with it. The agent's backend asks a GraphQL mutation for a single-use, short-lived link; opening it attaches the cart to the browser session (replace or merge, guest or signed-in custom

Package info

github.com/webmaster-ramos/magento2-agent-checkout-handoff

Homepage

Documentation

Type:magento2-module

pkg:composer/webmaster-ramos/module-agent-checkout-handoff

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

1.0.0 2026-11-18 10:26 UTC

This package is auto-updated.

Last update: 2026-11-18 12:59:55 UTC


README

Hand an AI shopping agent's cart back to the shopper's browser and open Magento checkout with it – on Luma and Hyvä, for guest and customer carts, with a single-use link that expires in minutes.

Why this exists

A shopping agent – a chat assistant, a voice assistant, an agent platform – builds a cart for the shopper over Magento's GraphQL API. To pay, the shopper has to continue in their own browser, with that cart. Magento has no storefront route for that:

  • The checkout only shows the cart of the browser's own session. A cart built over GraphQL belongs to no browser session.
  • The masked cart ID cannot simply travel in a link. It is a bearer credential: whoever holds it can keep changing the cart – items, addresses – while the shopper is checking out.

This module closes that gap. The agent's backend asks for a short-lived, single-use link; the shopper opens it and lands in checkout with the agent's cart, and the agent's cart ID stops working at that moment.

How it works

  1. The agent's backend calls the GraphQL mutation createAgentCheckoutHandoff with the cart ID and receives a link and its expiry time.
  2. The agent gives the link to the shopper – in the chat, by message.
  3. The shopper opens https://<store>/agentcheckout/handoff/open/t/<token>/. The module attaches the cart to the browser – guest or signed in, replacing or merging a cart the browser already has – gives a guest cart a new cart ID so the old one is dead, and redirects to checkout.

Features

  • Single-use, short-lived links. A link works once and expires after 1 to 60 minutes (15 by default). Issuing a new link for a cart revokes the cart's earlier unused link.
  • The agent's cart ID dies at handoff. When a guest cart is opened, it gets a fresh masked ID; the one the agent (or anyone it was leaked to) holds stops working, so nobody can change the cart behind the shopper's back.
  • Every browser state handled. Guest or signed in, an existing cart in the browser, guest checkout switched off, a customer's own cart, a shopper Magento remembers but who is not signed in – see What the shopper sees.
  • Same authorization as any cart operation. The mutation uses Magento's own cart access check: a guest cart needs a guest request, a customer cart needs that customer's token.
  • Nothing to probe, nothing cached. Every refusal shows the same message; the redirect is sent with no-store, no-referrer and noindex headers.
  • Only a hash is stored. The token itself is never saved; expired links are purged by an hourly cron job.
  • Per store view. Enable it, set the link lifetime and the cart policy for each store view separately.

Requirements

  • Adobe Commerce or Magento Open Source 2.4.7 – 2.4.9
  • PHP 8.2 – 8.5. PHP 8.2 reaches the end of security support on 2026-12-31.
  • Storefronts: Luma, Hyvä Theme (with native Magento checkout)
  • The storefront served over HTTPS
  • Magento cron running, for the hourly purge of expired links

Installation

composer require webmaster-ramos/module-agent-checkout-handoff
bin/magento module:enable WebRamos_AgentCheckoutHandoff
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Configuration

Stores > Configuration > Webmaster Ramos > Agent Checkout Handoff

Field Scope Default What it does
Enabled store view No Off: the mutation refuses and the link answers 404 for this store view.
Link Lifetime (minutes) store view 15 How long a new link can be opened: a whole number from 1 to 60. A link works once.
Shopper's Own Cart store view Replace it with the agent's cart Applies only when a guest shopper's browser already holds a non-empty cart of its own. "Replace it with the agent's cart" sets the browser's cart aside; "Merge the agent's cart into it" adds the agent's items to it. A signed-in shopper's cart is always merged.

The foot of the section shows the Webmaster Ramos support links and the module version – include that line when you contact support.

Usage

Issuing a link (the agent's backend)

Build the cart over GraphQL as usual, then call the mutation from your server, not from a browser:

mutation {
  createAgentCheckoutHandoff(input: { cart_id: "<masked cart id>" }) {
    url
    expires_at
  }
}
{
  "data": {
    "createAgentCheckoutHandoff": {
      "url": "https://shop.example.com/agentcheckout/handoff/open/t/3Qe…/",
      "expires_at": "2026-10-27T12:15:00Z"
    }
  }
}
  • Send the Store: <store view code> header for any store view other than the default one. The link is built for that store view's own host, and the cart is moved to it as for any cart operation (within the same website).
  • For a customer cart, send Authorization: Bearer <customer token>, as for any operation on that cart.
  • expires_at is ISO 8601 in UTC.

The mutation refuses with a GraphQL error when:

Message extensions.reason Cause
Agent checkout handoff is not enabled for this store. disabled Enabled is No for the request's store view.
The cart is empty. empty_cart Add at least one item first.
Agent checkout handoff needs the store front to be served over HTTPS. insecure The store view's secure base URL is not https://.
Required parameter "cart_id" is missing. – Empty cart_id.
Magento's own cart errors ("Could not find a cart with ID …", "The cart isn't active.", "The current user cannot perform operations on cart …") – Unknown cart, a cart already ordered, or a cart the request may not use: a customer cart without its customer's token or with another customer's, or a guest cart called with a customer token.

The message is translated for the store view; extensions.reason is not. Branch on the reason, not on the message. It is set, next to extensions.category graphql-input, exactly when the extension refused the cart; Magento's own errors carry none. Treat a value not listed here as a refusal that a retry will not fix.

A link that cannot be stored (a database fault) is not a refusal: the mutation answers Magento's Internal server error with no category, and the cause is logged in var/log/exception.log. It is safe to call it again.

After the shopper opens the link, a guest cart's ID no longer works – do not keep editing that cart. A customer cart keeps its ID; access to it is the customer's token, not the ID.

What the shopper sees

The link holds The browser Result Link
a guest cart a guest with no cart of their own Checkout with the agent's cart used
a guest cart a guest with a cart of their own Checkout; that cart is replaced or merged, per Shopper's Own Cart used
a guest cart a signed-in shopper Checkout; the items are merged into the shopper's account cart, as at any sign-in used
a guest cart guest checkout is switched off Sign-in page with "Sign in to place the order. Your cart is ready."; after sign-in, checkout with the cart used
a guest cart a shopper Magento remembers (Persistent Shopping Cart) who is not signed in Sign-in page; after sign-in the link continues kept
a customer's cart that customer, signed in Checkout with the cart used
a customer's cart not signed in Sign-in page with "Sign in to continue to checkout with your cart."; after sign-in, checkout kept
a customer's cart another customer, signed in Refused kept

Every refusal – an expired, used, unknown or malformed link, a link for another store view, a cart that is empty or already ordered – sends the shopper to the cart page with one message: "This checkout link is invalid or has expired." The agent can issue a new link.

Luma's and Hyvä's minicart show the agent's cart on the first page after the link, without a reload.

Security

  • 256-bit random tokens; only their SHA-256 hash is stored.
  • One use per link; the lifetime is capped at 60 minutes.
  • A link opens only on the store view it was issued for, and only over HTTPS.
  • The redirect goes to fixed storefront pages; nothing in the link can steer it elsewhere.
  • Cache-Control: no-store, Referrer-Policy: no-referrer and X-Robots-Tag: noindex, nofollow on every response of the link.
  • Treat the link like a password reset link: send it to the shopper only. Whoever opens it first gets the cart's contents – items and prices; no payment details are in a cart.

Data

Table webramos_agent_checkout_handoff: the token hash, the cart, store view and customer IDs, and three timestamps (created, expires, used). No names, addresses or payment data. Rows are deleted by the cron job webramos_agent_checkout_handoff_purge 24 hours after they expire, and with their cart, customer or store view.

Uninstallation

bin/magento module:disable WebRamos_AgentCheckoutHandoff
bin/magento setup:upgrade
bin/magento cache:flush
composer remove webmaster-ramos/module-agent-checkout-handoff

The configuration values stay in core_config_data (webramos_agent_checkout_handoff/*).

Notes and limitations

  • Headless and PWA storefronts keep the cart ID in the browser's local storage and need their own handoff; this module covers Luma and Hyvä.
  • Hyvä Checkout (the Magewire checkout) has not been tested; Hyvä stores using the native Magento checkout are covered.
  • GraphQL only; there is no REST endpoint.
  • The module issues and opens links. It does not build carts, and it does not talk to any agent platform itself.

Links

Changelog

See CHANGELOG.md.

Support

contact@webmaster-ramos.com

License

Open Software License 3.0 – see LICENSE.txt. Free.