Three checkout operations converge into one Solana transaction

DeFi users tolerate three consecutive wallet popups—approve, swap, claim—because they are sitting at a desk chasing yield. Put that same interaction pattern in front of an espresso machine with five people waiting behind you, and the cashier will unplug the tablet before noon.

Worse than the UX drag is the state machine hazard. If you split a returning customer’s checkout into three separate transactions—(1) send 9 USDC, (2) redeem a 1 USDC store credit, (3) issue a new 1 USDC reward—any dropped RPC packet, expired blockhash, or dismissed Phantom modal leaves the ledger half-written. Either the merchant gets paid without burning the old credit (double-spend on loyalty), or the old credit gets burned before the payment lands (angry regular at the counter).

While building Solpay (SolanaOn-chainPay), we leaned directly into Solana’s single-transaction atomicity to collapse the entire returning-customer loop into one confirmation. Here is how the runtime actually behaves on chain, what the frontend has to precompute before signing, and how we keep cashier revocation constant-time.


Anatomy of Two Real Devnet Transactions

Separate payment and rewards steps contrasted with a single atomic checkout path

Everything below comes from our November 19, 2026 Devnet verification run against Program F9wYEzU8wVYnhMoaJA9MgspdsAhbKnZhgvFnqv9fDuHr (all transactions submitted as Solana Versioned Transaction v0 with manual Phantom confirmation):

  1. First visit — locked invoice settlement + credit issuance

    • Signature: 47sU232yZxJdUEv4xDXa9uzEv2TtBmT1L5KeP3kKYxr15KmcGNZEBZsSfxG8Ky9SGD7GtYggMXco6kabtTLyARSr
    • Receipt account: BctnijK31YMKo42kykRCNUnkFuLtLR1BKfpQLBadZnd4
    • Atomic effect: Marks invoice CtdGDB...Eciq settled, transfers 10.000000 USDC from customer 94V4...PdUN to Daylight Coffee (D2zFrU...v6iT), and records a 1.000000 USDC store credit expiring exactly seven days later (2026-11-26T15:06:32.000Z).
  2. Return visit — net payment + FIFO credit burn + fresh reward

    • Signature: 51z13ntHEWJ7xm72myJmJcpuqacWyrdE6YLme7cAJPCbeHSQ8xpxUqSyNiTJruirwgpD1KtPgzzAJ8BNVM75krBo
    • Receipt account: 64sFErZpaG6Yujy3eVV6mikZHLbnSJwYW6oWnYni2rvJ
    • Atomic effect: Customer enters 10.000000 USDC via the permanent store QR. Inside one Solana transaction (network fee under 0.00001 SOL), the program:
      • Reduces the remaining credit on receipt Bctnij...Znd4 from 1.000000 to 0.000000;
      • Transfers 9.000000 USDC net cash to the merchant;
      • Checks active campaign 7chnrv...GG2f (100 USDC lifetime cap, 1 USDC minimum spend) and attaches a fresh 1.000000 USDC credit expiring 2026-11-26T15:07:43.000Z.

If any single invariant fails—say the old credit expired five seconds earlier, the campaign hit its 100 USDC cap, or the invoice crossed its 15-minute deadline—the entire transaction aborts cleanly. No half-redeemed vouchers, no orphan debits.


Pre-Signing Preview vs. On-Chain Enforcement

Because Solana programs require every read/write account to be declared up front in the transaction’s account keys, the checkout client cannot leave FIFO credit selection to magic at execution time. The frontend has to build an explicit preview before handing the transaction to Phantom:

[Logical Checkout Assembly Flow]

1. Load route context:
   - Fixed invoice (/i/<invoice_id>) -> locked sale_amount + expiry timestamp
   - Permanent store QR (/m/<merchant_id>) -> customer-entered sale_amount

2. Fetch store's active Campaign account:
   - Render "Pay & earn 1 USDC" banner immediately, even before wallet connect

3. On wallet connect, query customer's unredeemed credit lots for this store:
   - Filter out remaining_credit == 0 and expires_at <= now
   - Sort ascending by expires_at (FIFO: burn soonest-expiring credit first)

