Get Invoice

Get the full public invoice view with payment methods and status
View as Markdown

Get an invoice

Fetch the public checkout view by publicInvoiceId. This endpoint requires no authentication — it’s designed to be called by agents or shared with payers.

1import { Gwop } from "@gwop/sdk";
2
3const gwop = new Gwop({
4 merchantApiKey: process.env.GWOP_MERCHANT_API_KEY,
5});
6
7const { result: invoice } = await gwop.invoices.get({
8 id: "inv_21bd059c2ad849efb2112437f5284e1e",
9});
10
11console.log(invoice.status); // "OPEN"
12console.log(invoice.amount.display); // "1.025 USDC"
13console.log(invoice.paymentMethods); // [{id: "x402-base", ...}, ...]
14console.log(invoice.merchant.name); // "agentrouter"
15console.log(invoice.statusCheck.url); // Polling URL

Response (OPEN invoice)

1{
2 "schemaVersion": "gwop.invoice.v4",
3 "id": "inv_21bd059c2ad849efb2112437f5284e1e",
4 "status": "OPEN",
5 "amount": {
6 "value": 1025000,
7 "display": "1.025 USDC",
8 "currency": "USDC",
9 "decimals": 6
10 },
11 "pricing": {
12 "baseAmount": 1000000,
13 "gwopFee": 25000,
14 "total": 1025000
15 },
16 "description": "Get test invoice",
17 "expiresAt": "2026-03-25T02:06:43.328Z",
18 "createdAt": "2026-03-25T01:51:43.402Z",
19 "merchant": {
20 "name": "agentrouter",
21 "verified": true
22 },
23 "statusCheck": {
24 "url": "https://agents.gwop.io/v1/invoices/inv_21bd059c...",
25 "method": "GET",
26 "field": "status",
27 "paidValue": "PAID",
28 "hint": "Check status before retrying payment."
29 },
30 "links": {
31 "landingPage": "https://gwop.io",
32 "docs": "https://docs.gwop.io"
33 },
34 "paymentMethods": ["..."]
35}

Payment Methods

Open invoices include paymentMethods — the available rails for payment. Each method includes everything an agent needs to pay:

1{
2 "id": "x402-base",
3 "kind": "x402",
4 "network": "eip155:8453",
5 "chain": "base",
6 "asset": {
7 "symbol": "USDC",
8 "decimals": 6,
9 "contract": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
10 },
11 "payTo": "0xcFf8Dcf2e9562Ec4D77E387902BB52Ea18539215",
12 "amount": 1025000,
13 "amountDisplay": "1.025 USDC",
14 "paymentUrl": "https://agents.gwop.io/v1/invoices/inv_.../x402/base",
15 "recoverUrl": "https://agents.gwop.io/v1/invoices/inv_.../x402/base/recover"
16}
FieldDescription
idUnique method identifier (x402-base, x402-solana)
kindPayment protocol (x402)
networkCAIP-2 chain identifier
chainHuman-readable chain name (base, solana)
assetToken details — symbol, decimals, contract address
payToDestination wallet address
amountAmount in atomic units (same as invoice total)
paymentUrlx402 payment endpoint — the agent POSTs here
recoverUrlRecovery endpoint if payment was sent but not confirmed

Currently all invoices support both Base (EVM) and Solana payment rails. The agent chooses which chain to pay on.

Pricing Breakdown

The public invoice includes a transparent fee breakdown:

FieldDescription
pricing.baseAmountThe amount you requested
pricing.gwopFeeGwop’s processing fee
pricing.totalTotal the payer sends (= amount.value)

Status Check

The statusCheck object tells agents how to poll for payment confirmation:

1// Agent-side polling pattern
2const checkUrl = invoice.statusCheck.url;
3const paidValue = invoice.statusCheck.paidValue; // "PAID"
4
5const poll = async () => {
6 const res = await fetch(checkUrl);
7 const data = await res.json();
8 return data[invoice.statusCheck.field] === paidValue;
9};

After payment, the invoice gains settlement fields and loses paymentMethods:

1const { result: paid } = await gwop.invoices.get({ id: "inv_..." });
2
3paid.status; // "PAID"
4paid.paidAt; // Date — settlement timestamp
5paid.paidAmount; // 5125000 — amount settled
6paid.paymentChain; // "base" or "solana"
7paid.paymentChainCaip2; // "eip155:8453"
8paid.paidTxHash; // "0xcd2688e1..." — on-chain tx hash
9paid.txUrl; // "https://basescan.org/tx/0xcd2688e1..."
10paid.paymentMethods; // undefined — no longer payable

paymentMethods is only present on OPEN invoices. Once an invoice is paid, expired, or canceled, this field is undefined.

Error: Invoice not found

1import * as errors from "@gwop/sdk/models/errors";
2
3try {
4 await gwop.invoices.get({ id: "inv_doesnotexist" });
5} catch (err) {
6 if (err instanceof errors.ErrorResponse) {
7 err.data$.error.code; // "INVOICE_NOT_FOUND"
8 err.data$.error.message; // "Invoice not found"
9 err.statusCode; // 404
10 }
11}

Next step