---
id: I0018
title: "Shopify Solana Pay orders"
url: https://carbium.sh/library/integrate/shopify-solana-pay-orders
collection: Integrations
category: Commerce and billing
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Shopify Solana Pay orders

A Node checker takes the reference address of a Solana Pay link and the mint, finds the paying transaction on Carbium RPC at finalized commitment, and prints how much your wallet received. Your Shopify service then marks the order paid.

## How an order moves

Shopify and Solana Pay never talk to each other here. A small service of yours sits between them and does the gluing. The part that needs the chain is the one worth getting right: given the reference address of one order, find the transaction that paid it and say how much your wallet received.

1. A customer checks out with a manual payment method that you named after Solana Pay. Shopify creates the order with payment pending and sends your service an `orders/create` webhook.
2. Your service makes a fresh address for the order, the reference, and builds a Solana Pay link: `solana:<wallet>?amount=<amount>&spl-token=<mint>&reference=<reference>`. It shows the link as a QR code on a page or in the order email.
3. The customer's wallet sends the transfer and lists the reference as an extra read-only account in it.
4. The checker finds that transaction through the reference and confirms that your wallet gained at least the amount of the mint.
5. Your service calls Shopify's Admin API to mark the order paid.

Only step 4 is in `main.ts`. Steps 1, 2 and 5 need a Shopify access token and your own web host.

## What the checker reads on Solana

The reference is an address that nobody owns. A wallet that follows Solana Pay puts it in the transfer as a read-only account, so `getSignaturesForAddress` on the reference lists the payment. The checker asks for the newest five signatures of the reference, drops any that failed, and fetches each remaining one with `getTransaction`.

Finding the reference proves little by itself, because any transaction can list any address. The proof is in the balances in the transaction metadata. For each owner, the checker adds up the change in the token balance of your mint from before the transaction to after it, and compares your wallet's gain with the minimum. Summing by owner wallet handles two facts: a wallet can own more than one token account for one mint, and a token transfer to an existing token account lists the token accounts and the sender's authority, never the receiving wallet. The balance entries in the metadata carry the owner.

Amounts are raw units. USDC has 6 decimals, so 24.99 USDC is `24990000`. The Solana Pay link takes the decimal amount and the checker takes the raw one.

Both reads name `finalized`. A shop releases goods once, and a finalized payment cannot be undone.

