Why refusals need tests of their own
Payment code is usually tested on the happy path. The seller asks for a cent, the agent signs, the call returns data. That proves the plumbing. It says nothing about the moment a seller asks for ten times its usual price, or names a new address to be paid.
The x402 docs give a clear rule for one of those moments. When terms such as the scheme, network, amount, asset or payTo change, an application should re-run its payment policy checks or ask the user for approval [6]. A rule like that is only real if a test can break it. If you remove the check and every test still passes, the check was decoration.
So treat refusal as a feature. Write it down, build a seller that triggers it, and make the test fail when the agent pays.
Pick a test network that can actually settle
The x402 docs separate three kinds of support. Protocol support means x402 can describe payments on a network. Runtime support means your server can register it. Production support means you also have a facilitator path that settles there [1]. For testing you need the same thing on a test network: somewhere a payment could really be verified and settled.
The public x402.org facilitator covers several test networks, including Base Sepolia, Solana Devnet, Stellar Testnet, Aptos Testnet, Hedera Testnet and the XRPL Testnet [1]. Base Sepolia, chain eip155:84532, is the most common choice for EVM agents [1]. The docs also list Circle's Arc Testnet, eip155:5042002, with its USDC contract [1].
Use one network for the whole suite at first. Fewer moving parts make a failing test easier to read. Add a second network later, once you trust the first.
Check the token too. The x402 docs list a default USDC contract for each supported network, test networks included, so your test seller and your agent can agree on which token is real [1]. A test seller that names some other token makes a useful extra case: a good agent refuses a token it does not recognise.
Fund the test agent from official faucets
A faucet hands out free test tokens. Circle's public faucet sends 20 USDC per request, once every 2 hours for each address and each blockchain, with no account needed [2]. It covers many test networks, including Arc Testnet and Base Sepolia [2]. Circle describes a testnet as an instance of a blockchain used for testing, where developers can try apps without risking assets with real-world value [2].
Coinbase's developer faucet covers Base Sepolia, Ethereum Sepolia and Solana Devnet [3]. On the EVM test networks it gives 1 USDC per claim, up to 10 claims in 24 hours [3]. An EVM agent also needs a little ETH for gas on Base Sepolia. The Base docs list several faucets for that, and say the Coinbase one gives up to 0.1 ETH per 24 hours [4].
Give the test agent its own fresh address, separate from any key that has ever held real money. A test suite that touches a mainnet key is one typo away from a real payment. For a wider look at selling over the same protocol, read our guide to monetizing an API with x402.
Four bad sellers and what a good agent does
The price spike. The seller you have called many times now asks for far more than usual. The x402 reference client caps each payment at $1 by default [5], so a spike that stays under the cap sails through unless your agent compares the price with that seller's own history. A good agent stops and asks, or refuses outright.
The changed payout address. Same seller, same site, new payTo. This is the case the docs name directly: changed terms mean policy checks or approval again [6]. A good agent never follows a new address on its own.
The hour-long authorization. The offer sets a long maxTimeoutSeconds, so the signature it asks for would stay valid long after the call ends. A good agent shortens the window it signs, or refuses an offer that insists on a long one. The injected instruction. The seller's description contains text aimed at the model, such as a line telling it to ignore its limits. A good agent treats seller text as data and carries on with its own rules.
Add one honest seller to the set as a control. It asks a normal price, names the usual address and a short window. If the agent refuses that one too, your rules are too tight, and a real agent with those rules would be useless. A good suite proves both halves: pay the fair offer, refuse the bad ones.
What a pass looks like
For each bad seller, the passing result is simple: no signed payment left the agent. In x402, a payment starts when the client retries with the signed payload in the PAYMENT-SIGNATURE header [6]. If that header was never built, nothing could be settled. Assert on that directly. A test that only checks the agent's chat reply can pass while the signature went out anyway.
Log the reason as well. A refusal with no reason is hard to debug and impossible to audit. Name the rule that fired, such as price outlier or payout address changed, and test that the right rule fired for each seller.
Test the messy edge too. The docs say that after a payment header is sent, the outcome should be treated as unknown, and a second payment should not be created automatically [6]. A settlement_pending answer is not permission to pay again [6]. Build a seller that times out after receiving payment and check that your agent waits and reconciles rather than paying twice.
Wire the x402 test sellers into every change
Run the suite whenever the prompt, the model, the tools or the payment library changes. Agents drift. A model upgrade that makes the agent more helpful can also make it more willing to follow a seller's suggestion. The only way to know is to run x402 test sellers against the new build before it reaches real money.
Put the checks where the docs put them. In the reference client, spend controls run before any custom policy and before the payment payload is signed, and an onBeforePaymentCreation hook is the place for interactive approval, such as asking a person [5]. Code that runs after signing is too late to refuse.
Keep a short list of the sellers and the rule each one should trigger. When a real incident teaches you something new, add a seller for it. Over time the list becomes a record of every way your agent has been, or could be, fooled.
Keep the results where people can read them. A short table with each seller, the expected outcome and the actual outcome tells a reviewer more than a green tick. When a test fails, the table shows at once which rule broke and which seller broke it.
Where SpendTheBits fits
SpendTheBits runs public x402 test sellers on test networks that misbehave on purpose: a price spike, a changed payout address, an hour-long authorization and an injected instruction. Developers can point an agent at them to check it refuses. They never settle a payment, so a test cannot cost anything even if the agent fails.
To look at any seller's offer without paying, the free x402 payment scanner reads a seller's payment request without paying or signing, and gives a verdict of clear, careful or high risk with its reasons. When screening cannot be read, it says unknown, never clear.
When your agent is ready for real money, give it its own budget. In SpendTheBits an agent gets its own key, created on the phone and never derived from the seed phrase, and its spending limit is the USDC the owner puts at the agent's address. See the agents page and how to let an AI agent buy a gift card.

In the app · 3 steps
Give a tested agent a real budget in SpendTheBits
Once the agent refuses every bad seller on testnet, this is how it gets a small, separate budget.
Create the agent
Open Settings, then Agent budgets, and tap New. The agent gets its own key and only the USDC you choose to put at its address.

Set what it may buy
Turn on what the agent may pay for and set its limits, such as a per-card and a monthly limit for gift cards.

Approve what is above the line
A request above the agent's limit waits for you. Approve it on your phone or decline it.

Hold your own keys, keep the yield, skip the middleman.
SpendTheBits is a fully non-custodial wallet for 13 chains, free on iOS and Android.

