Introducing a new way to review your PRs.

Read the announcement

solana-foundation / pay

CLI for Agentic payments (x402, MPP, AP2).

View on GitHub

30 documents · Updated Nov 11, 2026

docs / solana-pay-merchant-examples

Solana Pay merchant examples

The Solana Pay merchant examples show how a seller turns an order into a wallet payment request, presents that request to a customer, finds the resulting transaction, and confirms that the payment matches the order. They cover both an in-person point-of-sale journey and a small end-to-end merchant flow.

For the wider SDK model, read TypeScript Solana Pay SDK. For the meaning of transfer fields and references, read Solana Pay transfer primitives.

Example scope

The examples separate merchant work from customer wallet work. The merchant creates payment intent and reads Solana state. The wallet presents the request, gets customer approval, signs the transaction, and sends it.

Example roles

The point-of-sale example is a browser checkout for in-person payments. It lets a cashier set an amount, shows a QR code, and gives the customer a visible payment progress state. The payment-flow merchant example is a small command-line sequence that makes the same roles clear without a full user interface.

ExampleMain journeyPayment observation
Point of saleCashier amount entry to QR scan and payment completionClient polling for the payment and confirmation state
Payment-flow merchantMerchant request to simulated wallet payment and order completionWebSocket reference watch followed by transfer validation

References: typescript/…/README.md• L1-5 typescript/…/NewPage.tsx• L12-51 typescript/…/main.ts• L6-24

Payment request paths

The point-of-sale app can publish a direct transfer request or a transaction request. A transfer request puts the payment fields in the Solana Pay URL. A transaction request puts a merchant HTTPS endpoint in the URL so the wallet can ask the merchant for a transaction built for the customer account.

The app uses the direct transfer path by default. Its configuration can switch to the transaction-request path, while the payment-flow merchant example demonstrates the direct transfer path.

References: typescript/…/App.tsx• L41-46 typescript/…/README.md• L119-139 typescript/…/main.ts• L32-36

Point-of-sale journey

The point-of-sale app presents a cashier-facing payment station. The order amount and merchant settings enter through the page URL, while the app creates a fresh reference for each payment session and carries the payment data through its client state.

Checkout setup

The app starts with a recipient and store label in the page query. It uses the configured network and asset display settings to show the balance due. The cashier enters an amount and starts a new payment session.

Each session receives a new reference address. The reference connects the displayed request to the later transaction search, so it must belong to one checkout rather than to the store as a whole.

References: typescript/…/App.tsx• L33-74 typescript/…/ConfigProvider.tsx• L6-35 typescript/…/PaymentProvider.tsx• L46-65 typescript/…/PaymentProvider.tsx• L111-128

Customer checkout

The pending screen shows the amount and a QR code for the current request. The customer scans the code with a Solana Pay wallet and approves the payment there. The app can also connect a browser wallet when that mode is enabled.

The QR code changes when the request changes. It can represent either the direct transfer fields or the merchant endpoint for a transaction request. This keeps the customer journey the same while allowing the merchant to choose how the transaction is made.

References: typescript/…/PendingPage.tsx• L12-55 typescript/…/QRCode.tsx• L18-31 typescript/…/PaymentProvider.tsx• L67-109

Payment state

The client keeps the active amount, memo, reference, signature, confirmation count, and request URL in one payment context. The status moves from a new checkout to an observed transaction, then to a validated payment and final completion.

StateMeaning for the user journey
NewThe station is ready for an amount and a new request.
PendingThe request is displayed and the wallet payment is not yet found.
ConfirmedA transaction with the session reference is found.
ValidThe transaction matches the expected payment.
InvalidThe observed transaction does not pass payment checks.
FinalizedThe valid transaction has reached the required confirmation level.

The page route follows the first three user-visible stages. The confirmed screen then shows progress as the transaction gains confirmations. A reset clears the session and returns the station to a new checkout.

References: typescript/…/usePayment.ts• L5-27 typescript/…/PaymentProvider.tsx• L193-285 typescript/…/ConfirmedPage.tsx• L10-29 typescript/…/Progress.tsx• L14-44

