Kai Ole Hartwig

sylius-x402 — off by default, and only on data routes.

The middleware answers a data route with HTTP 402 and the payment requirements an agent can meet. After installation it is switched off, and it never touches the storefront, the checkout or the discovery documents. Billing happens after the response, and only for a successful one.

Installing a bundle must not start charging money.

That is why the middleware is off by default. A default that demands payment after composer require turns an update into an outage for every client that could access the routes free of charge until then. If you want to switch x402 on, you should have to decide that — route by route.

The middleware never touches the storefront, never the checkout and never the discovery documents. A 402 on a /.well-known/ document would contradict itself: the agent would have to pay in order to learn how it can pay. And a 402 in the checkout hits people for whom that response contains no way forward.

Billing happens after the response, and only if it was successful. A request that ends in a 500 has delivered nothing — billing before that charges for a result that does not exist. The default verifier advertises prices correctly without money moving or a wallet key existing: you can check the price presentation end to end before connecting a payment path.

Off by default, billing after a successful response

Sylius: 2.0+ · PHP: 8.2+ · Licence: MIT · Version: 1.0.0

Source code & documentation

Composer package

MIT · Sylius 2.0+ · PHP 8.2+

composer require koh/sylius-x402

Built, tested and released under MIT. Public distribution via Packagist is being prepared (coming soon).

Part of the family

MIT

This package belongs to koh/sylius-agent-ready — seventeen bundles that make a Sylius shop usable for AI agents. Each one can be used on its own.

To the overview
Part of the family