Skip to main content

pay402

Buy anything behind an HTTP 402. No account, no API key, no browser.

Both rails are proven on mainnet, with this code, verified against the chain rather than against anyone's database:

buyer seller fee wallet splitter
Base −$0.02005 +$0.01 +$0.01005 kept nothing
Solana −$0.02005 +$0.01 +$0.01005 n/a — no splitter

On both, the buyer held no native gas token: on Base the relayer submits the EIP-3009 authorization, on Solana it signs as fee payer. The interface may still move before 1.0.

pip install "pay402[evm]"
pay402 https://api.checkout402.com/c/chk_abc123 --quote
pay402 https://api.checkout402.com/c/chk_abc123 --key $PAY402_KEY --max-usd 1.00
from pay402 import pay
goods = pay(url, private_key=os.environ["AGENT_KEY"], max_usd="1.00")

Reads the 402 challenge, picks a chain it can sign for, signs, retries with X-PAYMENT, and hands back the goods plus a receipt. Base (EIP-3009) and Solana (SPL) today.

Guardrails

max_usd is required for a live payment. An agent looping on a paid endpoint with no ceiling is the failure mode that matters, so the default is refusal rather than a permissive setting someone forgets to override. Nothing is signed until the quoted total has passed the cap.

On Solana the payee builds the transaction and you sign it, so pay402 decodes it and refuses unless it does exactly what the 402 advertised: two transfers, to the quoted wallets, for the quoted amounts, out of your token account and no other, with no third program involved. Non-custodial should mean more than "they cannot hold your funds".

If you paid and the goods did not arrive, the error carries the receipt id — the one thing you need to get it resolved.

Rehearse first

Every checkout has a test face — the same URL plus /test — where settlement is simulated: no chain, no funds, synthetic tx hash. Same call, two swaps:

pay(url + "/test", test_payer="0xAnyAddress")   # instead of a private key

The shapes are identical to a live payment, so code proven on the test face runs unchanged against the bare URL.

Extras

pay402[evm] for Base, pay402[solana] for Solana, pay402[all] for both. The base install is httpx only, so an agent sandbox will accept it.

MIT. Source: https://github.com/bitfent/checkout402

Release files for pay402 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pay402 0.4.0
File Size Uploaded
pay402-0.4.0.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pay402 0.4.0
File Interpreter ABI Platform
pay402-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / pay402-0.4.0.tar.gz

Download URL pay402-0.4.0.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7bce28b8b3cee07463ed3b9219c60b63aaa1e24e1755f25b40c8d47ab643a600
BLAKE2b-256 checksum
How to use checksums
83c6862c87f08aaeb9f3743c6e6221f2e6a502a385b275811967b1e28e41905b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / pay402-0.4.0-py3-none-any.whl

Download URL pay402-0.4.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dad639b32e6826a8acfb6bab2ddd1876ad85ea63809c55e66a2ba146aa6809b2
BLAKE2b-256 checksum
How to use checksums
670dd5f740f3b65183ec2bf36cfee9b47ede12c099389853aa680ae4a9d8c62a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page