> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Pay as a customer

> Before writing any code, see a USDC payment from the customer's side and read the transaction it produces.

<div className="sol-stepper not-prose" data-path="checkout">
<div className="sol-stepper-nav" role="navigation" aria-label="Build a checkout · ~30 min">
<ol>
<li data-state="current"><a href="/developers/docs/payments/checkout/try-it" aria-current="step"><span className="sol-stepper-n">Step 1<span className="sol-vh">: </span></span><span className="sol-stepper-t">Pay as a customer</span></a></li>
<li data-state="todo"><a href="/developers/docs/payments/checkout/browser"><span className="sol-stepper-n">Step 2<span className="sol-vh">: </span></span><span className="sol-stepper-t">Show a payment QR code</span></a></li>
<li data-state="todo"><a href="/developers/docs/payments/checkout/backend"><span className="sol-stepper-n">Step 3<span className="sol-vh">: </span></span><span className="sol-stepper-t">Confirm from your backend</span></a></li>
<li data-state="todo"><a href="/developers/docs/payments/checkout/go-live"><span className="sol-stepper-n">Step 4<span className="sol-vh">: </span></span><span className="sol-stepper-t">Go live</span></a></li>
</ol>
</div>
</div>

A customer buys a 1 USDC sticker from a demo shop: the customer pays, the
shop's server checks the payment onchain, and only then is the order paid.
Press **Run** to step through this tutorial's code on a local test network
(Surfpool). Nothing is sent from your browser, and no real money moves.

