Download the PHP package koh/sylius-x402 without Composer

On this page you can find all versions of the php package koh/sylius-x402. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-x402

koh/sylius-x402

x402 payment middleware for Sylius: selected API paths answer 402 Payment Required with a machine-readable price that an agent can pay and retry.

It is off by default. Installing the bundle must not start charging for anything, and even when switched on it ships no settlement: the bundled verifier advertises prices and refuses every payment until you plug in a real one. That makes a shop protocol-correct and discoverable long before anyone decides to accept stablecoins.

Install

koh/sylius-agent-contracts comes with it. There is no route to import — the bundle works as request and response listeners.

Configure

Settling payments

Alias PaymentVerifierInterface to your own implementation:

verify() checks the PAYMENT-SIGNATURE header (a base64-encoded x402 v2 PaymentPayload) against the requirement and throws PaymentRequiredException when it is missing or invalid. settle() runs only after the controller produced a 2xx response — a request that ends in an error has delivered nothing and is not charged. A settlement failure at that point is logged and does not change the response; the caller already has what they paid for. A string returned from settle() — the base64-encoded SettlementResponse — is sent as PAYMENT-RESPONSE.

Letting authenticated agents through

Implement PaymentBypassVoterInterface from koh/sylius-agent-contracts to exempt callers, for example agents holding an MCP access token. The listener runs at priority 5, after the Symfony firewall (8), so the security token exists when voters are asked. Base the decision on that token, never on a request header the caller controls.

Output

The bundle speaks x402 protocol version 2 over HTTP (specs/x402-specification-v2.md, specs/transports-v2/http.md). A gated request without a valid payment gets the PaymentRequired object base64-encoded in the PAYMENT-REQUIRED header, and the same object as the JSON body:

A 402 is never cached: the requirement is per request, and a cached challenge would keep answering after payment.

The same price table feeds PayableOperationProviderInterface, under the rail x402. That is not an MPP payment method, so koh/sylius-mpp does not declare these operations as MPP x-payment-info offers; the 402 above is where an x402 client learns the price. While enabled is false nothing is published at all.

Decommission

Set enabled: false first if agents may be mid-payment, and settle anything outstanding in your verifier. Then remove the composer require, the config/bundles.php entry, config/packages/koh_x402.yaml and any verifier alias. The bundle owns no database table and no cache pool.

Security

Report vulnerabilities privately — see SECURITY.md. Advisories are published as CSAF 2.0 at https://ole-hartwig.eu/.well-known/csaf/.

The family threat model, covering this package, is at https://github.com/ohartwig/sylius-agent-ready/blob/main/docs/threat-model.md.

Licence

MIT — see LICENSE.


All versions of sylius-x402 with dependencies

PHP Build Version
Package Version
Requires koh/sylius-agent-contracts Version ^1.1
php Version ^8.3
psr/log Version ^2.0 || ^3.0
sylius/sylius Version ^2.2.9 || ^2.3.0
symfony/config Version ^7.4 || ^8.0
symfony/dependency-injection Version ^7.4 || ^8.0
symfony/event-dispatcher Version ^7.4 || ^8.0
symfony/http-foundation Version ^7.4 || ^8.0
symfony/http-kernel Version ^7.4 || ^8.0
symfony/routing Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package koh/sylius-x402 contains the following files

Loading the files please wait ...