Download the PHP package johnguoy/laravel-x402 without Composer
On this page you can find all versions of the php package johnguoy/laravel-x402. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johnguoy/laravel-x402
More information about johnguoy/laravel-x402
Files in johnguoy/laravel-x402
Package laravel-x402
Short Description Laravel SDK for the x402 V2 HTTP payment protocol. Charge AI agents and API clients per request using USDC stablecoins over HTTP.
License MIT
Homepage https://github.com/johnguoy/laravel-x402
Informations about the package laravel-x402
laravel-x402
laravel-x402 is a Laravel SDK for the x402 V2 HTTP payment protocol. Protect any API route with a single middleware line and start collecting USDC micropayments from AI agents and developer clients — no accounts, no API keys, no subscriptions.
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 | ^12.0 | ^13.0 |
| BCMath extension | enabled (standard in PHP 8.x) |
Installation
Laravel's package auto-discovery will register the service provider and X402 facade automatically.
Publish the config file
This creates config/x402.php in your application where you configure your wallet, networks, and facilitators.
Configuration
Open config/x402.php (or set environment variables in .env):
Minimal .env for development (testnet)
Minimal .env for production (Base Mainnet)
Usage
1. Protect a route with the x402 middleware
Middleware parameter order:
All parameters after price are optional and fall back to config values.
2. What clients receive
Step 1 — request without payment (402 response):
Step 2 — request with payment signature (200 response):
3. Use the Facade for advanced scenarios
4. Use PaymentAmount for precision math
Networks & Facilitators
Supported Networks (CAIP-2)
| Network | CAIP-2 |
|---|---|
| Base Mainnet | eip155:8453 |
| Base Sepolia (testnet) | eip155:84532 |
| Ethereum Mainnet | eip155:1 |
| Polygon Mainnet | eip155:137 |
| Avalanche C-Chain | eip155:43114 |
| Solana Mainnet | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp |
| Solana Devnet | solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 |
Known Production Facilitators
| Key | URL | Notes |
|---|---|---|
coinbase |
https://facilitator.cdp.coinbase.com |
KYT/OFAC checks |
cloudflare |
https://x402.cloudflare.com |
Edge-native |
stellar |
https://facilitator.stellar.org |
Stellar network only |
dexter |
https://facilitator.dexter.cash |
Free, no account |
mogami |
https://facilitator.mogami.tech |
Free, Base focused |
testnet |
https://x402.org/facilitator |
Dev/testnet only |
Testing
Run only unit or feature tests:
Changelog
See CHANGELOG.md.
License
MIT — see LICENSE.md.
Credits
- Built on the x402 V2 open specification — a Linux Foundation project
- Protocol co-founded by Coinbase and Cloudflare
All versions of laravel-x402 with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/routing Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8