x402 paymentsPrivate preview
Use x402 for machine-to-machine payments.
x402 is a protocol for internet payments. When a client requests a paid resource, your server returns an HTTP 402 response with payment details. The client pays, then retries the request with an authorization. Stripe handles deposit addresses and automatically captures the PaymentIntent when funds settle on-chain.
Before you begin
- A Stripe account.
- Crypto payins enabled for your account.
- Machine payments enabled for your account. Contact machine-payments@stripe.com.
Payment lifecycle
In this guide, you build the server. Your server indicates that payment is required and returns the content after successful payment. You interact with Stripe and a facilitator to complete the payment.
Create your endpoint
Add payment middleware to your endpoint to require payment.
This example requires 0.01 USD, paid in USDC, per request to /paid.
Create a PaymentIntent
To process payments, create a PaymentIntent that accepts the crypto payment method. Use the payTo method from earlier.
API version
This feature requires the 2026-03-04. API version. Set the Stripe-Version header to 2026-03-04. when initializing your Stripe client.
This function returns a crypto deposit address that the client receives and uses for payment.
The PaymentIntent response includes deposit addresses with supported_, which lists the accepted tokens and their contract addresses for each network:
{ "id": "pi_123", "amount": 5000, "currency": "usd", "status": "requires_action", "next_action": { "type": "crypto_display_details", "crypto_display_details": { "deposit_addresses": { "base": { "address": "0xbase_address", "supported_tokens": [ { "token_currency": "usdc", "token_contract_address": "0x…" } ] } } } } }
For more details on how crypto PaymentIntents work, including deposit addresses, payment lifecycle, and supported networks, see the deposit mode integration guide.
Test your endpoint
Make a request to your server without an eligible client to confirm it returns a 402 status code.
curl http://localhost:3000/paid
You see a 402 status code.
Next, make a request with an eligible client. Use Stripe’s purl to test in the command line.
Sandboxes and testnet
PaymentIntents that you create in a sandbox don’t monitor crypto testnets, so we can’t automatically detect testnet transactions that you send. To test sandbox PaymentIntents, use the test helper endpoint to simulate crypto deposits. Learn more about testing your integration.
If you connected a wallet, the server returns the content and you can confirm payment. Visit the Stripe Dashboard Payments page to see the transaction.
Alternatively, you can use curl to fetch the latest payments from the Stripe API:
curl https://api.stripe.com/v1/payment_intents?limit=10 \ -u:sk_test_BQokikJOvBiI2HlWgH4olfQ2
Run mainnet transactions
To run mainnet transactions, integrate with an x402 facilitator that supports mainnet.
See the Coinbase Developer Platform guide to use the CDP Facilitator.
Token and network support
PaymentIntents with the crypto payment method in mode: deposit support USDC on the following networks:
| Network | Token | Token contract address |
|---|---|---|
| Tempo | USDC | 0x20c000000000000000000000b9537d11c60e8b50 |
| Base | USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Solana | USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |