Security and trust

What keeps the shopper and the merchant safe when an assistant sits in front of a checkout: where credentials live, why the model never touches a payment page, what the processor's own record is, and what a platform agent can and cannot do.

The model never sees a payment page or a credential

The safety property that matters most in Anthropic's Claude Commerce Agents blueprint is structural. The model has no tool that takes a card number, a wallet token or a bank account, and it has no tool that charges. Its one write is to the cart. When the assistant calls checkout, the server creates the processor session and attaches the URL to the card after the model's call has returned, so the URL is in the event the browser renders and in no request body the model receives. tests/test_checkout_handoff_turn.py proves it on a full search, add and checkout turn, and tests/test_runtime_agnostic.py proves it on the model-agnostic loop, where the executor is the same object.

The tender card follows the same rule. present_tender_options (commerce_core/tender.py) lets the model add a note of at most 200 characters; every reward, split, balance and points figure comes from the gateway for that cart. The tender-and-loyalty skill tells the assistant to state none of the figures in its text. It also tells the assistant to ask for no card numbers, bank details or one-time codes, and to repeat back none that a customer pastes. The hosted page says it plainly: the assistant that staged the checkout never sees this page and cannot press these buttons.

A second gate protects the merchant's systems from the model. Every cart write must name a product id that a catalog or order tool returned in this conversation; test_cart_write_needs_provenance shows an invented id refused before the backend or the gateway sees it. Tool results are fenced and labeled as data. Identity is bound at session start; no tool argument names a user.

Credentials live in the process environment

Processor keys and the model key are read from the environment and nowhere else. Each platform folder has a .env.example with empty values and a comment naming where each value comes from; the real file is platforms/<platform>/.env, which .gitignore excludes (.env), and platforms/_lib/common.sh::load_env exports it into the process that starts a demo. Nothing writes a key to disk. The adapters read their variables through env() in psp_commerce/adapters/_base.py and raise MissingCredentials when one is absent, which verticals/registry.py::gateway_for turns into the simulated gateway. GATEWAY_MODE=simulated forces simulation even when keys are present, and GET /api/brand reports gateway_mode so nobody mistakes a demo for a live run, or a live run for a demo.

scripts/record_platform_agent.py, which records a Claude Code session for the documentation, starts recording only after the credential dialog is gone and refuses to render a frame that contains any fragment matching sk-ant-, sk_test_, sk_live_, rk_test_ or rk_live_. The run scripts write their logs to /tmp/commerce-agents-<merchant>.log; those logs carry URLs and ids, and a key that was exported into the shell is never printed by the scripts.

The return leg, and why the processor's status is the record

After a shopper pays on a live processor's page, three sources could claim the payment happened: the browser coming back, the storefront's poll, and the processor. The reference treats only the processor's own read or its signed webhook as the record.

On Stripe, GET /checkout/return?session_id=… makes the adapter call GET /checkout/sessions/{id} and record the order only when Stripe reports payment_status: paid (psp_commerce/adapters/stripe.py::get_checkout_session). A shopper who reaches the return page without paying sees "Payment not finished" and no order is recorded (tests/test_demo_paths.py::test_return_leg_notifies_the_assistant_once).

On Adyen, a session can only be read with the sessionResult Adyen appends to the return URL; without it the read fails with error 29_004, found on the live run of 7 September 2026. The return route hands the value to record_session_result, and only then does get_checkout_session call GET /sessions/{id}?sessionResult=. A stale or forged sessionResult is Adyen's to reject; on an error the adapter drops it and leaves the session as it was. In production Adyen's AUTHORISATION webhook is the record of truth either way.

psp_commerce/webhooks.py mounts POST /webhooks/stripe and POST /webhooks/adyen. The Stripe verifier recomputes the HMAC-SHA256 over <timestamp>.<raw body> with the endpoint secret, compares it in constant time to the v1 value in Stripe-Signature, and rejects a timestamp more than 300 seconds away. The Adyen verifier recomputes hmacSignature over the documented colon-joined notification fields with the hex-decoded HMAC key, per item. A route answers 503 when its secret (STRIPE_WEBHOOK_SECRET, ADYEN_HMAC_KEY) is not set and 404 when the deployment runs the simulated gateway. A verified event records the transaction or dispute on the adapter's ledger and queues the same note to the assistant that the return page queues. tests/test_adapters_http.py::test_webhook_verifiers covers a valid signature and a tampered one. The Worldpay, CyberSource and Clover verifiers are not implemented in this repository; each adapter names its notification format in its endpoints["webhook"] entry.

The note itself is queued once per session, whichever route sees the payment first (install_hosted_checkout keeps a set of notified session ids). The assistant learns of the order the way it learns of any event outside the conversation: as an app event delivered on its next turn. It never reads the payment page.

What a platform agent can and cannot do

A platform agent reaches a merchant here through the Universal Commerce Protocol (UCP) over the Model Context Protocol (MCP), or through the Agentic Commerce Protocol (ACP). It can search the catalog, build a cart, create a checkout and read its status. Creating a checkout stages a session with the processor and answers with continue_url; the shopper pays on the processor's page and the agent learns the outcome from get_checkout. The platform MCP server in commerce_core/mcp_server.py is narrower still: its create_checkout_session returns a URL and says in its own result that the agent cannot pay.

Paying without a redirect needs a credential the processor accepts. complete_checkout (UCP) and POST /acp/checkout_sessions/{id}/complete (ACP) pass the instrument to authorize_delegated, and each real adapter declares which providers it can charge: Stripe accepts a shared payment token and a Google Pay gateway payload, Adyen a Google Pay payload, Worldpay a delegate token and a Google Pay payload, CyberSource a Visa Intelligent Commerce credential and a Google Pay payload, and Clover none. Anything else raises DelegatedCredentialUnsupported, which the endpoints answer as payment_handler_unsupported with the redirect path named. The simulated gateway enforces the same list: MockGateway.delegated_providers_for reads the real adapter's declaration, so a simulated Adyen merchant refuses a Stripe token exactly as the live one would (tests/test_thirdparty.py::test_ucp_refuses_a_credential_the_processor_cannot_charge). On live Stripe on 6 September 2026 a placeholder token drew "No such shared_payment_token", which is the correct outcome: a real token needs enrolment with Stripe and a platform to mint it.

Every transaction a platform completes carries agent_id and a truncated credential on the record, so a merchant answering a dispute can say which agent paid and with what.

Agent profiles on Shopify stores

Shopify's stores require every tools/call on their UCP endpoint to carry meta.ucp-agent.profile, a URL naming the agent's profile and capabilities; Shopify publishes one for its 2026-04-08 capability set, and scripts/platform_agent.py sends it on every call. This was confirmed against the public demo store fakestore-ai.myshopify.com on 8 September 2026. The reference's own merchants accept any caller and ignore the key. A production deployment of these endpoints should read the profile, verify it, and rate-limit and log by it; the code does not do that today.

A public endpoint and the rate of abuse

The merchant APIs here have no authentication. That is fine on localhost, where every run script keeps them, and it is the reason commerce_core/mcp_server.py refuses to bind to anything other than loopback unless MCP_UNSAFE_ALLOW_NO_AUTH=1 says an authenticating gateway is in front. Putting a tunnel in front of a merchant API to show a remote platform agent changes the picture: anyone who finds the address can read the catalog and the feed, create carts, and stage checkouts. On a live adapter each staged checkout is a real session in the processor's test environment, visible in its dashboard, and each ACP session creates one too.

For a demo through a tunnel, keep the window short, watch the processor's dashboard, and take the tunnel down afterwards. Sessions expire (fifteen minutes on the simulated gateway; the processor's own expiry on a live adapter). For anything longer than a demo, put an authenticating gateway in front, rate-limit create_checkout, create_cart and /acp/checkout_sessions by caller, and set the ACP bearer key: AcpService accepts an api_key and answers 401 without it, though verticals/_host.py does not wire one today.

Rolling keys after a demo

A key that has passed through a chat, a screenshot, a recording or a shared terminal should be rolled when the demo is over, test-mode keys included. The reference never needs a key stored anywhere except the process environment or the ignored .env file, so rolling one means replacing that value and restarting the run script. Each processor's dashboard issues a new key; follow the processor's own instructions for revoking the old one.

What this reference does not do

Being honest about the gaps is part of trust. The merchant API has no authentication or CSRF protection; the demo's identity is a fixed demo user bound at session start; the simulated pages accept any tender without collecting details; the merchant-owned checkout pages skip card entry (a real page collects it with the processor's tokenizer); webhook verification exists for Stripe and Adyen only; the ACP bearer key is available in the service and not wired by the host; and the agent profile on the UCP endpoint is accepted without verification. Each is named here so a team taking this to production knows where to start.