Accept USDC payments for an API without a processor
Updated 23 November 2026 · 17 sections
You can accept USDC for an API in an afternoon without a payment processor, a merchant account or a facilitator. What you cannot skip is the verification, because the client is the party telling you it paid. This is the shape of a correct implementation, and the four places where a naive one gets robbed.
One. The quote
An unpaid request is answered with 402 and a body the caller can act on. It needs the amount, the asset, the network, the address and a nonce, plus an expiry so a stale quote cannot be paid forever.
GET /api/v2/market/listing/lst_289030db
→ 402 Payment Required
{
"accepts": [{
"amountUsd": 29.00,
"asset": "USDC",
"network": "base",
"payAddress": "0x8c24…e109",
"nonce": "nc_9f2c…",
"expiresAt": "2026-11-23T18:30:00Z"
}],
"renewalsLeft": 2
}Bind the quote to whoever is buying — a key, a session, an order token — and not just to the listing. A quote anyone can pay is a quote anyone can pay for somebody else’s order, and the seller has no way to tell which buyer got the goods.
Two. The transfer
The buyer sends an ordinary ERC-20 transfer of USDC to the quoted address and reports the transaction hash. No signature scheme, no permit, no relayer: the transfer is the payment. This is the part that makes the model portable — any wallet can pay, and no custom client is required beyond the 402 handling.
Three. The verifier
Four checks, all against the chain rather than the client’s description of it: the receipt exists with status 0x1; it contains a Transfer log emitted by the USDC contract; the recipient topic equals your address; the summed value is at least the quoted amount. Then confirm it is buried deep enough. Three confirmations on Base is seconds, and it is the difference between “the transfer is visible” and “the transfer cannot be reorganised away”.
Accept overpayment and give no change — refunding the difference is a second transaction and a second chance to be wrong. Refuse underpayment with the shortfall named, so the buyer can top up deliberately instead of guessing.
Four. The replay guard
Store the transaction hash when you accept it, and refuse any hash already used. The uniqueness must be marketplace-wide, not per order and not per buyer, or the same confirmed transfer can be submitted to a second order and deliver twice. This is the single most common bug in homegrown implementations, because it never fires in testing — only when someone tries.
if (txRefSeenBefore(hash)) return 409 conflict
txRef = hash // recorded before delivery, not after
if (confirmations < 3) return 202 pending
releaseDeliverable(order)Record the processor reference for invoice payments too. A wallet transfer is not the only rail that can be replayed against a second order.
The four things people forget
- Expiry. A quote held for thirty minutes with two renewals is generous and bounded. A quote with no expiry is an option to buy at yesterday’s price.
- Delivery order. Verify, then record, then deliver. Deliver-then-record is how a crash halfway through turns into free goods.
- The fee is not in the transfer. If you take a cut, book it against the order as gross, fee and net. Deducting from the transfer means the seller’s address receives an amount that does not match the price, and every reconciliation after that is a guess.
- Refunds are new transfers. There is no reversal. A refund is you sending money out, and the order records it as refunded without pretending the original settlement reversed.
That is the whole system: about two hundred lines, an RPC endpoint, and an address. What it does not give you is discovery — an agent has to find the URL, read the price and be able to complete the purchase unattended. That is the part this marketplace exists to solve, and where to sell an API to AI agents is the map. If you would rather publish a listing than run a verifier, open a shop.