<div className="sol-term not-prose" data-term="paths/checkout/demo" data-kind="checkout" data-steps="2" data-l-run="Run" data-l-run-step="Run step" data-l-next="Next step" data-l-all="Run all" data-l-again="Run again" data-l-running="Running…" data-l-tx="Sending transaction…" data-l-http="Requesting…" data-l-call="Running…" data-l-confirming="Confirming…" data-l-done="Done" data-l-copied="Copied" data-l-step="Step">
<div className="sol-term-head"><span className="sol-term-title">Demo Sticker Shop</span><span className="sol-term-env">Local test network (Surfpool)</span><button type="button" className="sol-term-copy" data-act="copy">Copy</button></div>
<div className="sol-term-stage" data-stage="checkout">
<div className="sol-term-item"><span className="sol-term-item-label">Holographic sticker</span><span className="sol-term-item-sub">1.00 USDC</span><span className="sol-term-pill" data-at="0" data-tone="todo">Not paid yet</span><span className="sol-term-pill" data-at="1" data-tone="info">Payment sent · not verified yet</span><span className="sol-term-pill" data-at="2" data-tone="ok" data-final="">Paid · ready to ship</span></div>
</div>
<ol className="sol-term-plan">
<li data-step="1"><span className="sol-term-plan-n" aria-hidden="true">1</span><span className="sol-term-plan-body"><strong className="sol-term-plan-title">The customer pays 1 USDC</strong> <span className="sol-term-plan-desc">The order asks for 1,000,000 base units (1 USDC) and carries a fresh reference. The customer's wallet approves one USDC transfer to the shop, and `payStore` returns the transaction's signature. The shop hasn't checked anything yet.</span></span></li>
<li data-step="2"><span className="sol-term-plan-n" aria-hidden="true">2</span><span className="sol-term-plan-body"><strong className="sol-term-plan-title">The shop's server verifies the payment</strong> <span className="sol-term-plan-desc">The checkout sends the signature to the shop's server. The server fetches that transaction from the network and checks that it succeeded, carries the order's reference, and moved exactly 1 USDC of the USDC mint into the shop's account. Only then is the order paid.</span></span></li>
</ol>
<div className="sol-term-screen" role="region" tabIndex="0" aria-label="Demo Sticker Shop: Output">
<div className="sol-term-step" data-step="1" data-pending="tx">
<div className="sol-term-row sol-term-note">\# Step 1/2 · The customer pays 1 USDC</div>
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> order</div>
<div className="sol-term-row sol-term-ln">\{</div>
<div className="sol-term-row sol-term-ln" data-indent="2"><span className="sol-term-k">id\:</span> `'order-1001',`</div>
<div className="sol-term-row sol-term-ln" data-indent="2"><span className="sol-term-k">storeOwner\:</span> `'`<span className="sol-h" title="DVxMtF9M6EAQ8CjqH9omYUTXdJU7hu4M8G94udRyr1m6"><span className="sol-h-f">DVxMtF9M6EAQ8CjqH9omYUTXdJU7hu4M8G94udRyr1m6</span><span className="sol-h-s" aria-hidden="true">DVxM…r1m6</span></span>`',`</div>
<div className="sol-term-row sol-term-ln" data-indent="2"><span className="sol-term-k">amount\:</span> 1000000n,</div>
<div className="sol-term-row sol-term-ln" data-indent="2"><span className="sol-term-k">reference\:</span> `'`<span className="sol-h" title="47venn787GZLWUcgUU3QM1CpT11JHQMs8hyYQMPXKN2W"><span className="sol-h-f">47venn787GZLWUcgUU3QM1CpT11JHQMs8hyYQMPXKN2W</span><span className="sol-h-s" aria-hidden="true">47ve…KN2W</span></span>`'`</div>
<div className="sol-term-row sol-term-ln">\}</div>
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> const signature = await payStore(customer, order)</div>
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> signature</div>
<div className="sol-term-row sol-term-ln">`'`<span className="sol-h" title="paxK3zbseZEZpGrmGrzm3p3VYF5XN6aTAGKS1sVt2CmkcJ2afLCTB5C84rFT8VFX6LboNFty2pzcTCiVJw5DAtJ"><span className="sol-h-f">paxK3zbseZEZpGrmGrzm3p3VYF5XN6aTAGKS1sVt2CmkcJ2afLCTB5C84rFT8VFX6LboNFty2pzcTCiVJw5DAtJ</span><span className="sol-h-s" aria-hidden="true">paxK…DAtJ</span></span>`'`</div>
<div className="sol-term-result"><span className="sol-term-badge" data-tone="info">Payment sent · not verified yet</span></div>
</div>
<div className="sol-term-step" data-step="2" data-pending="call">
<div className="sol-term-row sol-term-note">\# Step 2/2 · The shop's server verifies the payment</div>
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> `await verifyPayment({ ...order, signature, mint: USDC_MINT })`</div>
<div className="sol-term-row sol-term-ln" data-tone="ok">\{ paid\: true \}</div>
<div className="sol-term-result"><span className="sol-term-badge" data-tone="ok">Verified\: amount, mint, recipient, and reference</span></div>
</div>
</div>
<div className="sol-term-success"><span className="sol-term-success-icon" aria-hidden="true">✓</span><span>Verified. The shop's server confirmed that 1 USDC for order-1001 reached the shop, so the order can ship.</span></div>
<div className="sol-term-foot"><button type="button" className="sol-term-btn" data-act="run">Run step 1</button><button type="button" className="sol-term-btn" data-act="all" data-variant="secondary">Run all</button><span className="sol-term-status"></span><span className="sol-term-sr" role="status"></span></div>
</div>

That's the whole customer experience: one approval, and the payment settles in
under a second. The same code runs on
<span className="sol-chip" data-concept="clusters"><Tooltip headline="Devnet & mainnet" tip="Devnet is a free public test network that behaves like the real one (mainnet), with play money. Same code, different URL." cta="Learn more" href="/developers/docs/references/clusters">devnet</Tooltip><span className="nojs-only"> ([Devnet & mainnet](/developers/docs/references/clusters): Devnet is a free public test network that behaves like the real one (mainnet), with play money. Same code, different URL.)</span></span> and on mainnet;
only the URL and the USDC address change.

<div className="sol-concept not-prose">
[<span className="sol-concept-name">Wallets & signatures</span> <span className="sol-concept-def">A wallet holds a key pair: a public address that anyone can pay, and a private key that signs approvals and never leaves the device.</span>](/developers/docs/core/wallets)
</div>

