better-auth-solana-payments 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ [English](README.md) · [Español](README.es-ES.md) · [Français](README.fr-FR.md)
2
+
3
+ # Better Auth Solana Payments
4
+
5
+ Acepta pagos únicos con Solana Pay para usuarios u organizaciones de Better Auth. El servidor verifica las transferencias mediante RPC de solo lectura.
6
+
7
+ ## Instalación
8
+
9
+ ```sh
10
+ pnpm add better-auth better-auth-solana-payments solana-payments
11
+ ```
12
+
13
+ Requiere Node.js 22+, Better Auth `>=1.4.22 <2` y `solana-payments` `^1.1.0`.
14
+
15
+ ## Configurar Better Auth
16
+
17
+ Define `SOLANA_RPC_URL` y `SOLANA_RECIPIENT` en el servidor. El ejemplo usa el mint de USDT de mainnet. Elige un mint y una URL RPC de la misma red.
18
+
19
+ ```ts
20
+ import { betterAuth } from "better-auth";
21
+ import { solanaPayments } from "better-auth-solana-payments";
22
+ import { SOLANA_USDT, createReadOnlySolanaPayments } from "solana-payments";
23
+
24
+ const client = createReadOnlySolanaPayments({
25
+ rpcUrl: process.env.SOLANA_RPC_URL!,
26
+ token: SOLANA_USDT,
27
+ commitment: "confirmed",
28
+ });
29
+
30
+ export const auth = betterAuth({
31
+ plugins: [solanaPayments({ client, recipient: process.env.SOLANA_RECIPIENT! })],
32
+ });
33
+ ```
34
+
35
+ Usa un adaptador persistente, monta el controlador de Better Auth y aplica el esquema del plugin antes de aceptar pagos. Si tu instalación carece de los campos de entrega, sigue la [guía de migración](skills/solana-payment-verification/SKILL.md#existing-databases).
36
+
37
+ ```ts
38
+ import { createAuthClient } from "better-auth/client";
39
+ import { solanaPaymentsClient } from "better-auth-solana-payments/client";
40
+
41
+ export const authClient = createAuthClient({ plugins: [solanaPaymentsClient()] });
42
+ ```
43
+
44
+ ## Cobrar un pago
45
+
46
+ Crea una intención desde una sesión autenticada con una cadena decimal en las unidades de visualización del token.
47
+
48
+ ```ts
49
+ const { data, error } = await authClient.payment.create({ amount: "2.5" });
50
+ if (error || !data?.paymentUrl) {
51
+ throw new Error(error?.message ?? "Could not create Solana payment");
52
+ }
53
+
54
+ const { reference, paymentUrl } = data;
55
+ ```
56
+
57
+ Guarda la referencia con el pedido del servidor. Presenta la URL como enlace de Solana Pay o código QR. Tras el envío desde la cartera, llama a `authClient.payment.verify({ reference })` e incluye la firma si está disponible. Usa `authClient.payment.get({ reference })` para leer el estado almacenado.
58
+
59
+ Comprueba el pago contra el pedido en el servidor y haz que `onPaymentComplete` sea idempotente por referencia. Concede acceso cuando el pago esté `paid` y la entrega `completed`. Para pagos de organización, activa el plugin de organización de Better Auth y configura `organization.enabled` en el plugin de Solana e incluye el mismo `organizationId` en cada llamada. [Configuración](skills/better-auth-solana-payments-setup/SKILL.md) · [Verificación y entrega](skills/solana-payment-verification/SKILL.md)
60
+
61
+ ## Proyectos independientes
62
+
63
+ Crea un proyecto con npm. TanStack Start es la opción predeterminada.
64
+
65
+ ```sh
66
+ npm create better-auth-solana-payments@latest my-app
67
+ npm create better-auth-solana-payments@latest my-next-app -- --template nextjs
68
+ npm create better-auth-solana-payments@latest my-worker -- --template hono
69
+ ```
70
+
71
+ Configura el entorno según el README generado y ejecuta `pnpm install --frozen-lockfile` y `pnpm dev`.
72
+
73
+ Descarga el proyecto independiente de TanStack en la próxima versión. El archivo incluye el lockfile y una plantilla de entorno. Extráelo, configura el entorno y ejecuta `pnpm install --frozen-lockfile` y `pnpm dev`. [GitHub Releases](https://github.com/alexasomba/better-auth-solana-payments/releases)
74
+
75
+ Desde el repositorio, exporta la demo con el paquete publicado o con un tarball local generado mediante `vp pack` y `pnpm pack`.
76
+
77
+ ```sh
78
+ pnpm starter:export tanstack /tmp/solana-starter
79
+ pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-solana-payments.tgz
80
+ ```
81
+
82
+ ## Demo y habilidades para agentes
83
+
84
+ Consulta las guías de integración para agentes en inglés de [TanStack Start](skills/solana-tanstack-start/SKILL.md), [Next.js App Router](skills/solana-nextjs/SKILL.md) y [Hono en Cloudflare Workers](skills/solana-hono/SKILL.md).
85
+
86
+ [TanStack Start](examples/tanstack/README.md) y [Next.js](examples/nextjs/README.md) muestran inicio de sesión, pago con cartera y verificación. [Hono](examples/hono/README.md) ofrece la API de pagos en un Worker.
87
+
88
+ El paquete npm incluye [habilidades para agentes](skills). Con pnpm 12.11 o posterior, ejecuta `pnpm approve` tras instalarlo y aprueba sus habilidades cuando se te solicite. TanStack Intent puede localizar y cargar los mismos archivos.
89
+
90
+ ```sh
91
+ pnpm dlx @tanstack/intent list
92
+ pnpm dlx @tanstack/intent load better-auth-solana-payments#better-auth-solana-payments-setup
93
+ ```
@@ -0,0 +1,93 @@
1
+ [English](README.md) · [Español](README.es-ES.md) · [Français](README.fr-FR.md)
2
+
3
+ # Better Auth Solana Payments
4
+
5
+ Acceptez les paiements ponctuels via Solana Pay pour les utilisateurs ou les organisations Better Auth. Le serveur vérifie les transferts par RPC en lecture seule.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ pnpm add better-auth better-auth-solana-payments solana-payments
11
+ ```
12
+
13
+ Utilisez Node.js 22+, Better Auth `>=1.4.22 <2` et `solana-payments` `^1.1.0`.
14
+
15
+ ## Configurer Better Auth
16
+
17
+ Définissez `SOLANA_RPC_URL` et `SOLANA_RECIPIENT` côté serveur. Cet exemple utilise le mint USDT du réseau principal. Choisissez un mint et une URL RPC sur le même réseau.
18
+
19
+ ```ts
20
+ import { betterAuth } from "better-auth";
21
+ import { solanaPayments } from "better-auth-solana-payments";
22
+ import { SOLANA_USDT, createReadOnlySolanaPayments } from "solana-payments";
23
+
24
+ const client = createReadOnlySolanaPayments({
25
+ rpcUrl: process.env.SOLANA_RPC_URL!,
26
+ token: SOLANA_USDT,
27
+ commitment: "confirmed",
28
+ });
29
+
30
+ export const auth = betterAuth({
31
+ plugins: [solanaPayments({ client, recipient: process.env.SOLANA_RECIPIENT! })],
32
+ });
33
+ ```
34
+
35
+ Utilisez un adaptateur persistant, montez le gestionnaire Better Auth et appliquez le schéma du plugin avant d’accepter des paiements. Si les champs d’exécution manquent dans votre installation, suivez le [guide de migration](skills/solana-payment-verification/SKILL.md#existing-databases).
36
+
37
+ ```ts
38
+ import { createAuthClient } from "better-auth/client";
39
+ import { solanaPaymentsClient } from "better-auth-solana-payments/client";
40
+
41
+ export const authClient = createAuthClient({ plugins: [solanaPaymentsClient()] });
42
+ ```
43
+
44
+ ## Encaisser un paiement
45
+
46
+ Créez une intention dans une session authentifiée. Transmettez le montant décimal sous forme de chaîne dans l’unité d’affichage du jeton.
47
+
48
+ ```ts
49
+ const { data, error } = await authClient.payment.create({ amount: "2.5" });
50
+ if (error || !data?.paymentUrl) {
51
+ throw new Error(error?.message ?? "Could not create Solana payment");
52
+ }
53
+
54
+ const { reference, paymentUrl } = data;
55
+ ```
56
+
57
+ Conservez la référence avec la commande côté serveur. Présentez l’URL sous forme de lien Solana Pay ou de code QR. Après l’envoi depuis le portefeuille, appelez `authClient.payment.verify({ reference })` et joignez la signature si elle est disponible. Utilisez `authClient.payment.get({ reference })` pour lire l’état enregistré.
58
+
59
+ Rapprochez le paiement de la commande côté serveur et rendez `onPaymentComplete` idempotent par référence. Accordez l’accès lorsque le paiement est `paid` et son exécution `completed`. Pour les paiements d’organisation, activez le plugin d’organisation de Better Auth et configurez `organization.enabled` dans le plugin Solana et fournissez le même `organizationId` à chaque appel. [Configuration](skills/better-auth-solana-payments-setup/SKILL.md) · [Vérification et exécution](skills/solana-payment-verification/SKILL.md)
60
+
61
+ ## Starters autonomes
62
+
63
+ Créez un projet avec npm. TanStack Start est le choix par défaut.
64
+
65
+ ```sh
66
+ npm create better-auth-solana-payments@latest my-app
67
+ npm create better-auth-solana-payments@latest my-next-app -- --template nextjs
68
+ npm create better-auth-solana-payments@latest my-worker -- --template hono
69
+ ```
70
+
71
+ Configurez l’environnement selon le README généré, puis exécutez `pnpm install --frozen-lockfile` et `pnpm dev`.
72
+
73
+ Téléchargez le starter TanStack autonome dans la prochaine version. L’archive contient le fichier de verrouillage et un modèle d’environnement. Extrayez-la, configurez l’environnement, puis exécutez `pnpm install --frozen-lockfile` et `pnpm dev`. [GitHub Releases](https://github.com/alexasomba/better-auth-solana-payments/releases)
74
+
75
+ Depuis le dépôt, exportez la démo avec le paquet publié ou une archive locale créée via `vp pack` puis `pnpm pack`.
76
+
77
+ ```sh
78
+ pnpm starter:export tanstack /tmp/solana-starter
79
+ pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-solana-payments.tgz
80
+ ```
81
+
82
+ ## Démo et compétences pour agents
83
+
84
+ Consultez les guides d’intégration pour les agents en anglais de [TanStack Start](skills/solana-tanstack-start/SKILL.md), de [Next.js App Router](skills/solana-nextjs/SKILL.md) et de [Hono sur Cloudflare Workers](skills/solana-hono/SKILL.md).
85
+
86
+ [TanStack Start](examples/tanstack/README.md) et [Next.js](examples/nextjs/README.md) présentent la connexion, le paiement par portefeuille et la vérification. [Hono](examples/hono/README.md) expose l’API de paiements dans un Worker.
87
+
88
+ Le paquet npm inclut des [compétences pour agents](skills). Avec pnpm 12.11 ou une version ultérieure, exécutez `pnpm approve` après l’installation et approuvez les compétences proposées. TanStack Intent peut répertorier et charger les mêmes fichiers.
89
+
90
+ ```sh
91
+ pnpm dlx @tanstack/intent list
92
+ pnpm dlx @tanstack/intent load better-auth-solana-payments#better-auth-solana-payments-setup
93
+ ```
package/README.md CHANGED
@@ -1,20 +1,22 @@
1
+ [English](README.md) · [Español](README.es-ES.md) · [Français](README.fr-FR.md)
2
+
1
3
  # Better Auth Solana Payments
2
4
 
3
- One-time Solana payment integration for [Better Auth](https://www.better-auth.com).
5
+ Accept one-time Solana Pay payments for users or organizations with Better Auth. The server uses read-only RPC to verify transfers.
4
6
 
5
- ## Installation
7
+ ## Install
6
8
 
7
- ```bash
9
+ ```sh
8
10
  pnpm add better-auth better-auth-solana-payments solana-payments
9
11
  ```
10
12
 
11
- Requires Node.js 22.22.2 or later and solana-payments 1.x.
13
+ Requires Node.js 22+, Better Auth `>=1.4.22 <2`, and `solana-payments` `^1.1.0`.
12
14
 
13
- Existing installations must add the fulfillment fields before upgrading. For the default SQLite table and column names, see `migrations/0.2.0-sqlite.sql`; custom schemas must generate the equivalent Better Auth migration. Back up the database, verify paid-row fulfillment state, then deploy.
15
+ See the [API and compatibility policy](COMPATIBILITY.md).
14
16
 
15
- ## Server setup
17
+ ## Configure Better Auth
16
18
 
17
- Create a read-only Solana Payments SDK client and register the Better Auth plugin.
19
+ Set `SOLANA_RPC_URL` and `SOLANA_RECIPIENT` on the server. This example uses the mainnet USDT mint. Choose a matching mint and RPC endpoint for your cluster.
18
20
 
19
21
  ```ts
20
22
  import { betterAuth } from "better-auth";
@@ -28,170 +30,80 @@ const client = createReadOnlySolanaPayments({
28
30
  });
29
31
 
30
32
  export const auth = betterAuth({
31
- plugins: [
32
- solanaPayments({
33
- client,
34
- recipient: process.env.SOLANA_RECIPIENT!,
35
- }),
36
- ],
33
+ plugins: [solanaPayments({ client, recipient: process.env.SOLANA_RECIPIENT! })],
37
34
  });
38
35
  ```
39
36
 
40
- ## Client setup
37
+ Use a persistent Better Auth database adapter and mount your auth handler. Generate and apply the plugin schema before accepting payments. Existing installations that lack fulfillment fields should follow the [migration instructions](skills/solana-payment-verification/SKILL.md#existing-databases).
41
38
 
42
39
  ```ts
43
40
  import { createAuthClient } from "better-auth/client";
44
41
  import { solanaPaymentsClient } from "better-auth-solana-payments/client";
45
42
 
46
- export const authClient = createAuthClient({
47
- plugins: [solanaPaymentsClient()],
48
- });
43
+ export const authClient = createAuthClient({ plugins: [solanaPaymentsClient()] });
49
44
  ```
50
45
 
51
- ## One-time payment flow
52
-
53
- ```ts
54
- const created = await authClient.payment.create({
55
- // A decimal string in the configured token's display units; never use a JavaScript number.
56
- amount: "2.5",
57
- metadata: { orderId: "order_123" },
58
- });
59
-
60
- if (created.data?.paymentUrl) {
61
- // Present this Solana Pay URL as a link or QR code for the signed-in customer.
62
- window.location.assign(created.data.paymentUrl);
63
- }
46
+ ## Take a payment
64
47
 
65
- const verified = await authClient.payment.verify({
66
- reference: created.data!.reference,
67
- });
48
+ Create an intent from an authenticated session using a decimal string in token display units.
68
49
 
69
- if (verified.data?.status === "paid" && verified.data.fulfillmentStatus === "completed") {
70
- // Grant the entitlement only after server-side verification and fulfillment complete.
50
+ ```ts
51
+ const { data, error } = await authClient.payment.create({ amount: "2.5" });
52
+ if (error || !data?.paymentUrl) {
53
+ throw new Error(error?.message ?? "Could not create Solana payment");
71
54
  }
72
55
 
73
- const payment = await authClient.payment.get({
74
- reference: created.data!.reference,
75
- });
76
- ```
77
-
78
- `payment.create` persists a pending payment intent and returns its reference and Solana Pay URL.
79
- After the customer signs the transaction, call `payment.verify` with that reference. The server
80
- uses its configured RPC client to verify the matching token transfer before marking the payment
81
- paid. `payment.get` reads the current status without attempting verification.
82
-
83
- Amounts are decimal strings in the configured token's display units (for example, `"2.5"` is
84
- 2.5 USDT with the default six-decimal USDT token). Do not pass JavaScript numbers, which can lose
85
- precision for token amounts.
86
-
87
- If the wallet already returned a transaction signature, send it as the optional `signature` field
88
- to `payment.verify`. The SDK checks that candidate before scanning recent transactions, while still
89
- verifying the configured mint, recipient, amount, cluster and confirmation commitment. The plugin
90
- inherits the token program configured on the server's SDK client. Basic Token-2022 transfers are
91
- supported; transfer-fee and transfer-hook mints need extension-aware verification and are not
92
- accepted as ordinary transfers. See Solana's [payment verification guidance](https://solana.com/docs/payments/accept-payments/verification-tools)
93
- and [Token Extensions documentation](https://solana.com/docs/tokens/extensions) when configuring a mint.
94
-
95
- The browser may supply the amount, optional metadata, reference, optional transaction signature,
96
- and optional organization ID. The server controls the recipient and token configuration, so clients
97
- cannot redirect funds or choose another mint. The integration uses a read-only RPC client: it stores
98
- no private keys and never signs or sends a transaction on behalf of a customer.
99
-
100
- This package supports one-time payments only. It does not create recurring subscriptions or
101
- perform recurring charges.
102
-
103
- ## TanStack Start example
104
-
105
- The repository includes a runnable TanStack Start example at
106
- [`examples/tanstack`](./examples/tanstack). It demonstrates email/password auth, server-created
107
- Solana Pay requests, wallet checkout, and server-side verification against devnet RPC.
108
-
109
- ```bash
110
- cd examples/tanstack
111
- cp .env.example .env
112
- # Set SOLANA_MINT and SOLANA_RECIPIENT to your devnet SPL token and recipient.
113
- pnpm install
114
- pnpm dev
56
+ const { reference, paymentUrl } = data;
115
57
  ```
116
58
 
117
- The example uses an in-memory adapter and is intended for local development only. It does not
118
- store private keys or submit transactions. See its README for the repeatable RPC and on-chain
119
- smoke test (`pnpm test:devnet`) and the full wallet verification flow.
59
+ Keep the reference with your server-owned order. Present the payment URL as a Solana Pay link or QR code. After the customer submits the transaction, call `authClient.payment.verify({ reference })` and include the wallet's signature if available. Use `authClient.payment.get({ reference })` to read the stored status.
120
60
 
121
- For devnet, configure a devnet SPL-token mint; the built-in `SOLANA_USDT` preset is the mainnet
122
- USDT mint and must not be used for devnet testing. In production, use a persistent Better Auth
123
- adapter, a generated `BETTER_AUTH_SECRET`, and a dedicated RPC provider.
61
+ Match the payment to the order on the server and make `onPaymentComplete` idempotent by reference. Grant access after the payment is `paid` and fulfillment is `completed`. For organization payments, enable Better Auth's organization plugin and set `organization.enabled` in the Solana plugin and include the same `organizationId` on each payment call. See the [setup](skills/better-auth-solana-payments-setup/SKILL.md) and [verification](skills/solana-payment-verification/SKILL.md) guides.
124
62
 
125
- ### Fulfillment migration and retries
63
+ ## Run the TanStack demo with Docker
126
64
 
127
- Generate/apply your Better Auth schema migration before upgrading. Add `fulfillmentStatus` (default `pending`), nullable `fulfillmentToken`, and nullable `fulfillmentClaimedAt` to `solanaPayment`. Backfill previously paid rows to `completed` before accepting requests, so historical payments are not fulfilled again.
65
+ With Docker Compose 2.24 or later, run `docker compose up --build` from the repository root and open [http://localhost:3000](http://localhost:3000). Set `DEMO_PORT` in your shell to use another host port.
128
66
 
129
- Payment settlement and fulfillment are separate: verification persists `paid`, then claims a database lease before invoking `onPaymentComplete`. Failed callbacks return an error and leave fulfillment pending; retry verification to recover, including after a restart. A crashed worker's claim becomes recoverable after five minutes. Callbacks must be idempotent by payment reference, since a crash after an external side effect can cause a retry. Responses expose `fulfillmentStatus`; grant access only when it is `completed`.
67
+ The demo uses in-memory data. Restarting the container clears local accounts and demo billing records. To configure sandbox checkout, add the required values to the ignored root `.env.docker` file. Set `SOLANA_MINT`, `SOLANA_RECIPIENT`, and any RPC or token overrides for your devnet checkout. The container generates a local auth secret at startup when `BETTER_AUTH_SECRET` is unset.
130
68
 
131
- ## Settlement and operational edge cases
69
+ Run `docker compose down` to stop the demo. See [Contributing](CONTRIBUTING.md) for issue reports, local checks, and release notes.
132
70
 
133
- ### Confirmation depth
71
+ ## Standalone starters
134
72
 
135
- The SDK verifier requires at least `confirmed`, even if its client is configured with
136
- `processed`. Configure `commitment: "finalized"` when your application needs the strongest
137
- settlement state before fulfillment; a merely confirmed transaction then remains unaccepted.
138
- This is a commitment policy, not a configurable number of confirmations. Failed execution
139
- is rejected regardless of commitment. See [Solana's commitment definitions](https://solana.com/docs/rpc#configuring-state-commitment).
73
+ Scaffold a project with npm. TanStack Start is the default.
140
74
 
141
- Show an awaiting-confirmation state and retry server verification with bounded backoff for
142
- an unsettled transfer or RPC failure. `PAYMENT_MISMATCH` alone does not distinguish an
143
- unconfirmed transfer, absent transfer, wrong token/network, or a provider error. A browser
144
- wallet success notification is not settlement proof. Grant an entitlement only when the
145
- response has both `status === "paid"` and `fulfillmentStatus === "completed"`.
146
-
147
- Choose the commitment before accepting payments and keep it consistent: an already-paid
148
- intent retries fulfillment without re-verifying the chain, so changing the client to
149
- `finalized` does not upgrade previously recorded confirmed payments automatically.
75
+ ```sh
76
+ npm create better-auth-solana-payments@latest my-app
77
+ npm create better-auth-solana-payments@latest my-next-app -- --template nextjs
78
+ npm create better-auth-solana-payments@latest my-worker -- --template hono
79
+ ```
150
80
 
151
- ### Duplicate verification and callbacks
81
+ Set the environment variables from the generated README, then run `pnpm install --frozen-lockfile` and `pnpm dev`.
152
82
 
153
- Repeated browser verification calls share the stored payment. A conditional database claim
154
- allows one active fulfillment callback; completed fulfillment is not called again. Callback
155
- failure releases the claim for retry, and a crashed claim can be recovered after five minutes.
156
- This does not guarantee exactly-once external side effects: a crash after issuing an email,
157
- granting access, or updating another service can happen before completion is persisted.
83
+ Download the standalone TanStack starter from the next release. The archive includes the lockfile and environment template. Extract it, configure the sample environment file, then run `pnpm install --frozen-lockfile` and `pnpm dev`. [GitHub Releases](https://github.com/alexasomba/better-auth-solana-payments/releases)
158
84
 
159
- Make `onPaymentComplete` idempotent using the payment reference as a durable business key.
160
- Use a unique entitlement/fulfillment record and a transaction or outbox where possible;
161
- pass the same reference as an external service's idempotency key. Retry verification after
162
- a transient failure, including after a restart. The fulfillment migration and a persistent
163
- adapter are required; an in-memory adapter cannot coordinate separate workers.
85
+ From a repository checkout, export a starter with the released package or with a local tarball built by `vp pack` followed by `pnpm pack`.
164
86
 
165
- ### Refunds
87
+ ```sh
88
+ pnpm starter:export tanstack /tmp/solana-starter
89
+ pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-solana-payments.tgz
90
+ ```
166
91
 
167
- This read-only plugin has no refund endpoint and no `refunded` payment status. A refund is a
168
- separate authorized on-chain transfer, not a rollback of the settled transaction. Keep the
169
- original paid record as settlement evidence. An application refund ledger should record the
170
- payment reference, approved amount, token mint, cluster, destination, refund signature and
171
- confirmation state, and reconcile retries idempotently before sending again.
92
+ ## Demos and agent guides
172
93
 
173
- Verify the refund destination through your application's authenticated review flow; do not
174
- trust a browser-supplied address or infer the payer from an arbitrary transaction account.
175
- Use a separate controlled signing service/manual process. Mark a refund complete only after
176
- its chosen confirmation policy succeeds, then apply the application's entitlement policy.
177
- The plugin neither signs refunds nor automatically revokes access.
94
+ The [TanStack Start](examples/tanstack/README.md) and [Next.js](examples/nextjs/README.md) demos walk through sign-in, wallet checkout, and transfer verification. The [Hono example](examples/hono/README.md) exposes the same payment API from a Worker.
178
95
 
179
- ### Right token, wrong network
96
+ ### Solana Pay integration skills
180
97
 
181
- Token symbols are labels; the asset is identified by its cluster and mint address. Verification
182
- uses the server's configured RPC endpoint and token, and does not search other networks. A
183
- transfer on another Solana cluster, or USDT sent through another chain, does not settle this
184
- intent. The mainnet `SOLANA_USDT` preset is not a devnet token. See [Solana clusters](https://solana.com/docs/references/clusters).
98
+ - [Set up Solana Pay checkout and payment intents](skills/better-auth-solana-payments-setup/SKILL.md)
99
+ - [Verify Solana transactions and fulfill orders](skills/solana-payment-verification/SKILL.md)
100
+ - [Integrate Solana Pay in TanStack Start](skills/solana-tanstack-start/SKILL.md)
101
+ - [Integrate Solana Pay in Next.js App Router](skills/solana-nextjs/SKILL.md)
102
+ - [Integrate Solana Pay in Hono and Cloudflare Workers](skills/solana-hono/SKILL.md)
185
103
 
186
- Show the required network and mint before payment, check the wallet's network where possible,
187
- and keep the RPC/cluster/mint configuration fixed for outstanding intents. If verification
188
- cannot find a matching transfer, leave access unfulfilled; the intent remains pending until
189
- expiry. Do not switch the production verifier to another network or manually mark the intent
190
- paid to make the transaction appear to match.
104
+ The npm package includes these skills. With pnpm 12.11 or later, run `pnpm approve` after installing the package to review and approve its skills. Use TanStack Intent to list and load them from your project.
191
105
 
192
- Collect the transaction signature, actual network, mint and recipient for a support case,
193
- and independently verify them on that network. A missing result is not proof that funds were
194
- never sent. Explain that recovery depends on control of the recipient on the actual network;
195
- this plugin cannot bridge, reverse or recover those funds. If a reviewed recovery/refund is
196
- possible, track it separately and ask the customer to create a new intent on the required
197
- network. Never request a wallet seed phrase or private key.
106
+ ```sh
107
+ pnpm dlx @tanstack/intent list
108
+ pnpm dlx @tanstack/intent load better-auth-solana-payments#better-auth-solana-payments-setup
109
+ ```
package/dist/client.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { t as solanaPayments } from "./index-DlPQtl6v.mjs";
2
- import { BetterFetch, BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
1
+ import { c as PACKAGE_VERSION, t as solanaPayments } from "./index-C4Hqr385.mjs";
2
+ import { BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
3
3
  import { BetterAuthClientPlugin } from "better-auth/client";
4
- //#region src/client.d.ts
5
4
  export type FetchResult<T, O extends BetterFetchOption | undefined> = O extends {
6
5
  throw: true;
7
6
  } ? T : BetterFetchResponse<T>;
@@ -49,11 +48,12 @@ declare module "better-auth" {
49
48
  solanaPayments: ReturnType<typeof solanaPaymentsClient>;
50
49
  }
51
50
  }
52
- type SolanaPaymentsClientPluginInstance = Omit<BetterAuthClientPlugin, "id" | "$InferServerPlugin" | "getActions"> & {
51
+ type SolanaPaymentsClientPluginInstance = Omit<BetterAuthClientPlugin, "id" | "version" | "$InferServerPlugin" | "getActions"> & {
53
52
  id: "solanaPayments";
53
+ version: typeof PACKAGE_VERSION;
54
54
  $InferServerPlugin: ReturnType<typeof solanaPayments>;
55
- getActions: ($fetch: BetterFetch, $store: unknown, options: unknown) => SolanaPaymentsClientActions;
55
+ getActions: ($fetch: Parameters<NonNullable<BetterAuthClientPlugin["getActions"]>>[0], $store: unknown, options: unknown) => SolanaPaymentsClientActions;
56
56
  };
57
57
  export declare const solanaPaymentsClient: () => SolanaPaymentsClientPluginInstance;
58
- //#endregion
58
+ export {};
59
59
  //# sourceMappingURL=client.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.mts","names":["solanaPaymentsServer"],"sources":["../src/client.ts"],"mappings":";;;;YAMY,YAAY,GAAG,UAAU,iCAAiC;EAAY;IAC9E,IACA,oBAAoB;iBAEP;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,WAAW;EACX;;iBAGe;EACf,SAAS,UAAU,2CACjB;IACE;IACA,WAAW;IACX;KAEF,UAAU,MACP,QAAQ,YAAY,uBAAuB;EAChD,SAAS,UAAU,2CACjB;IAAQ;IAAmB;IAAoB;KAC/C,UAAU,MACP,QAAQ,YAAY,uBAAuB;EAChD,MAAM,UAAU,2CACd;IAAQ;IAAmB;KAC3B,UAAU,MACP,QAAQ,YAAY,uBAAuB;;iBAGjC;EACf,SAAS;;;YAIC;IACR,SAAS;;;;YAKD;IACR,gBAAgB,kBAAkB;;;KAIjC,qCAAqC,KACxC;EAGA;EACA,oBAAoB,kBAAkBA;EACtC,aACE,QAAQ,aACR,iBACA,qBACG;;qBAGM,4BAA2B"}
1
+ {"version":3,"file":"client.d.mts","names":["solanaPaymentsServer"],"sources":["../src/client.ts"],"mappings":";;;YAMY,YAAY,GAAG,UAAU,iCAAiC;EAAY;IAC9E,IACA,oBAAoB;iBAEP;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,WAAW;EACX;;iBAGe;EACf,SAAS,UAAU,2CACjB;IACE;IACA,WAAW;IACX;KAEF,UAAU,MACP,QAAQ,YAAY,uBAAuB;EAChD,SAAS,UAAU,2CACjB;IAAQ;IAAmB;IAAoB;KAC/C,UAAU,MACP,QAAQ,YAAY,uBAAuB;EAChD,MAAM,UAAU,2CACd;IAAQ;IAAmB;KAC3B,UAAU,MACP,QAAQ,YAAY,uBAAuB;;iBAGjC;EACf,SAAS;;;YAIC;IACR,SAAS;;;;YAKD;IACR,gBAAgB,kBAAkB;;;KAIjC,qCAAqC,KACxC;EAGA;EACA,gBAAgB;EAChB,oBAAoB,kBAAkBA;EACtC,aACE,QAAQ,WAAW,YAAY,2CAC/B,iBACA,qBACG;;qBAGM,4BAA2B"}
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as PACKAGE_VERSION } from "./version-B5dtK-2_.mjs";
2
- //#region src/client.ts
1
+ import { t as PACKAGE_VERSION } from "./version-CYmaVAD3.mjs";
2
+ // src/client.ts
3
3
  const solanaPaymentsClient = () => ({
4
4
  id: "solanaPayments",
5
5
  version: PACKAGE_VERSION,
@@ -27,7 +27,6 @@ const solanaPaymentsClient = () => ({
27
27
  })
28
28
  } })
29
29
  });
30
- //#endregion
31
30
  export { solanaPaymentsClient };
32
31
 
33
32
  //# sourceMappingURL=client.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterFetch, BetterFetchOption, BetterFetchResponse } from \"@better-fetch/fetch\";\nimport type { BetterAuthClientPlugin } from \"better-auth/client\";\n\nimport type { solanaPayments as solanaPaymentsServer } from \"./index.ts\";\nimport { PACKAGE_VERSION } from \"./version.ts\";\n\nexport type FetchResult<T, O extends BetterFetchOption | undefined> = O extends { throw: true }\n ? T\n : BetterFetchResponse<T>;\n\nexport interface SolanaPaymentResponse {\n id: string;\n reference: string;\n amount: string;\n mint: string;\n decimals: number;\n recipient: string;\n status: \"pending\" | \"paid\" | \"expired\" | \"failed\";\n fulfillmentStatus?: \"pending\" | \"processing\" | \"completed\";\n expiresAt: Date;\n signature?: string;\n slot?: string;\n metadata?: Record<string, unknown>;\n paymentUrl?: string;\n}\n\nexport interface SolanaPaymentActions {\n create: <O extends BetterFetchOption | undefined = undefined>(\n data: {\n amount: string;\n metadata?: Record<string, unknown>;\n organizationId?: string;\n },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n verify: <O extends BetterFetchOption | undefined = undefined>(\n data: { reference: string; signature?: string; organizationId?: string },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n get: <O extends BetterFetchOption | undefined = undefined>(\n data: { reference: string; organizationId?: string },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n}\n\nexport interface SolanaPaymentsClientActions {\n payment: SolanaPaymentActions;\n}\n\ndeclare module \"better-auth/client\" {\n interface BetterAuthClient {\n payment: SolanaPaymentActions;\n }\n}\n\ndeclare module \"better-auth\" {\n interface BetterAuthClientPlugins {\n solanaPayments: ReturnType<typeof solanaPaymentsClient>;\n }\n}\n\ntype SolanaPaymentsClientPluginInstance = Omit<\n BetterAuthClientPlugin,\n \"id\" | \"$InferServerPlugin\" | \"getActions\"\n> & {\n id: \"solanaPayments\";\n $InferServerPlugin: ReturnType<typeof solanaPaymentsServer>;\n getActions: (\n $fetch: BetterFetch,\n $store: unknown,\n options: unknown,\n ) => SolanaPaymentsClientActions;\n};\n\nexport const solanaPaymentsClient = (): SolanaPaymentsClientPluginInstance => ({\n id: \"solanaPayments\",\n version: PACKAGE_VERSION,\n $InferServerPlugin: {} as ReturnType<typeof solanaPaymentsServer>,\n pathMethods: {\n \"/solana-payments/create-payment\": \"POST\",\n \"/solana-payments/verify-payment\": \"POST\",\n \"/solana-payments/payment\": \"GET\",\n },\n getActions: ($fetch): SolanaPaymentsClientActions => ({\n payment: {\n create: (data, options) =>\n $fetch(\"/solana-payments/create-payment\", {\n ...options,\n method: \"POST\",\n body: data,\n }),\n verify: (data, options) =>\n $fetch(\"/solana-payments/verify-payment\", {\n ...options,\n method: \"POST\",\n body: data,\n }),\n get: (data, options) =>\n $fetch(\"/solana-payments/payment\", { ...options, method: \"GET\", query: data }),\n },\n }),\n});\n"],"mappings":";;AA0EA,MAAa,8BAAkE;CAC7E,IAAI;CACJ,SAAS;CACT,oBAAoB,CAAC;CACrB,aAAa;EACX,mCAAmC;EACnC,mCAAmC;EACnC,4BAA4B;CAC9B;CACA,aAAa,YAAyC,EACpD,SAAS;EACP,SAAS,MAAM,YACb,OAAO,mCAAmC;GACxC,GAAG;GACH,QAAQ;GACR,MAAM;EACR,CAAC;EACH,SAAS,MAAM,YACb,OAAO,mCAAmC;GACxC,GAAG;GACH,QAAQ;GACR,MAAM;EACR,CAAC;EACH,MAAM,MAAM,YACV,OAAO,4BAA4B;GAAE,GAAG;GAAS,QAAQ;GAAO,OAAO;EAAK,CAAC;CACjF,EACF;AACF"}
1
+ {"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterFetchOption, BetterFetchResponse } from \"@better-fetch/fetch\";\nimport type { BetterAuthClientPlugin } from \"better-auth/client\";\n\nimport type { solanaPayments as solanaPaymentsServer } from \"./index.ts\";\nimport { PACKAGE_VERSION } from \"./version.ts\";\n\nexport type FetchResult<T, O extends BetterFetchOption | undefined> = O extends { throw: true }\n ? T\n : BetterFetchResponse<T>;\n\nexport interface SolanaPaymentResponse {\n id: string;\n reference: string;\n amount: string;\n mint: string;\n decimals: number;\n recipient: string;\n status: \"pending\" | \"paid\" | \"expired\" | \"failed\";\n fulfillmentStatus?: \"pending\" | \"processing\" | \"completed\";\n expiresAt: Date;\n signature?: string;\n slot?: string;\n metadata?: Record<string, unknown>;\n paymentUrl?: string;\n}\n\nexport interface SolanaPaymentActions {\n create: <O extends BetterFetchOption | undefined = undefined>(\n data: {\n amount: string;\n metadata?: Record<string, unknown>;\n organizationId?: string;\n },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n verify: <O extends BetterFetchOption | undefined = undefined>(\n data: { reference: string; signature?: string; organizationId?: string },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n get: <O extends BetterFetchOption | undefined = undefined>(\n data: { reference: string; organizationId?: string },\n options?: O,\n ) => Promise<FetchResult<SolanaPaymentResponse, O>>;\n}\n\nexport interface SolanaPaymentsClientActions {\n payment: SolanaPaymentActions;\n}\n\ndeclare module \"better-auth/client\" {\n interface BetterAuthClient {\n payment: SolanaPaymentActions;\n }\n}\n\ndeclare module \"better-auth\" {\n interface BetterAuthClientPlugins {\n solanaPayments: ReturnType<typeof solanaPaymentsClient>;\n }\n}\n\ntype SolanaPaymentsClientPluginInstance = Omit<\n BetterAuthClientPlugin,\n \"id\" | \"version\" | \"$InferServerPlugin\" | \"getActions\"\n> & {\n id: \"solanaPayments\";\n version: typeof PACKAGE_VERSION;\n $InferServerPlugin: ReturnType<typeof solanaPaymentsServer>;\n getActions: (\n $fetch: Parameters<NonNullable<BetterAuthClientPlugin[\"getActions\"]>>[0],\n $store: unknown,\n options: unknown,\n ) => SolanaPaymentsClientActions;\n};\n\nexport const solanaPaymentsClient = (): SolanaPaymentsClientPluginInstance => ({\n id: \"solanaPayments\",\n version: PACKAGE_VERSION,\n $InferServerPlugin: {} as ReturnType<typeof solanaPaymentsServer>,\n pathMethods: {\n \"/solana-payments/create-payment\": \"POST\",\n \"/solana-payments/verify-payment\": \"POST\",\n \"/solana-payments/payment\": \"GET\",\n },\n getActions: ($fetch): SolanaPaymentsClientActions => ({\n payment: {\n create: (data, options) =>\n $fetch(\"/solana-payments/create-payment\", {\n ...options,\n method: \"POST\",\n body: data,\n }),\n verify: (data, options) =>\n $fetch(\"/solana-payments/verify-payment\", {\n ...options,\n method: \"POST\",\n body: data,\n }),\n get: (data, options) =>\n $fetch(\"/solana-payments/payment\", { ...options, method: \"GET\", query: data }),\n },\n }),\n});\n"],"mappings":";;AA2EA,MAAa,8BAAkE;CAC7E,IAAI;CACJ,SAAS;CACT,oBAAoB,CAAC;CACrB,aAAa;EACX,mCAAmC;EACnC,mCAAmC;EACnC,4BAA4B;CAC9B;CACA,aAAa,YAAyC,EACpD,SAAS;EACP,SAAS,MAAM,YACb,OAAO,mCAAmC;GACxC,GAAG;GACH,QAAQ;GACR,MAAM;EACR,CAAC;EACH,SAAS,MAAM,YACb,OAAO,mCAAmC;GACxC,GAAG;GACH,QAAQ;GACR,MAAM;EACR,CAAC;EACH,MAAM,MAAM,YACV,OAAO,4BAA4B;GAAE,GAAG;GAAS,QAAQ;GAAO,OAAO;EAAK,CAAC;CACjF,EACF;AACF"}