@tuwaio/nova-payments

@tuwaio/nova-payments is the checkout of Quasar Client, built on Nova UI Kit. It renders the checkout of a Quasar Payments invoice from its checkout token: the order with its lines, tax and deadline, the steps of the payment and its outcome, in a modal (a sheet from the bottom on a phone), in the page, or on a page of its own. It keeps no payment state of its own: the checkout store of @tuwaio/quasar-sdk/checkout reads the invoice and follows it, and no secret key reaches the browser.
[!IMPORTANT]
Docs only, not live in production: Quasar Payments is still being built, so what this page describes is not available yet and may change.
[!NOTE]
The package is in development: native speakers review the translations of the checkout before the stable release.
💾 Installation
pnpm add @tuwaio/nova-payments @tuwaio/quasar-sdk @tuwaio/nova-core @tuwaio/nova-connect @tuwaio/nova-transactions @tuwaio/satellite-react @tuwaio/satellite-core @tuwaio/pulsar-core @tuwaio/orbit-core zustand react framer-motion @radix-ui/react-dialog @web3icons/react @web3icons/common clsx tailwind-merge
The checkout connects wallets through Nova Connect (NovaConnectProvider of @tuwaio/nova-connect, with its own peers): the app's, or Nova's own when the app has no wallet connection (see "Wallet connection" below). Apps that connect wallets differently pass onConnectWallet, and without either the buyer pays with a QR code.
Import the stylesheets of @tuwaio/nova-core (theme variables), of @tuwaio/nova-transactions (the confirm and paid steps reuse its progress) and of this package (Tailwind CSS v4 utilities prefixed with novapay:):
@import '@tuwaio/nova-core/dist/index.css';
@import '@tuwaio/nova-transactions/dist/index.css';
@import '@tuwaio/nova-payments/dist/index.css';
With Nova's own connection, also import @tuwaio/nova-connect/dist/index.css for its connect modal.
The checkout is drawn in the look of Nova UI Kit 0.15: paper and ink, square, with the pixel icons of @tuwaio/nova-icons (installed with this package). Its icons come from the icon set of NovaIconsProvider of @tuwaio/nova-core, so an app that gave Nova another set (heroicons of @tuwaio/nova-core/heroicons) gets it in the checkout too. The icons only the checkout draws (a lock, a QR code, a download and others) are optional in a set: the Heroicons set has them from @tuwaio/nova-core 0.15.1, and with a set that has none, or an older @tuwaio/nova-core, they stay the pixel ones. The names of a seller, a wallet and a network keep their own letters inside the buttons, whose words are in capitals.
🚀 Usage
Issue the invoice on your server with @tuwaio/quasar-sdk and pass its checkoutToken to the checkout:
'use client';
import { PaymentCheckout } from '@tuwaio/nova-payments';
import { useState } from 'react';
export function Checkout({ token }: { token: string }) {
const [open, setOpen] = useState(false);
return (
<>
<button type="button" onClick={() => setOpen(true)}>
Pay
</button>
<PaymentCheckout token={token} open={open} onOpenChange={setOpen} />
</>
);
}
display="inline" renders it in the page. display="page" is the whole page, as the Quasar payment page shows it: a sheet 880 px wide, centered in the window (min-height: 100svh; a page with a header of its own sets --novapay-page-height on an ancestor, for example calc(100svh - 64px)), that grows downward with its step and scrolls nothing inside, full-bleed under 640 px. NovaPaymentsProvider sets the Quasar API for a Community Edition node (baseUrl) and replaces labels.
To pay from a wallet in the browser, give the provider the chain adapters of your app (@tuwaio/nova-payments/evm needs @wagmi/core and viem; @tuwaio/nova-payments/solana needs @solana/kit, @solana-program/system, @solana-program/token and @tuwaio/orbit-solana) and, optionally, your Pulsar store: every payment of a checkout goes to it, and Nova Transactions shows its toast (one the wallet sends at once, one paid with a QR code or a relayed signature once Quasar records it).
'use client';
import { NovaPaymentsProvider } from '@tuwaio/nova-payments';
import { paymentsEVMAdapter } from '@tuwaio/nova-payments/evm';
import { paymentsSolanaAdapter } from '@tuwaio/nova-payments/solana';
import type { Transaction } from '@tuwaio/pulsar-core';
import type { Config } from '@wagmi/core';
import type { ReactNode } from 'react';
export function Payments({
wagmiConfig,
injectExternalPendingTxs,
children,
}: {
wagmiConfig: Config;
injectExternalPendingTxs: (transactions: Transaction[]) => Promise<void>;
children: ReactNode;
}) {
return (
<NovaPaymentsProvider
adapters={[
paymentsEVMAdapter(wagmiConfig),
paymentsSolanaAdapter({ rpcUrls: { devnet: 'https://api.devnet.solana.com' } }),
]}
pulsar={{ injectExternalPendingTxs }}
>
{children}
</NovaPaymentsProvider>
);
}
Wallet connection: the app's or Nova's own
Nova Payments brings its own wallet connection only when the app has none. NovaPaymentsProvider decides once, on its first render, and usePaymentsConnection tells which:
Above NovaPaymentsProvider |
Wallet, network and connect modal |
Payment adapters |
The app's SatelliteConnectProvider and NovaConnectProvider |
The app's (app), with its SIWX; Nova mounts nothing of its own |
adapters |
The app's SatelliteConnectProvider only |
The app's wallet (appStore); "Connect wallet" calls onConnectWallet; never a second store |
adapters |
Nothing, and ownConnection is given |
Nova's own (own): a Satellite store, the watchers and a Nova Connect modal, never with SIWX |
ownConnection.adapters |
| Nothing |
None (none): QR codes, and onConnectWallet |
adapters |
Inside an app with Satellite Connect and Nova Connect, add only NovaPaymentsProvider with adapters on the wagmi config of the app's Satellite EVM adapter (as above): the checkout and the refunds show the app's wallet, "Connect wallet" opens the app's modal, and a payment on another network switches that wallet. If the app signs in with SIWX through Nova Connect, set siwx.sessionScope: 'account' there when its server binds a session to the address only, so a network switch made by the checkout does not ask the wallet to sign in again (see @tuwaio/nova-connect). A NovaPaymentsProvider inside another one's own connection uses that connection, so two stores never stack, and without adapters it pays with those of the provider above.
A page without a wallet connection (a payment page, an admin page) gives ownConnection, created once at module level. Nova's store runs Satellite's start-up only with autoConnect, so it never drops the wallet of another tab or of the host page. It lives as long as the page, one per Satellite adapter, as the wagmi config does: a checkout closed and opened again, another page or a second provider on the same adapters shows the wallet still connected. autoConnect: true reconnects the last wallet once per page load, with Satellite's start-up (with @tuwaio/satellite-core 0.11.1 or later, without a permission prompt and without disconnecting wallets this page did not connect; earlier versions disconnect every wallet of the adapters first); without it, the connect modal hides "Remember this wallet", since nothing would reconnect the wallet. Nova's own connection and its Nova Connect modal load on demand, so an app that does not use them does not download them.
'use client';
import { EVMConnectorsWatcher } from '@tuwaio/nova-connect/evm';
import { SolanaConnectorsWatcher } from '@tuwaio/nova-connect/solana';
import { type NovaPaymentsOwnConnection, NovaPaymentsProvider, PaymentCheckout } from '@tuwaio/nova-payments';
import { paymentsEVMAdapter } from '@tuwaio/nova-payments/evm';
import { paymentsSolanaAdapter } from '@tuwaio/nova-payments/solana';
import { createDefaultTransports, satelliteEVMAdapter } from '@tuwaio/satellite-evm';
import { satelliteSolanaAdapter } from '@tuwaio/satellite-solana';
import { createConfig, createStorage, injected, noopStorage } from '@wagmi/core';
import { base, type Chain, mainnet } from 'viem/chains';
const chains = [mainnet, base] as readonly [Chain, ...Chain[]];
const solanaRPCUrls = { mainnet: 'https://api.mainnet-beta.solana.com' };
const wagmiConfig = createConfig({
chains,
connectors: [injected()],
transports: createDefaultTransports(chains),
ssr: true,
storage: createStorage({ storage: noopStorage }),
});
const ownConnection: NovaPaymentsOwnConnection = {
adapter: [satelliteEVMAdapter(wagmiConfig, chains), satelliteSolanaAdapter({ rpcUrls: solanaRPCUrls })],
watchers: (
<>
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
<SolanaConnectorsWatcher />
</>
),
adapters: [paymentsEVMAdapter(wagmiConfig), paymentsSolanaAdapter({ rpcUrls: solanaRPCUrls })],
novaConnect: { appChains: chains, solanaRPCUrls, withBalance: true, withChain: true },
};
export function PayPage({ token }: { token: string }) {
return (
<NovaPaymentsProvider ownConnection={ownConnection}>
<PaymentCheckout token={token} display="page" />
</NovaPaymentsProvider>
);
}
The full integration with Satellite Connect, SIWX and Pulsar is in the Full-Stack React guide.
Before an EVM payment the buyer's wallet sends itself (paying the gas, or a smart wallet with or without the merchant's paymaster), the wallet confirms the invoice: right after the wallet and the method are chosen, before the price, a step says that it is free and moves no money, sums up what the wallet signs (the invoice, the seller, the amount and the wallet) and opens the wallet's signature request (an EIP-4361 message from Quasar, signed with personal_sign; a smart wallet may ask for its passkey). Quasar credits the wallet's transfers to this invoice only once it signed; one signature per invoice and wallet, so a new price, token or network needs none. A refusal keeps the buyer on the step with the reason and the same button; "Back to methods" returns. A gasless USDC or EURC payment needs no extra window (the signed authorization confirms the wallet), and when the buyer pays the gas of such a method instead, the pay step asks for the confirmation first. The EVM adapter sends a gasless payment itself, from a one-time account: a key it makes in memory for the payment, delegated (EIP-7702) to Simple7702Account, whose one call is the transfer Quasar authorized for the signature, sponsored by the merchant's paymaster; the wallet signs only the authorization, and Quasar signs nothing. Solana payments and automatic charges are unchanged. A chain adapter of your own adds signMessage for it.
The checkout shows a price's receiving address or QR code, and asks the wallet to pay, only once the payee of the price is verified: every place of the address in the quote (the instructions, the EIP-3009 authorization of a gasless payment, the paymaster calls, the Solana Pay link) names one address, the payout record Quasar sends with the quote covers its network and address and is signed by that address's own wallet, and the address is one of your payoutAddresses when you pin them. The chain adapters check the signature in the page: an ordinary EVM wallet's by recovery, a smart wallet's through its contract on the quote's network (ERC-1271, ERC-6492) over the RPC of your wagmi config, a Solana wallet's Ed25519. A price that fails is never shown: the step says that the payment is stopped and that nothing was sent (data-payee-refusal names the reason). The signature shows that the receiving wallet agreed, not that it is yours: a swap in Quasar's database could carry a record its own wallet signed. Pin your receiving addresses, from your own configuration, to stop that:
<PaymentCheckout
token={checkoutToken}
payoutAddresses={['0x52908400098527886E0F7030069857D2E4169EE7', '7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU']}
/>
The hosted payment page reads them from the #payout= fragment of its link, which payoutAddresses of the Quasar client of @tuwaio/quasar-sdk adds; against a compromise of Quasar's servers themselves, only a checkout in your own page with the pins holds. A chain adapter of your own adds verifyPayoutRecord; without it the checkout matches the record but leaves its signature unchecked.