4. Compute preview & assemble v0 transaction:
   - gross_usdc    = 10.000000
   - discount_usdc =  1.000000  (referencing receipt Bctnij...Znd4)
   - cash_usdc     =  9.000000
   - Pass explicit account metas: payer, merchant, active campaign, selected credit lot(s), new receipt

5. On-chain program re-verifies every constraint against Clock & account owners:
   - Frontend FIFO order is only a proposal; the program enforces ownership, store scope, expiry, and caps

That fifth step is worth emphasizing for anyone writing Anchor payment programs: never trust client-computed discount math. The client’s job is to pick the most helpful unexpired lots so the shopper doesn’t lose expiring credits; the program’s job is to re-verify store ownership, payer match, remaining balance, and Clock::get()?.unix_timestamp before subtracting a single lamport or micro-USDC from the transfer.

If you want a structured walkthrough of Anchor account constraints, PDA seeds, and SPL token CPI patterns, check our Solana Anchor Practical Guide. While debugging accounts on Devnet or Mainnet, you can also inspect PDAs, derive ATAs, and decode recent transactions without leaving the browser using Solana Tools at sol.fone.cc.


Constant-Time Cashier Revocation Without Sweeping Old Invoices

A store-owner key separated from a cashier key with limited permissions

Physical stores rotate part-time staff constantly. In Solpay, the owner wallet (93Hr...GRsL) authorizes a separate cashier wallet (9kYp...PH2H), creating a dedicated Staff authorization account (4FEEn1...w2ad).

Action Owner Wallet Cashier Wallet On-Chain Enforcement Boundary
Register store & manage staff Allowed Rejected Signer must match store owner authority
Publish & activate campaigns Allowed Rejected Terms become immutable upon publication
Issue 15-minute locked invoices Allowed Allowed Requires active Staff authorization account
Revoke cashier access Allowed — Flips Staff authorization state in O(1); no invoice loop needed
Settle unpaid cashier invoice — — Program checks creator’s Staff account at payment time; revoked = rejected
Audit / export settled receipts Allowed — Finalized receipts are independent accounts and remain untouched

Notice why revoking a cashier does not require scanning or closing every open invoice they ever created. When a customer attempts to settle an invoice, the settlement instruction checks whether the invoice’s creator still holds active authorization. Flipping one Staff account instantly and permanently invalidates every unpaid invoice tied to that cashier—in O(1) compute—without mutating a single settled receipt.


Dual Checkout Surfaces in One Program

Supporting both checkout paths under one accounting model keeps the codebase clean:

  • Fixed-amount invoice (/i/<invoice_id>): Cashier signs an on-chain invoice locked to 10.000000 USDC with a strict 15-minute expiry (15:05:21Z to 15:20:21Z in our test). Once paid, the invoice is marked settled so it cannot be replayed.
  • Permanent counter QR (/m/<merchant_id>): No pre-created invoice account. The shopper enters the amount directly, still runs through campaign eligibility and FIFO credit redemption, and generates the exact same finalized receipt schema—tagged source = static rather than source = invoice in downstream exports.

For teams who would rather license and customize a working POS codebase than spend quarters rebuilding these invariants from scratch, review the Solpay product page. And if your broader Solana roadmap also calls for token launches, CSV batch distributions, or liquidity workspaces, explore Solana Tools or test it live at sol.fone.cc.


Frequently Asked Questions (FAQ)

Why use a single Solana Versioned Transaction (v0) instead of separate payment and loyalty transactions?

Combining net USDC transfer, FIFO credit redemption, and fresh reward issuance into one atomic transaction eliminates multi-popup checkout friction at the counter and guarantees that partial failures cannot leave credits unburned or payments uncredited.

What happens if a customer tries to pay a locked invoice after 15 minutes?

The program validates the invoice’s expiration timestamp against on-chain clock state during settlement. Any payment attempt after the 15-minute window is rejected on-chain, preventing stale quotes or delayed replays.

Does revoking a cashier delete or alter the store’s past sales history?

No. Revocation only invalidates unpaid invoices created by that cashier. Previously settled payments live in finalized receipt accounts that stay intact for reconciliation and CSV accounting.