Invoices
Agent checkout — sell anything to agents with built-in x402 payment rails
In Gwop, an invoice and a checkout are the same thing. invoices.create() opens an agent checkout — a headless payment session with x402 rails for every supported chain. The docs use both terms interchangeably: “invoice” when talking about the API primitive, “agent checkout” when talking about what the agent experiences.
You set the amount, describe what you are selling, and attach any metadata you need. Gwop generates the checkout session with x402 payment URLs for both Base and Solana. The agent fetches it, picks a chain, and pays.
This is what makes agent checkout powerful: you control the commercial terms, Gwop handles settlement. Instead of per-request micropayments tied to a single endpoint, you create an explicit commercial moment — a credit pack, a subscription, a dataset, whatever your product needs — and let the agent buy it over x402.
How it works
- You define the product and price — your backend creates an invoice with an amount, description, and expiry. Gwop returns an
inv_*identifier and generates x402 payment URLs for Base and Solana inside it. - You hand the invoice to the agent — pass the
publicInvoiceId. The agent fetches the invoice, discovers the available payment methods, and chooses a chain. - The agent pays via x402 — the agent hits the x402 payment URL for their preferred chain. Gwop verifies the transaction on-chain.
- Gwop fires a webhook — your endpoint receives
invoice.paidwith the transaction hash, chain, and payer wallet. - Your backend fulfills — grant credits, activate a plan, unlock access. The sale is complete.
After fulfillment, you have a customer with a wallet identity, a purchase record, and whatever entitlements your app granted. That is the foundation for recurring revenue — the agent can come back, authenticate with the same wallet, and pick up where it left off.
The code
Invoice lifecycle
Every invoice moves through a deterministic state machine:
Transitions are one-way. A paid invoice cannot be canceled, and an expired invoice cannot be reopened. Create a new invoice if needed.
What you can sell
Because you control the amount, description, metadata, and fulfillment logic, invoices are a general-purpose commercial primitive. You can sell anything:
- Prepaid credits — sell a credit pack, deduct on usage
- Subscriptions and plans — charge monthly, enforce tier limits
- One-time purchases — reports, datasets, API packages, premium features
- Usage-based billing — invoice for accumulated usage at intervals
- Any digital good — if you can define a price and fulfillment, you can sell it to an agent
Invoices decouple payment from usage. Instead of micro-charging every API call, you charge upfront and let interactions flow without a payment wall on every request. This is how software is actually sold.
Multichain
Every invoice contains x402 payment URLs for both Base (EVM) and Solana. When the agent fetches the invoice, it sees payment methods for both chains and chooses which to use. No configuration required on your end — Gwop generates the rails for both chains automatically.