better-auth-solana-payments 0.5.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.
- package/README.es-ES.md +2 -0
- package/README.fr-FR.md +2 -0
- package/README.md +18 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{index-BQ-nihZA.d.mts → index-C4Hqr385.d.mts} +3 -3
- package/dist/{index-BQ-nihZA.d.mts.map → index-C4Hqr385.d.mts.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/version-CYmaVAD3.mjs +5 -0
- package/dist/version-CYmaVAD3.mjs.map +1 -0
- package/package.json +2 -2
- package/skills/better-auth-solana-payments-setup/SKILL.md +5 -3
- package/skills/solana-hono/SKILL.md +20 -0
- package/skills/solana-hono/agents/openai.yaml +6 -0
- package/skills/solana-nextjs/SKILL.md +20 -0
- package/skills/solana-nextjs/agents/openai.yaml +6 -0
- package/skills/solana-payment-verification/SKILL.md +6 -4
- package/skills/solana-tanstack-start/SKILL.md +20 -0
- package/skills/solana-tanstack-start/agents/openai.yaml +6 -0
- package/dist/version-BXUGEOkG.mjs +0 -5
- package/dist/version-BXUGEOkG.mjs.map +0 -1
package/README.es-ES.md
CHANGED
|
@@ -81,6 +81,8 @@ pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-so
|
|
|
81
81
|
|
|
82
82
|
## Demo y habilidades para agentes
|
|
83
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
|
+
|
|
84
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.
|
|
85
87
|
|
|
86
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.
|
package/README.fr-FR.md
CHANGED
|
@@ -81,6 +81,8 @@ pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-so
|
|
|
81
81
|
|
|
82
82
|
## Démo et compétences pour agents
|
|
83
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
|
+
|
|
84
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.
|
|
85
87
|
|
|
86
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.
|
package/README.md
CHANGED
|
@@ -60,6 +60,14 @@ Keep the reference with your server-owned order. Present the payment URL as a So
|
|
|
60
60
|
|
|
61
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.
|
|
62
62
|
|
|
63
|
+
## Run the TanStack demo with Docker
|
|
64
|
+
|
|
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.
|
|
66
|
+
|
|
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.
|
|
68
|
+
|
|
69
|
+
Run `docker compose down` to stop the demo. See [Contributing](CONTRIBUTING.md) for issue reports, local checks, and release notes.
|
|
70
|
+
|
|
63
71
|
## Standalone starters
|
|
64
72
|
|
|
65
73
|
Scaffold a project with npm. TanStack Start is the default.
|
|
@@ -81,11 +89,19 @@ pnpm starter:export tanstack /tmp/solana-starter
|
|
|
81
89
|
pnpm starter:export tanstack /tmp/solana-local --tarball /path/to/better-auth-solana-payments.tgz
|
|
82
90
|
```
|
|
83
91
|
|
|
84
|
-
##
|
|
92
|
+
## Demos and agent guides
|
|
85
93
|
|
|
86
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.
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
### Solana Pay integration skills
|
|
97
|
+
|
|
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)
|
|
103
|
+
|
|
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.
|
|
89
105
|
|
|
90
106
|
```sh
|
|
91
107
|
pnpm dlx @tanstack/intent list
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as PACKAGE_VERSION, t as solanaPayments } from "./index-
|
|
1
|
+
import { c as PACKAGE_VERSION, t as solanaPayments } from "./index-C4Hqr385.mjs";
|
|
2
2
|
import { BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
|
|
3
3
|
import { BetterAuthClientPlugin } from "better-auth/client";
|
|
4
4
|
export type FetchResult<T, O extends BetterFetchOption | undefined> = O extends {
|
package/dist/client.mjs
CHANGED
|
@@ -40,7 +40,7 @@ interface SolanaPaymentsOptions {
|
|
|
40
40
|
};
|
|
41
41
|
schema?: InferOptionSchema<SolanaPaymentsPluginSchema>;
|
|
42
42
|
}
|
|
43
|
-
declare const PACKAGE_VERSION = "0.5.
|
|
43
|
+
declare const PACKAGE_VERSION = "0.5.1";
|
|
44
44
|
type Adapter = {
|
|
45
45
|
create<T>(input: {
|
|
46
46
|
model: string;
|
|
@@ -97,7 +97,7 @@ interface SolanaPaymentStore {
|
|
|
97
97
|
declare function createSolanaPaymentStore(context: SolanaPaymentStoreContext): SolanaPaymentStore;
|
|
98
98
|
declare function solanaPayments(input: SolanaPaymentsOptions): {
|
|
99
99
|
id: "solanaPayments";
|
|
100
|
-
version: "0.5.
|
|
100
|
+
version: "0.5.1";
|
|
101
101
|
endpoints: {
|
|
102
102
|
createPayment: import("better-auth").StrictEndpoint<"/solana-payments/create-payment", {
|
|
103
103
|
method: "POST";
|
|
@@ -245,4 +245,4 @@ declare function solanaPayments(input: SolanaPaymentsOptions): {
|
|
|
245
245
|
};
|
|
246
246
|
};
|
|
247
247
|
export { SolanaPaymentStore as a, PACKAGE_VERSION as c, SolanaPaymentsOptions as d, getSchema as f, MarkPaidResult as i, SolanaPayment as l, CreateSolanaPaymentInput as n, SolanaPaymentStoreContext as o, solanaPaymentsPluginSchema as p, MarkPaidInput as r, createSolanaPaymentStore as s, solanaPayments as t, SolanaPaymentStatus as u };
|
|
248
|
-
//# sourceMappingURL=index-
|
|
248
|
+
//# sourceMappingURL=index-C4Hqr385.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-C4Hqr385.d.mts","names":[],"sources":["../src/schema.ts","../src/types.ts","../src/version.ts","../src/store.ts","../src/index.ts"],"mappings":";;;KAIK,sBAAsB;EAGvB,QAAQ,kQAkBN;;KA6BM,6BAA6B;cAC5B,4BAA4B;iBAEzB,UACd,SAAS,KAAK,mCACb;KCtDS;UAEK;EACf;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,uBAAuB;EACvB,WAAW;EACX;;EAEA;EACA;EACA,WAAW;EACX,WAAW;;UAGI;EACf,QAAQ;EACR,WAAW;EACX;EACA,qBACE,SAAS,eACT,SAAS,2BACN;EACL;IACE;;EAEF,SAAS,kBAAkB;;cCzChB;KCMR;EACH,OAAO,GAAG;IAAS;IAAe,MAAM,KAAK;MAAa,QAAQ;EAClE,QAAQ,GAAG;IAAS;IAAe,OAAO;MAAgB,QAAQ;EAClE,OAAO,GAAG;IAAS;IAAe,QAAQ,QAAQ;IAAI,OAAO;MAAgB,QAAQ;;KAElF;EACC;EAAe;;EACf;EAAe;EAAgB;;UAGpB;EACf,SAAS;EACT;IAAY;MAAS;;;EACrB;EACA;;KAGU,2BAA2B,KACrC;UAIe;EACf;EACA;;UAGe;EACf,SAAS;EACT;;UAGe;EACf,eAAe;EACf,OAAO,OAAO,2BAA2B,QAAQ;EACjD,SAAS,aAAa,QAAQ;EAC9B,gBAAgB,oBAAoB,QAAQ;EAC5C,SAAS,mBAAmB,QAAQ,gBAAgB,QAAQ;EAC5D,uBACE,mBACA,QAAQ,eACR,2BACC,QAAQ;EACX,iBAAiB,oBAAoB,QAAQ;EAC7C,kBACE,mBACA,eACA,qBACC,QAAQ;EACX,YAAY,oBAAoB,QAAQ;;iBAG1B,yBAAyB,SAAS,4BAA4B;iBC7B9D,eAAe,OAAO;;;;IAgBhC,qCAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACb,qCAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACb,kCAAU"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SolanaPaymentStore, c as PACKAGE_VERSION, d as SolanaPaymentsOptions, f as getSchema, i as MarkPaidResult, l as SolanaPayment, n as CreateSolanaPaymentInput, o as SolanaPaymentStoreContext, p as solanaPaymentsPluginSchema, r as MarkPaidInput, s as createSolanaPaymentStore, t as solanaPayments, u as SolanaPaymentStatus } from "./index-
|
|
1
|
+
import { a as SolanaPaymentStore, c as PACKAGE_VERSION, d as SolanaPaymentsOptions, f as getSchema, i as MarkPaidResult, l as SolanaPayment, n as CreateSolanaPaymentInput, o as SolanaPaymentStoreContext, p as solanaPaymentsPluginSchema, r as MarkPaidInput, s as createSolanaPaymentStore, t as solanaPayments, u as SolanaPaymentStatus } from "./index-C4Hqr385.mjs";
|
|
2
2
|
export { type CreateSolanaPaymentInput, type MarkPaidInput, type MarkPaidResult, PACKAGE_VERSION, type SolanaPayment, type SolanaPaymentStatus, type SolanaPaymentStore, type SolanaPaymentStoreContext, type SolanaPaymentsOptions, createSolanaPaymentStore, getSchema, solanaPayments, solanaPaymentsPluginSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-CYmaVAD3.mjs";
|
|
2
2
|
import { defineErrorCodes } from "better-auth";
|
|
3
3
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
4
4
|
import { APIError, createAuthEndpoint, getSessionFromCtx, originCheckMiddleware, sessionMiddleware } from "better-auth/api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-CYmaVAD3.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = \"0.5.1\"; // x-release-please-version\n"],"mappings":";AAAA,MAAa,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth-solana-payments",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "One-time Solana payment integration for Better Auth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"better-auth",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
50
50
|
"@better-fetch/fetch": "1.3.3",
|
|
51
|
-
"@types/node": "^
|
|
51
|
+
"@types/node": "^26.6.10",
|
|
52
52
|
"better-auth": "1.7.28",
|
|
53
53
|
"publint": "^0.3.25",
|
|
54
54
|
"typescript": "7.0.2",
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: better-auth-solana-payments-setup
|
|
3
3
|
description: >-
|
|
4
|
-
Set up
|
|
4
|
+
Set up one-time Solana Pay checkout with Better Auth. Use for server and browser plugin setup, RPC and token configuration, payment intents, and organization checkout.
|
|
5
5
|
license: MIT
|
|
6
6
|
metadata:
|
|
7
7
|
library: better-auth-solana-payments
|
|
8
|
-
library_version: "0.5.
|
|
8
|
+
library_version: "0.5.1" # x-release-please-version
|
|
9
9
|
purpose: Configure a new Solana payment integration and create the first payment intent.
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
# Set up Solana
|
|
12
|
+
# Set up Solana Pay checkout with Better Auth
|
|
13
|
+
|
|
14
|
+
Create a Solana Pay wallet link or QR code from an authenticated Better Auth payment intent. Configure the Solana RPC, token mint, and recipient on the server.
|
|
13
15
|
|
|
14
16
|
1. Install `better-auth-solana-payments`, `better-auth`, and `solana-payments`. Use Node.js 22+, Better Auth `>=1.4.22 <2`, and the Solana SDK `^1.1.0`.
|
|
15
17
|
2. On the server, create a `createReadOnlySolanaPayments` client with your RPC URL, token, and commitment. The `SOLANA_USDT` preset uses the mainnet USDT mint. Configure a mint on the same cluster as the RPC endpoint and recipient. Set a dedicated RPC provider for production.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: solana-hono
|
|
3
|
+
description: >-
|
|
4
|
+
Integrate Solana Pay with Better Auth in a Hono Cloudflare Worker. Use for authenticated payment intent endpoints, devnet RPC bindings, and server-side transfer verification.
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
library: better-auth-solana-payments
|
|
8
|
+
library_version: "0.5.1" # x-release-please-version
|
|
9
|
+
purpose: Mount Better Auth and Solana Pay in Hono and validate its authenticated payment API.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Solana Pay in Hono with Better Auth
|
|
13
|
+
|
|
14
|
+
1. For a new Worker, run `npm create better-auth-solana-payments@latest my-worker -- --template hono`. Follow the generated README. In an existing app, configure the server plugin using the [Solana Pay setup skill](../better-auth-solana-payments-setup/SKILL.md).
|
|
15
|
+
2. Copy `.dev.vars.example` to `.dev.vars` for Wrangler. Read `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `SOLANA_RPC_URL`, `SOLANA_MINT`, `SOLANA_DECIMALS`, and `SOLANA_RECIPIENT` from server bindings. Use the recipient wallet address and match the RPC cluster, mint, and mint precision. Replace the in-memory demo adapter with a persistent database and apply the schema before accepting payments.
|
|
16
|
+
3. Mount `app.all("/api/auth/*", ...)` in a typed Hono app. Resolve the auth configuration using `c.env` and pass `c.req.raw` to `auth.handler`. Keep the public Better Auth URL aligned with the mounted Worker.
|
|
17
|
+
4. Check `GET /health`, then sign in through Better Auth and keep the session cookie. With that cookie, call `POST /api/auth/solana-payments/create-payment` with a decimal amount string and `GET /api/auth/solana-payments/payment?reference=...` to read the payment. After wallet submission, call `POST /api/auth/solana-payments/verify-payment` with the stored reference. Grant access after the verified payment matches the server-owned order and fulfillment is complete. See [verification and fulfillment](../solana-payment-verification/SKILL.md).
|
|
18
|
+
5. Run `pnpm typecheck` and `pnpm build` for TypeScript and a Wrangler dry run. Use `pnpm dev` to exercise the routes with local bindings and devnet.
|
|
19
|
+
|
|
20
|
+
[Hono starter](https://github.com/alexasomba/better-auth-solana-payments/tree/main/examples/hono) · [Better Auth Hono integration](https://better-auth.com/docs/integrations/hono)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Solana Pay with Better Auth in Hono"
|
|
3
|
+
short_description: "Solana Pay endpoints and transfer verification in Hono"
|
|
4
|
+
default_prompt: "Use $solana-hono to add authenticated Solana Pay routes to my Hono Worker."
|
|
5
|
+
policy:
|
|
6
|
+
allow_implicit_invocation: true
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: solana-nextjs
|
|
3
|
+
description: >-
|
|
4
|
+
Integrate Solana Pay checkout with Better Auth in Next.js App Router. Use for auth route handlers, wallet links, devnet payment intents, and server-side transfer verification.
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
library: better-auth-solana-payments
|
|
8
|
+
library_version: "0.5.1" # x-release-please-version
|
|
9
|
+
purpose: Mount Better Auth and Solana Pay in Next.js and verify wallet checkout.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Solana Pay in Next.js with Better Auth
|
|
13
|
+
|
|
14
|
+
1. For a new app, run `npm create better-auth-solana-payments@latest my-app -- --template nextjs`. Follow the generated README. In an existing app, add the server and client plugins using the [Solana Pay setup skill](../better-auth-solana-payments-setup/SKILL.md).
|
|
15
|
+
2. Copy `.env.example` to `.env.local`. Use a generated `BETTER_AUTH_SECRET` and set `BETTER_AUTH_URL` to the app origin. Set `SOLANA_RPC_URL`, `SOLANA_MINT`, `SOLANA_DECIMALS`, and `SOLANA_RECIPIENT` on the server. Use the recipient wallet address and match the RPC cluster, mint, and mint precision. Use a devnet mint during local testing.
|
|
16
|
+
3. Export `GET` and `POST` from `app/api/auth/[...all]/route.ts`. The starter uses a shared handler that awaits `getAuth()` and forwards the original request to `auth.handler(request)`. Keep the RPC client in the server auth module. Before accepting payments, replace the demo's in-memory adapter with persistent storage and apply the plugin schema.
|
|
17
|
+
4. Register `solanaPaymentsClient()` from `better-auth-solana-payments/client` in the browser. From a signed-in session, use `payment.create({ amount })` with a decimal string, open `paymentUrl` in the wallet, and verify the stored reference with `payment.verify({ reference })`. Match the verified payment to the server-owned order and grant access after payment and fulfillment complete. See [verification and fulfillment](../solana-payment-verification/SKILL.md).
|
|
18
|
+
5. Run `pnpm typecheck` and `pnpm build`. Check email sign-in, intent creation, and wallet verification on devnet. Use `pnpm preview` to check the OpenNext Worker runtime if targeting Cloudflare.
|
|
19
|
+
|
|
20
|
+
[Next.js starter](https://github.com/alexasomba/better-auth-solana-payments/tree/main/examples/nextjs) · [Next.js Route Handlers](https://nextjs.org/docs/app/getting-started/route-handlers)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Solana Pay with Better Auth in Next.js"
|
|
3
|
+
short_description: "Solana Pay checkout in Next.js App Router"
|
|
4
|
+
default_prompt: "Use $solana-nextjs to add a Solana Pay checkout and verify transfers in my Next.js app."
|
|
5
|
+
policy:
|
|
6
|
+
allow_implicit_invocation: true
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: solana-payment-verification
|
|
3
3
|
description: >-
|
|
4
|
-
Verify
|
|
4
|
+
Verify Solana Pay transactions in Better Auth. Use for finalized transfers, wallet signatures, retryable verification, fulfillment callbacks, and schema upgrades.
|
|
5
5
|
license: MIT
|
|
6
6
|
metadata:
|
|
7
7
|
library: better-auth-solana-payments
|
|
8
|
-
library_version: "0.5.
|
|
8
|
+
library_version: "0.5.1" # x-release-please-version
|
|
9
9
|
purpose: Confirm Solana transfers and make application fulfillment recoverable.
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
# Verify and fulfill
|
|
12
|
+
# Verify Solana Pay transactions and fulfill orders with Better Auth
|
|
13
|
+
|
|
14
|
+
Verify a Solana Pay transfer against the original payment intent before fulfilling the order. Handle pending transactions and retries without duplicating side effects.
|
|
13
15
|
|
|
14
16
|
1. After the wallet submits the transaction, call `authClient.payment.verify({ reference, signature })` using the original intent reference. The signature is optional and allows the SDK to check that candidate before scanning history. Include the intent's `organizationId` if it is organization-scoped. Use `payment.get({ reference })` with the same scope to read stored state without an RPC verification.
|
|
15
|
-
2. Use the configured mint, token program, recipient, reference, and expected amount to validate the transfer. The
|
|
17
|
+
2. Use the configured mint, token program, recipient, reference, and expected amount to validate the transfer. The plugin requires `finalized` settlement before marking an intent paid. A transfer observed at `confirmed` remains pending. Keep the network and token configuration stable for outstanding intents.
|
|
16
18
|
3. On a transient RPC failure or while waiting for confirmation, retry verification with bounded backoff. A mismatch can mean the transfer is still unconfirmed or used a different asset or destination. Keep the payment pending and collect the signature, network, mint, and recipient for investigation.
|
|
17
19
|
4. In `onPaymentComplete`, match the payment against the server-owned order and make side effects idempotent by reference. A conditional database claim allows one active callback. Failed callbacks can be retried through verification, and a crashed claim can be recovered after five minutes. Grant application access only after the server has confirmed the order and completed fulfillment.
|
|
18
20
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: solana-tanstack-start
|
|
3
|
+
description: >-
|
|
4
|
+
Integrate Solana Pay checkout with Better Auth in TanStack Start. Use for the auth catch-all route, server-function cookies, Solana Pay wallet links, and devnet transfer verification.
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
library: better-auth-solana-payments
|
|
8
|
+
library_version: "0.5.1" # x-release-please-version
|
|
9
|
+
purpose: Mount Better Auth and Solana Pay in TanStack Start and verify one-time SPL-token payments.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Solana Pay in TanStack Start with Better Auth
|
|
13
|
+
|
|
14
|
+
1. For a new app, run `npm create better-auth-solana-payments@latest my-app` and follow the generated README. In an existing app, configure `solanaPayments()` in the server auth module using the [Solana Pay setup skill](../better-auth-solana-payments-setup/SKILL.md).
|
|
15
|
+
2. Mount `auth.handler(request)` on both `GET` and `POST` in `src/routes/api/auth/$.ts`. Put `tanstackStartCookies()` from `better-auth/tanstack-start` last in the Better Auth plugin array when calling server APIs that set session cookies from Start server functions.
|
|
16
|
+
3. Copy `.env.example` to `.env` for the starter. Set a generated `BETTER_AUTH_SECRET` and point `BETTER_AUTH_URL` at the app origin. Keep the RPC configuration, token mint, token decimals, and recipient wallet address on the server. Use a mint on the RPC's cluster and a devnet wallet funded with that token for the demo. Replace the in-memory adapter with persistent storage and apply the plugin schema before accepting payments.
|
|
17
|
+
4. Register `solanaPaymentsClient()` from `better-auth-solana-payments/client` in the `better-auth/react` client. In an authenticated session, call `authClient.payment.create({ amount })` with a display-unit decimal string and open the server-generated `paymentUrl` in the wallet. Use `payment.get({ reference })` for owner-scoped history and `payment.verify({ reference })` after the wallet submits the transfer. Match the verified payment to the server-owned order and grant access after payment and fulfillment complete. [Verification and fulfillment](../solana-payment-verification/SKILL.md)
|
|
18
|
+
5. Run `pnpm typecheck`, `pnpm test`, and `pnpm build`. After setting devnet configuration, `pnpm test:devnet` checks the RPC and generates a payment request. Use the signed-in browser and wallet flow to check a real devnet transfer.
|
|
19
|
+
|
|
20
|
+
[TanStack Start starter](https://github.com/alexasomba/better-auth-solana-payments/tree/main/examples/tanstack) · [Better Auth TanStack Start integration](https://better-auth.com/docs/integrations/tanstack)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Solana Pay with Better Auth in TanStack Start"
|
|
3
|
+
short_description: "Solana Pay checkout and verification in TanStack Start"
|
|
4
|
+
default_prompt: "Use $solana-tanstack-start to add a Solana Pay wallet checkout to my TanStack Start app."
|
|
5
|
+
policy:
|
|
6
|
+
allow_implicit_invocation: true
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version-BXUGEOkG.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = \"0.5.0\"; // x-release-please-version\n"],"mappings":";AAAA,MAAa,kBAAkB"}
|