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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pay402-0.3.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pay402-0.3.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pay402-0.3.0.tar.gz.

File metadata

  • Download URL: pay402-0.3.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pay402-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f15c08040e882ea19394126d85f90e07f575ab87bc7b630cf699fcc6700e4280
MD5 ecdc5ff643206ec04feb70e93ecd24be
BLAKE2b-256 6e8fb25b9d935553f53b8178379915cda0327954169655ed5c8b5c062c8249e6

See more details on using hashes here.

File details

Details for the file pay402-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pay402-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pay402-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efe2302d76064f84f69e1e0b4ebe652008ad6fb44bd4827f22a8b48fab0ae5a4
MD5 487b4fb5daf46953a44436b5f6d2e61d
BLAKE2b-256 9880f4e681e73e0f4b192a61c388a42129e461a3758a237924d659949d0b0611

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page