Wallet handoff

When a connected wallet is enabled, the client reads the current request and asks the wallet to sign and send the payment. In the normal QR journey, an external wallet performs this step instead. Both paths produce a transaction that carries the session reference.

For a direct transfer request, the wallet creates the transfer from the request fields. For a transaction request, it first asks the merchant API for a transaction and then signs the returned transaction. The merchant does not need the customer’s signing key.

References: typescript/…/PaymentProvider.tsx• L130-191 typescript/…/index.ts• L68-99 typescript/…/simulateWalletInteraction.ts• L7-45

Payment observation

The app treats transaction observation as a separate step from transaction validation. Finding a signature shows that a transaction mentions the checkout reference. Validation decides whether that transaction paid the right recipient with the right asset and amount.

Active payment tracking

While a checkout is pending, the point-of-sale client searches for a transaction that mentions its reference. After it finds a signature, it checks the transaction against the configured recipient, amount, token, and reference. It retries when the transaction record is not yet ready, but it marks the payment invalid for other validation errors.

After validation succeeds, the client tracks the signature status until the configured confirmation count is reached or Solana reports finalization. This prevents the screen from treating mere reference discovery as proof that the order was paid.

References: typescript/…/PaymentProvider.tsx• L193-285 typescript/…/usePayment.ts• L14-27 typescript/…/validateTransfer.ts• L107-154

Recent transaction tracking

The transactions screen gives the merchant a short history of payments received by the configured recipient. For token payments, it tracks the recipient’s associated token account. For SOL payments, it tracks the recipient address.

The provider refreshes recent signatures and then loads their transaction details and confirmation status. It keeps only incoming transfers that match the configured asset and recipient, then shows the amount, signature, time, error, status, and confirmation count. This history is a monitoring view; it does not replace the active checkout validation step.

References: typescript/…/TransactionsProvider.tsx• L34-101 typescript/…/TransactionsProvider.tsx• L103-220 typescript/…/Transactions.tsx• L10-58

Merchant server API

The point-of-sale server API supports the transaction-request variant of the checkout. It gives a wallet store metadata on GET and returns a customer-specific serialized transaction on POST.

Request metadata

The GET endpoint accepts the store label and returns that label with an icon URL based on the current host. A wallet can use this response to present the merchant identity before the customer approves a request.

The API applies cross-origin handling and a basic IP rate limit before it dispatches the request. The example defaults to a small request window and allows deployment settings to change those limits.

References: typescript/…/index.ts• L17-33 typescript/…/index.ts• L102-109 typescript/…/cors.ts• L1-4 typescript/…/rateLimit.ts• L5-13

Transaction response

The POST endpoint receives the customer account in the request body. It also receives the recipient, amount, optional token mint, reference, memo, and message from the request query. It uses those values to create the payment instructions, assigns the customer account as the fee payer, and returns a base64 transaction for the wallet to sign.

The message is returned with the transaction as display context. The wallet remains responsible for customer approval and signing. The merchant service supplies the transaction shape but does not sign for the customer.

References: typescript/…/index.ts• L35-99 typescript/…/PaymentProvider.tsx• L137-176 typescript/…/fetchTransaction.ts• L37-77

Server boundary

The endpoint checks that request values have the expected basic types and address form. The example then builds a payment from those request values. A real merchant service should connect them to a trusted order record before it returns a transaction, so a caller cannot change the amount or destination by changing the URL.

The server reads the Solana cluster from its environment and defaults to devnet. The client example also uses devnet settings. Network and asset settings must agree across the request, the API, the wallet, and the tracking view.

References: typescript/…/index.ts• L40-80 typescript/…/env.ts• L1-3 typescript/…/connection.ts• L1-4 typescript/…/constants.ts• L4-15

Payment-flow merchant sequence

The payment-flow merchant example compresses the full checkout into a single runnable sequence. It is useful as a mental model for the order of trust decisions in a merchant integration.

Merchant observation

