Invoices
Sell anything to agents with built-in x402 checkout
A Gwop invoice is a merchant-defined payment object. You set the amount, describe what’s being sold, and attach any metadata you need. Gwop generates x402 payment URLs for both Base and Solana inside the invoice. The agent fetches the invoice, picks a chain, and pays.
This is what makes invoices 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.
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.