## What just happened

Step 1 is the customer's side. The order and the approval became a
transaction:

- **`amount: 1000000n`.** USDC has 6 decimals, so 1 USDC is 1,000,000 base
  units. Code always works in base units.
- **`storeOwner`.** The shop's wallet. The USDC goes to the shop's USDC account
  for that wallet.
- **`reference`.** A fresh address created for this order and attached to the
  transfer. The shop uses it to tell which order a payment is for.
- **`signature`.** The transaction's ID, which `payStore` returns once the
  network has confirmed the transfer. The checkout hands it to the shop's
  server.

The network fee for this transfer was 5,000 lamports (0.000005 SOL), paid by
the customer's wallet. [Go live](/developers/docs/payments/checkout/go-live) shows how
your app can pay it instead.

The money has moved, but the order isn't paid until the shop checks. Step 2 is
the shop's side: its server looks the transaction up by its signature and
returns `{ paid: true }` only if it succeeded, carries the order's reference,
and moved exactly 1 USDC of the USDC mint into the shop's account. The shop
goes by the network's record, not the customer's word.

<div className="sol-concept not-prose">
[<span className="sol-concept-name">Transactions</span> <span className="sol-concept-def">A transaction is a signed request to change the shared ledger.</span>](/developers/docs/core/transactions)
</div>

The 1 USDC did not move between the two wallets directly. It moved from the
customer's USDC account to the shop's USDC account:

<div className="sol-concept not-prose">
[<span className="sol-concept-name">Token accounts</span> <span className="sol-concept-def">Wallets don't hold tokens directly.</span>](/developers/docs/tokens/basics/create-token-account)
</div>

## What a wrong amount looks like

The same check refuses a payment that doesn't match the order. Here the 1 USDC
payment from above is checked against an order that costs 2 USDC:

<div className="sol-term not-prose" data-term="paths/checkout/checks" data-kind="checkout" data-steps="1" data-l-run="Run" data-l-run-step="Run step" data-l-next="Next step" data-l-all="Run all" data-l-again="Run again" data-l-running="Running…" data-l-tx="Sending transaction…" data-l-http="Requesting…" data-l-call="Running…" data-l-confirming="Confirming…" data-l-done="Done" data-l-copied="Copied" data-l-step="Step">
<div className="sol-term-head"><span className="sol-term-title">What a wrong amount looks like</span><span className="sol-term-env">Local test network (Surfpool)</span><button type="button" className="sol-term-copy" data-act="copy">Copy</button></div>
<div className="sol-term-screen" role="region" tabIndex="0" aria-label="What a wrong amount looks like: Output">
<div className="sol-term-step" data-step="1" data-pending="call">
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> `await verifyPayment({ ...order, amount: 2_000_000n, signature, mint: USDC_MINT })`</div>
<div className="sol-term-row sol-term-ln">\{</div>
<div className="sol-term-row sol-term-ln" data-tone="error" data-indent="2"><span className="sol-term-k">paid\:</span> false,</div>
<div className="sol-term-row sol-term-ln" data-tone="error" data-indent="2"><span className="sol-term-k">reason\:</span> `'amount mismatch: expected 2000000, received 1000000'`</div>
<div className="sol-term-row sol-term-ln">\}</div>
<div className="sol-term-result"><span className="sol-term-badge" data-tone="error">Refused\: amount mismatch</span></div>
</div>
</div>
<div className="sol-term-foot"><button type="button" className="sol-term-btn" data-act="run">Run</button><span className="sol-term-status"></span><span className="sol-term-sr" role="status"></span></div>
</div>

The shop doesn't ship. [Step 3](/developers/docs/payments/checkout/backend) builds the endpoint that runs
this check, and also refuses a signature that was already used for another
order.

## See it on mainnet

To watch real USDC transfers settle on mainnet, open
[USDC in Solana Explorer](https://explorer.solana.com/address/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v).