The merchant client connects to RPC and subscription services without a signer. Checkout data creates a label, message, memo, amount, and one reference. The merchant encodes these values with its recipient into a Solana Pay URL.

The simulated wallet parses that URL, creates the requested transfer, and sends it as the customer. In a real checkout, a wallet provider performs this interaction. The merchant then watches the reference through a WebSocket subscription and receives a candidate signature.

References: typescript/…/main.ts• L10-57 typescript/…/simulateCheckout.ts• L4-25 typescript/…/simulateWalletInteraction.ts• L18-45 typescript/…/watchReference.ts• L24-73

Order completion

The merchant validates the candidate signature against the expected recipient and amount. Only a successful validation leads to the example’s order-completion action. This distinction matters because a reference watcher reports a matching transaction even when the transaction later proves failed or does not transfer the expected value.

The example uses a local validator endpoint and a test customer key. These values exist to make the flow runnable. They are not a model for holding customer keys or for choosing a production network.

References: typescript/…/main.ts• L47-85 typescript/…/constants.ts• L1-12 typescript/…/validateTransfer.ts• L117-154

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the payment state transitions aligned with the observation order. A signature must not move a checkout to completion before transfer validation and the required confirmation rule.
  • Keep the reference and expected order data linked across QR generation, wallet payment, server transaction creation, and merchant validation. A mismatch can produce a valid chain transaction for the wrong checkout.
  • Keep SOL and token settings aligned across the client display, server request, wallet transfer, recipient account lookup, and recent transaction filters.
  • Keep the transaction-request response contract stable. Changes to the customer account input or serialized transaction output affect wallet approval and signing.
  • Keep the server network and client tracking network the same. A payment on another cluster will appear to be missing.
  • Keep the recent-transaction filters consistent with the configured recipient and token account. A change can hide incoming payments without causing an RPC error.

Important failure modes

TriggerConsequenceGuard
A checkout reuses a referenceThe merchant can find a transaction from another sessionCreate one reference for each checkout and bind it to the trusted order record
The client accepts a found signature as paymentA failed or wrong transfer can appear paidRun transfer validation before order completion
The transaction-request API trusts amount or recipient query valuesA caller can request a transaction for altered payment termsResolve payment terms from a trusted server-side order
Client and server use different clusters or token settingsThe wallet may send a payment that tracking cannot findShare one network and asset configuration across the flow
The transaction is still unavailable after signature discoveryValidation reports a temporary missing recordRetry the lookup until the selected commitment exposes transaction data
A customer wallet lacks funds or a token accountInstruction creation or transaction submission failsCheck wallet funding and token account readiness before approval
Recent history watches the wrong recipient token accountIncoming token payments are absent from the transaction listDerive and track the account for the configured recipient and mint

Key files

FileWhy to read it
typescript/…/README.mdExplains the point-of-sale example’s user journey, devnet setup, and transaction-request option.
typescript/…/PaymentProvider.tsxDefines active payment data, request creation, wallet handoff, discovery, validation, and finality tracking.
typescript/…/TransactionsProvider.tsxDefines the separate recent-payment history and its recipient or token-account filters.
typescript/…/NewPage.tsxShows the amount-entry starting point for the cashier journey.
typescript/…/PendingPage.tsxShows the QR handoff and customer approval step.
typescript/…/ConfirmedPage.tsxShows the post-discovery confirmation progress screen.
typescript/…/index.tsDefines the merchant metadata and transaction-request API.
typescript/…/env.tsDefines the server’s network and rate-limit inputs.
typescript/…/main.tsRuns the compact merchant request, wallet payment, reference watch, and validation sequence.
typescript/…/simulateWalletInteraction.tsShows the wallet-side interpretation of the merchant URL and transaction submission.
typescript/…/merchant.tsDefines the merchant-facing SDK actions used by the end-to-end example.
typescript/…/watchReference.tsDefines real-time reference observation for the merchant flow.
typescript/…/validateTransfer.tsDefines the checks that separate a matching signature from an accepted payment.