Skip to content

Feat/x402 implementation#11

Open
notorious-d-e-v wants to merge 10 commits intovisa:mainfrom
notorious-d-e-v:feat/x402-implementation
Open

Feat/x402 implementation#11
notorious-d-e-v wants to merge 10 commits intovisa:mainfrom
notorious-d-e-v:feat/x402-implementation

Conversation

@notorious-d-e-v
Copy link

Add x402 payment integration (USDC on Solana and Base)

Adds a machine-to-machine x402 payment flow as an alternative to the
existing browser-based credit card checkout.

The merchant backend serves HTTP 402 responses with payment requirements, and agents sign and settle
USDC payments on-chain via a facilitator.

  • Add x402 setup module with server initialization and settlement logic
  • Rewrite x402 checkout endpoint
  • Add wallet setup scripts for merchant and agent
  • Add Solana ATA creation script
  • Add x402 checkout UI to TAP agent Streamlit app
  • Add x402 header logging to CDN proxy
  • Update README with setup, facilitator, and production docs
  • Add *.db and .env to .gitignore

Tested end-to-end on Solana devnet and Base Sepolia testnet.

Demo

x402-checkout-demo-compressed_1_3x_with_groovesalad_soft.mp4

Adds a machine-to-machine x402 payment flow as an alternative to the
existing browser-based credit card checkout. The merchant backend serves
HTTP 402 responses with payment requirements, and agents sign and settle
USDC payments on-chain via a facilitator.

- Add x402 setup module with server initialization and settlement logic
- Rewrite x402 checkout endpoint as two-mode (402 → sign → 200) flow
- Add wallet setup scripts for merchant and agent
- Add Solana ATA creation script
- Add x402 checkout UI to TAP agent Streamlit app
- Add x402 header logging to CDN proxy
- Update README with setup, facilitator, and production docs
- Add *.db and .env to .gitignore

Tested end-to-end on Solana devnet and Base Sepolia testnet.
Capture and decode the base64-encoded PAYMENT-RESPONSE header returned
by the merchant after settlement, showing the facilitator receipt in the
Streamlit UI.
The payment requirements are already encoded in the PAYMENT-REQUIRED
header per the x402 spec. No need to duplicate them in the JSON body.
Add five low-cost digital products ($0.01-$0.50) to the sample data
seed script, suitable for testing x402 payments with small amounts of
testnet USDC.
Change x402 checkout to use CDN_PROXY_URL (localhost:3001) instead of
hitting the merchant backend directly, aligning with the TAP architecture
where all agent traffic flows through the CDN proxy.
Users hitting a ValueError on quickstart because RSA/Ed25519 keys
weren't configured. This adds a one-command setup script and updates
the README quickstart with the new step.
Auto-seed the database (including digital products for x402) when the
merchant backend starts, so users don't need to run create_sample_data.py
manually. Also removes the stale merchant.db that was committed despite
.gitignore, and cleans up setup_keys.py output.
- setup_x402.py: orchestrates wallet generation, ATA creation, and
  polls for SOL/USDC funding with in-place terminal updates
- Wallet scripts now prompt before overwriting existing private keys
- Remove redundant next-steps output from sub-scripts since the
  orchestrator handles user guidance
- Only poll USDC for agent wallets (merchants receive payments)
- Improve x402 testing instructions in README
The database and sample data are now created automatically when the
server starts, so remove the manual create_sample_data.py step from
the setup instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant