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.2.1.tar.gz (13.3 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.2.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pay402-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1c130638d4df95466121c37139bf96a869d1e8518e81e164fb509f38ac654462
MD5 9363190729add9bc007c9ac24487c5ac
BLAKE2b-256 1c194b65df008a6514d879717ed7bda57d7ddd220d261cf89b0bca254544e9b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pay402-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84f6fa9892c60f3b59b5a12710c8a47015daa53d0c5f8f5be14477c4038919ad
MD5 d5e9ca9044223025d17d323bf3d99fb4
BLAKE2b-256 409ed46928be3ee7dfb34bc744caadd5c12a5c7bda5df943427d23ff84359210

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