# How do I accept Solana payments in my app?

> Accept Solana payments with Solana Pay: a reference per order, a SOL or USDC transfer, a backend check. Inside Cherry, paying takes one approval.


To accept Solana payments, use Solana Pay: give each order a unique reference key, ask the buyer's wallet for a SOL or USDC transfer that carries it, and let your backend find and validate that transaction before you deliver anything. The standard works in any web app. Inside a mini app on [Cherry.fun](https://cherry.fun/learn/features/cherry-wallet/) the buyer's wallet is already connected, so a payment takes one approval, and listing the app at [portal.cherry.fun](https://portal.cherry.fun) is free with no review queue.

The bigger win is who shows up. Cherry users fund their wallets inside the app with a card or Apple Pay before they find you, so they reach your checkout already holding SOL or USDC and approve your request on their own device.

## Transfer request, transaction request or connected wallet?

The [Solana Pay specification](https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/SPEC.md) defines two kinds of `solana:` URL. A Cherry mini app uses neither URL, but it reuses the same transfer and the same backend check.

| Flow | What the wallet receives | Good for | What you build |
|---|---|---|---|
| Transfer request | A URL with recipient, amount, optional token mint, reference, label and message; the wallet composes the transfer itself | QR codes, payment links, a checkout page | The URL or QR, plus the backend check |
| Transaction request | A URL pointing at your HTTPS endpoint; the wallet posts its address and you return any transaction | Payments that call your own program or bundle extra steps | An API endpoint that builds transactions |
| Cherry mini app | Your app builds the transfer and asks the connected Cherry wallet to sign it | Web apps whose buyers are already signed in with a wallet | The Mini App SDK, plus the backend check |

The steps below use the transfer flow. It handles a fixed price in SOL or a token, which is what most apps sell.

## What you need for Solana Pay

- A Solana wallet address you control to receive payments. Use the wallet address itself, never a token account: the wallet derives the token account from it.
- Node.js 20 or later. Version 1 of the [`@solana/pay` library](https://www.npmjs.com/package/@solana/pay) is built on `@solana/kit`.
- A backend with an orders table, even a small one.
- For the Cherry route: your web app deployed over https and the [Mini App SDK](https://portal.cherry.fun/docs/mini-apps/quickstart).

```bash
npm install @solana/pay @solana/kit @solana-program/system @solana-program/token @cherrydotfun/miniapp-sdk
```

## Step 1: Create a reference for each order

A reference is a random 32-byte key added to the payment as a read-only account. Solana validators index transactions by the accounts they touch, so the reference lets you find the payment before you know its signature. Create it on your server when the buyer starts checkout:

```ts
import { generateKeyPairSigner } from '@solana/kit';

const reference = (await generateKeyPairSigner()).address;
await db.orders.insert({ reference, item: 'level-pack', amount: 5, token: 'USDC', status: 'pending' });
```

Never reuse a reference. Check: every pending order row carries its own.

## Step 2: Pick SOL or a token

Amounts are in whole units: 0.5 means half a SOL, never lamports. To charge in a token, pass its mint address. For USDC, Circle publishes the Solana mint on its [contract addresses page](https://developers.circle.com/stablecoins/usdc-contract-addresses):

```ts
import { address } from '@solana/kit';

const recipient = address('YOUR_WALLET_ADDRESS');
const USDC_MINT = address('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
```

Keep decimals within what the token supports, 9 for SOL and 6 for USDC, or the amount is rejected as malformed. Low prices work fine, which suits small purchases like a level pack or an extra life.

## Step 3: Ask for the payment

One codebase can serve your own site and Cherry. Call `isInsideCherry()` from the Mini App SDK at runtime to pick the branch.

### On your own site: a link or QR code

```ts
import { encodeURL, createQR } from '@solana/pay';

const url = encodeURL({ recipient, amount: 5, splToken: USDC_MINT, reference, label: 'My App', message: 'Level pack' });
createQR(url).append(document.getElementById('pay-qr')!);
```

Any wallet that supports the standard can scan the code or open the link and send the transfer.

### Inside Cherry: one approval in the connected wallet

Here the buyer opened your app already signed in, wallet connected. Build the same transfer with Cherry's signer and request a signature:

```ts
import {
  address, appendTransactionMessageInstructions, compileTransaction, createSolanaRpc, createTransactionMessage,
  getBase64EncodedWireTransaction, pipe, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash,
} from '@solana/kit';
import { createTransfer } from '@solana/pay';
import { CherryMiniApp } from '@cherrydotfun/miniapp-sdk';
import { createCherrySigner } from '@cherrydotfun/miniapp-sdk/kit';
import { withTransactionLabel } from '@cherrydotfun/miniapp-sdk/solana';

const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const cherry = new CherryMiniApp();
await cherry.init();
const signer = createCherrySigner(cherry);
const instructions = await createTransfer(rpc, signer, { recipient, amount: 5, splToken: USDC_MINT, reference });
const { value: blockhash } = await rpc.getLatestBlockhash().send();

const compiled = compileTransaction(pipe(
  createTransactionMessage({ version: 0 }),
  (m) => setTransactionMessageFeePayer(address(signer.address), m),
  (m) => setTransactionMessageLifetimeUsingBlockhash(blockhash, m),
  (m) => appendTransactionMessageInstructions(instructions, m),
));
const [signed] = await withTransactionLabel('Buy the level pack', () => signer.signTransactions([compiled]));
await rpc.sendTransaction(getBase64EncodedWireTransaction(signed as unknown as typeof compiled), { encoding: 'base64' }).send();
```

Cherry's wallet sheet shows your app's name, the amount it decodes from the transaction and your label, and the buyer approves on their own device ([Wallet and limits](https://portal.cherry.fun/docs/mini-apps/wallet)). Keep the label to one plain line that matches the amount. Show no connect button and no QR code here: the [Mini App Policy](https://portal.cherry.fun/docs/mini-apps/policy) rules out other wallet connects and signing outside Cherry.

If the send call returns a transaction signature, this step is done.

## Step 4: Find the reference and validate the transfer

A signature sent by the client proves nothing on its own, and the spec tells apps to confirm a transaction before releasing goods. Check the chain from your server:

```ts
import { findReference, validateTransfer, FindReferenceError } from '@solana/pay';

try {
  const { signature } = await findReference(rpc, order.reference, { commitment: 'confirmed' });
  await validateTransfer(rpc, signature, { recipient, amount: 5, splToken: USDC_MINT, reference: order.reference });
  await db.orders.update(order.id, { status: 'paid', signature });
} catch (err) {
  if (err instanceof FindReferenceError) return 'pending'; // not on chain yet, poll again
  throw err;
}
```

Poll every second or two while the buyer waits. Inside Cherry, tie the order to the user ID from the verified launch token, because the paying wallet can change when someone picks another wallet to pay with.

Run a test purchase: the order should flip to paid exactly once, with its signature stored.

## Step 5: List the app free at portal.cherry.fun

Open the listing wizard at [portal.cherry.fun](https://portal.cherry.fun): describe the app, say who runs it, choose how it earns (sales, a commission, something else in your words, or free) and accept the terms. The wizard then writes a brief for your coding agent. You add a small domain proof file and run the automated checks and a one-minute test, and publishing lists the app immediately ([Listing and publishing](https://portal.cherry.fun/docs/mini-apps/listing)). There is no review queue.

From then on your app opens inside Cherry on iPhone, Android, the Solana Seeker and the web, so App Store, Google Play and Solana dApp Store users reach it through Cherry's own listings, with no store page or store review of yours to manage. Your audience holds wallets on Solana, BNB, Base and Robinhood Chain; payments in a mini app are Solana transactions today.

Buyers top up inside Cherry with a card, Apple Pay, Google Pay or PayPal before they open your app, so you build no on-ramp and no wallet-connect screen. You can sell items, charge for access or take a commission from the first day. Cherry asks for no fee on your sales; if the app does well, a voluntary tip is welcome.

New listings start Unverified: up to $50 per transaction and $50 per wallet per day in your app. A three-minute identity check of the project owner raises the limits to $1,000 per transaction and $5,000 per wallet per day ([Verification](https://portal.cherry.fun/docs/mini-apps/verification)).

## Solana Pay errors and fixes

- **createTransfer fails with an account-not-found error.** Your receiving wallet has no USDC token account yet. Receive a small amount of USDC once, or create the account, and retry.
- **createTransfer throws "insufficient funds".** The buyer lacks the token or the SOL. Inside Cherry, they can top up in the wallet and come back.
- **findReference never finds the payment.** Check that your RPC points at mainnet and not devnet, and that the transfer carried the same reference you stored.
- **validateTransfer fails on the amount.** The order's amount, token or recipient differs from what was paid. Compare all three with the stored order.
- **Cherry refuses with a limit error.** The price is above your trust tier. Offer a smaller amount, or verify to raise the limits.
- **The request fails because the wallet changed.** The buyer chose another wallet to pay with. Rebuild the transaction for that wallet; never resend the same bytes.

## More Solana payment guides

- [List a mini app for free](https://cherry.fun/learn/features/list-a-mini-app-for-free/): everything a Cherry listing gives a builder.
- [How to accept crypto payments in an app](https://cherry.fun/learn/guides/how-to-accept-crypto-payments/): gateways and wallet payments compared.
- [How to accept USDC payments](https://cherry.fun/learn/guides/accept-usdc-payments/): the stablecoin side in depth.
- [Vibe coding on Solana](https://cherry.fun/learn/guides/vibe-coding-solana/): hand this integration to an AI agent.
- [Do you need a crypto on-ramp?](https://cherry.fun/learn/guides/crypto-onramp/): why funding belongs in the wallet.

To try a payment as a buyer, get Cherry on [iPhone](https://apps.apple.com/app/cherry-fun-solana-messenger/id6749173799), [Android](https://play.google.com/store/apps/details?id=fun.cherry) or [the web](https://chat.cherry.fun).

## FAQ

### Does it cost anything to use Solana Pay?

Solana Pay is an open standard with an MIT-licensed JavaScript library, so there is no account to open and nothing to sign up for. The buyer's transaction pays the normal Solana network fee. If you list the app in Cherry, the listing is free too.

### Can I accept USDC with Solana Pay?

Yes. Add the token's mint address in the spl-token field, and the wallet sends that token to the associated token account of your recipient address. For USDC on Solana, Circle publishes the mint as EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v.

### How do I know a Solana payment actually arrived?

Give every order its own reference key and put it in the transfer. Your backend calls findReference to locate the transaction by that key, then validateTransfer to check the recipient, the amount and the token. Deliver only after both pass.

### Can I show a Solana Pay QR code inside a Cherry mini app?

No. Cherry's Mini App Policy says an app never asks users to connect another wallet or to sign anything outside Cherry. Inside Cherry, ask the connected wallet for the same transfer through the SDK, and keep the QR code for your standalone site.

### Do I need a transaction request instead of a transfer request?

Only if the payment has to do more than move SOL or a token, for example call your own program or bundle extra steps into one transaction. A transfer request covers a fixed price, and the wallet builds it from the URL. A transaction request points the wallet at your HTTPS endpoint, which returns the transaction to sign.

## Sources

- [Cherry Portal](https://portal.cherry.fun)
- [Cherry docs: Mini apps overview](https://portal.cherry.fun/docs/mini-apps)
- [Cherry docs: Mini-app Quickstart](https://portal.cherry.fun/docs/mini-apps/quickstart)
- [Cherry docs: Wallet and limits](https://portal.cherry.fun/docs/mini-apps/wallet)
- [Cherry docs: Listing and publishing](https://portal.cherry.fun/docs/mini-apps/listing)
- [Cherry docs: Verification](https://portal.cherry.fun/docs/mini-apps/verification)
- [Cherry docs: Mini App Policy](https://portal.cherry.fun/docs/mini-apps/policy)
- [Solana Pay specification](https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/SPEC.md)
- [@solana/pay JavaScript library](https://www.npmjs.com/package/@solana/pay)
- [Circle: USDC contract addresses](https://developers.circle.com/stablecoins/usdc-contract-addresses)