`getTransaction` is called with `maxSupportedTransactionVersion: 1`. Mainnet carries [v1 transactions](https://carbium.sh/docs#rpc), and with that field absent or 0 Carbium answers -32015, uncharged, for one of them.

## The Shopify side

In the Shopify admin, add a manual payment method in the payment settings and name it for Solana Pay. Orders paid that way start with payment pending, which gives your service something to complete. Menu names move, so check Shopify's current help pages for the exact path.

Subscribe to `orders/create` and verify each delivery with the `X-Shopify-Hmac-Sha256` header before you trust the body. Shopify can deliver a webhook more than once, so key your own table on the order id. Keep one row per order.

| Field | Why it is stored |
|---|---|
| Order id | Links the payment back to the order and makes a repeated webhook harmless. |
| Reference | The address in the link, one per order, never reused. |
| Wallet and mint | What the checker compares balances against. |
| Amount in raw units | Fixed when the link is made, from the order total at that moment. |
| Created time | Lets you expire the order and stop watching it. |

When the checker prints `paid: true`, call the Admin GraphQL `orderMarkAsPaid` mutation with the order id, and write the signature into the same row so a second run does nothing. Require each signature to be unique across all orders and refuse one already recorded for another order. A customer can open two orders with the same total and send one transfer that lists both references, and without that check the checker would mark both orders paid.

The order total is in the store's currency. For a USD store paid in USDC the amount is the total. For any other currency you pick a rate when you make the link and keep it in the row; the rate source is yours to pick.

> Make the reference with `generateKeyPairSigner()` from `@solana/kit`, keep the address and drop the secret half. The secret is never used.

## The checker

Install with `npm install @solana/kit@8.6.0` and set the package type to module. Node 24 strips the types on load. `CARBIUM_KEY` is required, and the file exits with a message when it is missing. `CARBIUM_RPC_URL` and `WAIT_S` are optional, with the [Carbium RPC endpoint](https://carbium.sh/docs#endpoints) `https://services.carbium.sh` and 20 seconds as defaults.

The arguments are the reference, the mint, then optionally your wallet and a minimum in raw units. With a wallet it checks that wallet for at least the minimum, or 1 raw unit when you give none. With no wallet it takes, for each transaction, the owner with the largest gain, so you can see the output on any busy mint before you have an order.

`main.ts` (run: `node main.ts`)

```ts
// I0018 · Shopify Solana Pay orders
// https://carbium.sh/library/integrate/shopify-solana-pay-orders
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY.");
  process.exit(1);
}
const [reference, mint, wallet, minimum] = process.argv.slice(2);
if (!reference || !mint) {
  console.error("Usage: node main.ts <reference> <mint> [wallet] [minimum in raw units]");
  process.exit(1);
}
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);
const commitment = "finalized"; // named on every call; finalized sits 0 to 1 slots behind processed
const deadline = Date.now() + Number(process.env.WAIT_S ?? 20) * 1000;
const seen = new Set<string>();

type Bal = { mint: string; owner?: string; uiTokenAmount: { amount: string } };
type Meta = { preTokenBalances?: readonly Bal[] | null; postTokenBalances?: readonly Bal[] | null };

// Raw units each owner wallet gained of the mint in one transaction.
function gains(meta: Meta | null): Map<string, bigint> {
  const out = new Map<string, bigint>();
  const add = (list: readonly Bal[] | null | undefined, sign: bigint) => {
    for (const b of list ?? []) {
      if (b.mint === mint && b.owner) out.set(b.owner, (out.get(b.owner) ?? 0n) + sign * BigInt(b.uiTokenAmount.amount));
    }
  };
  add(meta?.preTokenBalances, -1n);
  add(meta?.postTokenBalances, 1n);
  return out;
}

async function check(): Promise<boolean> {
  const sigs = await rpc.getSignaturesForAddress(address(reference), { limit: 5, commitment }).send();
  const fresh = sigs.filter((s) => s.err === null && !seen.has(s.signature));
  const txs = await Promise.allSettled(
    fresh.map((s) =>
      rpc.getTransaction(s.signature, { commitment, encoding: "json", maxSupportedTransactionVersion: 1 }).send(),
    ),
  );
  for (const [i, r] of txs.entries()) {
    const sig = fresh[i].signature;
    if (r.status === "rejected") {
      console.error(`${sig}: getTransaction failed: ${r.reason instanceof Error ? r.reason.message : String(r.reason)}`);
      continue; // retried on the next poll
    }
    seen.add(sig);
    if (r.value === null) {
      console.error(`${sig}: getTransaction answered null, skipped`);
      continue;
    }
    const got = gains(r.value.meta);
    const best = [...got].sort((a, b) => (b[1] > a[1] ? 1 : b[1] < a[1] ? -1 : 0))[0]?.[0];
    const target = wallet ?? best;
    const credited = target ? (got.get(target) ?? 0n) : 0n;
    const min = BigInt(minimum ?? (wallet ? 1 : credited)); // no wallet: a demo that accepts the largest gain
    const paid = credited > 0n && credited >= min;
    console.log(JSON.stringify({ signature: sig, slot: fresh[i].slot.toString(), wallet: target ?? null, credited: credited.toString(), paid }));
    if (paid) return true;
  }
  return false;
}

for (;;) {
  const done = await check().catch((e: unknown) => {
    console.error("poll failed:", e instanceof Error ? e.message : String(e));
    return false;
  });
  if (done) break;
  if (Date.now() > deadline) {
    console.log("no paying transaction yet");
    break;
  }
  await new Promise((r) => setTimeout(r, 5_000));
}
```

Each line it prints is JSON with the signature, slot, wallet, raw amount credited and `paid`. It polls every 5 seconds until a transaction pays or `WAIT_S` runs out. A failed call is logged and retried on the next poll.

## What it costs against your limits

Each poll is one `getSignaturesForAddress` at 50 cells, and each new signature adds one `getTransaction`, also 50 cells. The two sit in different rate classes. Polling every 5 seconds is 0.2 req/s per open order for the address signatures class. Free allows 0.24 req/s of that class, which holds one open order. Dev allows 1.2 req/s, which holds six, and Business and Pro allow 100 and 500.

The `getTransaction` calls fall in the ledger and transaction lookups class, which allows 0.24, 1.2, 5 and 25 req/s on Free, Dev, Business and Pro. It is only used when a new signature appears.

[Limits are per account](https://carbium.sh/docs#limits) and every key shares them. A class also absorbs bursts of up to 1,024 cells, so the first poll that fetches five transactions, 250 cells in the lookups class, fits in it.

A shop with many orders open together should poll them in one loop at a slower interval, or subscribe over a WebSocket. For a fixed set of addresses, see [Multi-address deposit monitor](https://carbium.sh/library/blockchainideas/multi-address-deposit-monitor).

## Where it ends

- It creates no order, link or reference, and it never calls Shopify. Those steps are yours.
- It reads token balances only. A payment in SOL moves lamports, which would need the `preBalances` and `postBalances` in the metadata instead.
- It looks at the newest five signatures of the reference. A reference only the customer has seen rarely lists more than one, so five is plenty; raise `limit` if yours might.
- `getSignaturesForAddress` on Carbium reaches back 30 days at most, from its own [address index](https://carbium.sh/docs#migrate), so an order older than that cannot be checked this way. Expire orders well before that.
- A signature the index lists can sit below the validator's ledger floor, and `getTransaction` then answers null. The checker skips it and prints a line. A new order does not hit this.
- A partial payment prints `paid: false` with the amount credited. Whether the customer tops up or you refund is your policy.
- It does not refund. A refund is a transfer you sign from your wallet, and this file signs and sends nothing.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The log shows `getTransaction failed` with error -32015. | The transaction is v1 and the call lacks `maxSupportedTransactionVersion: 1`. Keep that field at 1 on every `getTransaction` and `getBlock` call. |
| A payment you can see in a wallet prints `credited: 0`. | The mint argument differs from the one in the link, or the wallet argument is a token account address. Pass the owner wallet and the mint from the `spl-token` parameter. |
| The checker prints `no paying transaction yet` for an order the customer says they paid. | Call `getSignaturesForAddress` by hand on the stored reference. An empty answer means the wallet did not list it, usually because the `reference` in the link differed from the stored one. Rebuild the link from the stored row. |
| The log shows `poll failed` with HTTP error 429. | The account's budget is spent or the interval is too short for the plan. Slow the poll and check which other keys share the account budget. |
| The log shows `getTransaction answered null` for a signature the reference lists. | Listed signatures can sit below the validator's ledger floor. Expect this on old orders only, keep the skip in the file, and test on the newest signatures. |
| Every call answers 401. | Carbium does not know the key. Attach the whole key in the `x-api-key` header, as the [error table](https://carbium.sh/docs#errors) says. |

## Questions

### Do I need a Solana Pay library?

No. A transfer request is a URL with `solana:`, the wallet and query parameters, and the check uses `@solana/kit` only.

### Why finalized and not confirmed?

A shop releases goods once, and a finalized payment cannot be undone. Change `commitment` to `confirmed` if you want the earlier answer.

### Can a WebSocket replace the polling?

Yes, `logsSubscribe` with a mention of the reference [streams its transactions](https://carbium.sh/docs#websocket). That filter opens at 25 credits and then costs 20 credits per MiB sent, and your plan caps sockets and subscriptions, with Free at 5 sockets. A notification still needs the `getTransaction` check before you mark anything paid.

### How long should I watch an order?

Pick an expiry in your own terms and stop polling after it. Keep it well inside the 30 days of the address index.

## Related

- [Multi-address deposit monitor](https://carbium.sh/library/blockchainideas/multi-address-deposit-monitor) (Blockchain ideas, BI0006)
- [Transaction status check](https://carbium.sh/library/howsolana/transaction-status-check) (How to use Solana, HS0008)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#websocket](https://carbium.sh/docs#websocket)
- [carbium.sh/docs#errors](https://carbium.sh/docs#errors)
- [carbium.sh/docs#migrate](https://carbium.sh/docs#migrate)
