openreceive-rails 0.4.10 → 0.4.13

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.
@@ -1,6 +1,6 @@
1
1
  # OpenReceive agent directions (Next.js)
2
2
 
3
- These directions describe OpenReceive 0.4.10.
3
+ These directions describe OpenReceive 0.4.13.
4
4
 
5
5
  Add OpenReceive to a Next.js App Router application — the app you are already
6
6
  working in. You do not need a copy of the OpenReceive source: the packages are
@@ -34,64 +34,90 @@ The one required credential is a receive-only NWC code (Nostr Wallet Connect):
34
34
  a string from the merchant's wallet that can create invoices and read their
35
35
  status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
36
36
  payer send USDT, USDC, ETH or SOL instead, converted into that same
37
- Lightning payment. You supply those credentials and three hooks — `authorize`, `amountFor`,
37
+ Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`, `amountFor`,
38
38
  `onPaid`;
39
39
  OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
40
40
  owns orders, users, prices, or fulfillment.
41
41
 
42
- ## Step 0 — check the environment before you write code
43
-
44
- Do this before installing packages or editing files.
45
-
46
- 1. Look for `NWC_URI` in this app's server environment — `.env.local`, the
47
- process env, the deploy config, whatever this app already uses. Next loads
48
- `.env.local` itself: do not add `dotenv`, and never give a credential a
49
- `NEXT_PUBLIC_` prefix, which inlines it into the browser bundle. If the app runs in a
50
- container the value is in none of those: ask the running process
51
- (`docker exec <container> printenv NWC_URI`), because finding the NAME in a
52
- compose file proves nothing about the value. Never print or echo the value
53
- itself; only report whether it is set. Check for `LSC_URI_PRIMARY` in the
54
- same pass.
55
- 2. If BOTH are already set — the common case in an existing app — say so and go
56
- straight to the quickstart. Steps 3 and 4 are for an environment that is
57
- missing one; do not stop to ask about altcoins that are already configured.
58
- If only `NWC_URI` is set, Bitcoin already works: continue, and raise the
59
- altcoin question at step 4 rather than blocking on it.
60
- 3. If `NWC_URI` is missing or empty, stop and tell the user exactly what to
61
- create:
62
-
63
- > OpenReceive cannot issue an invoice without a receive-only NWC code. Get
64
- > one at https://openreceive.org/get_a_nwc_code_to_receive_payments, then
65
- > put `NWC_URI=<the code>` in this app's server environment — for a Next
66
- > app that is `.env.local` in the project root — and tell me when it's set.
67
-
68
- Wait for the user before wiring OpenReceive; do not invent a placeholder
69
- value. Waiting is not idleness: you may write `.env.example` with the
70
- variable NAMES only (`NWC_URI=`, `LSC_URI_PRIMARY=`) so the merchant has a
71
- file to copy, and keep building the parts of the host that do not touch
72
- OpenReceive — the order model, the cart, the routes. The stop guards the
73
- credential, not the rest of the app.
74
- 4. If `LSC_URI_PRIMARY` was not already set, ask the user: "Do you want to
75
- accept altcoins and stablecoins (USDT, USDC, ETH, SOL) as well as
76
- Bitcoin?"
77
-
78
- - Yes → send them to https://openreceive.org/set_up_swap_provider for a
79
- swap-provider (LSC) code, to set as `LSC_URI_PRIMARY` in the same server
80
- environment. Do NOT wait for it: no application code reads the value, so
81
- the integration is identical with or without it — the library picks it up
82
- from the environment and swaps switch on. What a yes DOES change is the
83
- refund route back (the swap non-negotiable below): build it as part of
84
- this integration, not when the code arrives.
85
- - No → skip it. Bitcoin over Lightning works with `NWC_URI` alone, and you
86
- can add a swap provider later without changing application code.
87
- 5. Check the environment again and confirm `NWC_URI` is present.
88
- `LSC_URI_PRIMARY` may land later; swaps stay off until it does, and no code
89
- changes when it arrives.
90
- 6. If OpenReceive is ALREADY installed here, check the installed versions of
91
- `@openreceive/node` and `@openreceive/browser` against the release named at
92
- the top of this file. The headless display models below do not exist in
93
- older versions, and the first tile click throws with nothing saying why.
94
- Upgrade first.
42
+ ## Step 0 — ask for the two codes, one question at a time
43
+
44
+ Before anything else, look at one file: the project's `.env.local`, if it exists.
45
+ Read it only far enough to see whether `NWC_URI` and `LSC_URI_PRIMARY` are
46
+ there and non-empty, and never print the values. A code that is already
47
+ set is not asked for again; if both are set, skip to step 5
48
+ (making the server load the file), then the quickstart.
49
+
50
+ Otherwise your next action is a question to the user. Do not install packages,
51
+ edit the app, write `.env.example`, or search anywhere else before asking
52
+ it. Do not read deploy config (compose files, Vercel or platform secrets), Docker containers, or process environments, and never run
53
+ `printenv`. A new shop has neither code yet: hunting for one burns the turn and
54
+ can leak other secrets into the transcript.
55
+
56
+ Two server-only URIs are needed before the quickstart:
57
+
58
+ - `NWC_URI` — a receive-only Nostr Wallet Connect code,
59
+ `nostr+walletconnect://…`. Required for Bitcoin.
60
+ - `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
61
+ `lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
62
+ only when the user says they want Bitcoin alone.
63
+
64
+ The user never edits an environment file. They paste each code into the chat;
65
+ you store it. Ask one question per message.
66
+
67
+ 1. **First message — the NWC code, and nothing else.** Ask for it and walk them
68
+ through getting it:
69
+
70
+ > To receive payments I need a receive-only wallet code. In Rizful: open
71
+ > the menu, tap NWC, choose Receive-only NWC code, and tap Copy
72
+ > (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
73
+ > rather run your own wallet, Alby Hub works too: Connections → Add
74
+ > Connection → Read Only. Paste the code here and I will store it.
75
+
76
+ Do not mention `.env`, exports, or "tell me when it's set".
77
+ 2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
78
+ ask them to copy the receive-only code again. Otherwise write
79
+ `NWC_URI=<paste>` into the project's `.env.local`, creating the file if needed.
80
+ Make sure `.gitignore` covers `.env.local` (and `.dockerignore`, if the app has
81
+ one). Never echo the value, commit it, or put it in client code. Reply only
82
+ that it is saved, then ask the next question.
83
+ 3. **Second message — swaps.** If the user already asked for stablecoins or
84
+ altcoins, skip the yes/no and go straight to the walkthrough. Otherwise ask
85
+ whether payers should also be able to pay with USDT, USDC, ETH or SOL. The
86
+ walkthrough:
87
+
88
+ > Go to https://lightning-swap.com, sign in for API keys, create a key, and
89
+ > copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
90
+ > it here and I will store it — or say "Bitcoin only" and I will continue
91
+ > without it.
92
+
93
+ Mention FixedFloat only if they already use it.
94
+ 4. **When they paste it.** If it does not start with
95
+ `lightning+swapconnect://`, ask them to copy it again. Otherwise add
96
+ `LSC_URI_PRIMARY=<paste>` to the same `.env.local`, without echoing it. Swaps
97
+ are now on, so build the refund route back (the swap non-negotiable below) as
98
+ part of this integration. If they chose Bitcoin only, leave
99
+ `LSC_URI_PRIMARY` unset and skip that route.
100
+ 5. **Make the server load the file — yourself.** Next loads
101
+ `.env.local` into `process.env` on its own: do not add `dotenv`, and never
102
+ give a credential a `NEXT_PUBLIC_` prefix, which inlines it into the browser
103
+ bundle. When the app is started with Docker Compose, give the service
104
+ `env_file: .env.local`. Restart the dev server after writing the file.
105
+
106
+ Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
107
+ saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
108
+ runs the receive-only preflight: if it reports spend methods such as
109
+ `pay_invoice`, remove `NWC_URI` from `.env.local` and ask for a receive-only code
110
+ again. Never set the spend-capable override to get past it.
111
+
112
+ ### Upgrading an existing install
113
+
114
+ This is not the opening move of a new integration. When OpenReceive is ALREADY
115
+ installed here, `npx openreceive doctor` reports every credential as set/unset
116
+ (never the value) and probes the wallet. Check the installed
117
+ `@openreceive/node` and `@openreceive/browser` against the release named at the
118
+ top of this file: the headless display models below do not exist in older
119
+ versions, and the first tile click throws with nothing saying why. Upgrade
120
+ first.
95
121
 
96
122
  Only then start the quickstart.
97
123
 
@@ -109,7 +135,7 @@ itself, and they hold for every integration.
109
135
  payer-supplied amounts.
110
136
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
111
137
  the payer made, not proof. Read a framework session; never trust a body field.
112
- - `onPaid` must be idempotent. It runs once per `reference` — your order id, one
138
+ - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
113
139
  per thing you fulfill, created before checkout, kept across retries, never
114
140
  reused. A fresh id per page load lets one order be paid twice.
115
141
  - Receive-only NWC is required; a spend-capable code fails closed at boot unless
@@ -290,6 +316,8 @@ enough; drop the `.md` for the same page a person would read.
290
316
  Questions, or a problem with the library itself:
291
317
  https://openreceive.org/contact
292
318
 
319
+ - https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
320
+
293
321
  ---
294
322
 
295
323
  ## The quickstart, in full
@@ -307,11 +335,11 @@ Next.js App Router + React. Requires Node ≥ 22 and Next ≥ 15 (App Router).
307
335
  npm install @openreceive/next @openreceive/react
308
336
  ```
309
337
 
310
- Install the adapter for your server and the UI package for your frontend; the
338
+ Install the adapter for your server and the UI package for your frontend. The
311
339
  wallet client, HTTP handler, and contracts come along as dependencies. The
312
- `openreceive` package is the CLI only — `npx openreceive …` below needs no
313
- install. Different stack? Swap the two packages; the rest of this guide is
314
- identical.
340
+ `openreceive` package is only the CLI, and `npx openreceive …` below needs no
341
+ install. On a different stack, swap the two packages; the rest of this guide
342
+ stays the same.
315
343
 
316
344
  | | Packages |
317
345
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
@@ -319,18 +347,21 @@ identical.
319
347
  | Frontend | `@openreceive/react`, `@openreceive/vue`, `@openreceive/svelte`, `@openreceive/angular`, `@openreceive/elements` (plain HTML) |
320
348
 
321
349
  Express: [quickstart-node.md](https://openreceive.org/guides/quickstart-node.md) · Fastify:
322
- [quickstart-fastify.md](https://openreceive.org/guides/quickstart-fastify.md). This page is the Next.js one,
323
- and it is where an agent handed the Express guide goes wrong: no `dotenv`, no
324
- `app.use`, a client component for the checkout.
325
-
326
- On a fresh project, the App Router is what `create-next-app` scaffolds; no
327
- env loader is needed (Next loads `.env.local` itself). Install your ORM
328
- before step 2 (`npm install prisma @prisma/client` on the Prisma path) —
329
- `openreceive scaffold` emits files for the ORM you name but never installs it.
330
-
331
- npm environments that run with `ignore-scripts` (some editor sandboxes) skip
332
- Prisma's engine download and esbuild's binary postinstall, so a typecheck or
333
- build that fails only there is environmental, not a code problem.
350
+ [quickstart-fastify.md](https://openreceive.org/guides/quickstart-fastify.md). This page is the Next.js one.
351
+ An agent given the Express guide goes wrong on Next.js in three places: Next
352
+ needs no `dotenv`, no `app.use`, and it needs a client component for the
353
+ checkout.
354
+
355
+ On a fresh project, `create-next-app` scaffolds the App Router for you. You
356
+ need no env loader, because Next loads `.env.local` itself. Install your ORM
357
+ before step 2 (`npm install prisma @prisma/client` on the Prisma path).
358
+ `openreceive scaffold` emits files for the ORM you name, but it never installs
359
+ that ORM.
360
+
361
+ Some editor sandboxes run npm with `ignore-scripts`. That setting skips
362
+ Prisma's engine download and esbuild's binary postinstall. If a typecheck or
363
+ build fails only in such an environment, the environment is the cause, not
364
+ your code.
334
365
 
335
366
  ### 2. Migrate the payment tables
336
367
 
@@ -338,25 +369,25 @@ build that fails only there is environmental, not a code problem.
338
369
  npx openreceive scaffold payments --orm prisma # or drizzle | typeorm | sequelize | knex
339
370
  ```
340
371
 
341
- `openreceive scaffold payments` emits one schema/migration file for your ORM
342
- and a wiring guide. It never touches a database.
372
+ `openreceive scaffold payments` writes one schema or migration file for your
373
+ ORM, plus a wiring guide. It never touches a database.
343
374
  → [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments)
344
375
 
345
- Then run the emitted migration through your normal workflow (for example
346
- `npx prisma migrate dev`). OpenReceive owns the tables' logic at runtime; there
347
- is nothing else to generate. Details:
376
+ Then run the generated migration the way you normally do (for example
377
+ `npx prisma migrate dev`). OpenReceive runs the tables' logic at runtime, so
378
+ there is nothing else to generate. Details:
348
379
  [Payment storage](https://openreceive.org/guides/storage.md), [Node ORM recipes](https://openreceive.org/guides/node-orms.md).
349
380
 
350
- No ORM? A bare driver handle (`pg`, `node:sqlite`, `better-sqlite3`) is a
351
- supported `db` in step 4, and there is no scaffold flavor for it — execute the
352
- same DDL once yourself with `paymentsSchemaSql(dialect)` from
353
- `@openreceive/http` instead of scaffolding.
381
+ No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
382
+ `better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
383
+ Instead of scaffolding, run the same DDL once yourself, using
384
+ `paymentsSchemaSql(dialect)` from `@openreceive/http`.
354
385
 
355
386
  ### 3. Add wallet credentials
356
387
 
357
- Create a server-only `.env.local` (Next loads it into `process.env` on its
358
- own — do **not** add `dotenv`, and never prefix these with `NEXT_PUBLIC_`,
359
- which would inline them into the browser bundle):
388
+ Create a server-only `.env.local`. Next loads it into `process.env` on its
389
+ own, so do **not** add `dotenv`. Never prefix these variables with
390
+ `NEXT_PUBLIC_`, because that would inline them into the browser bundle.
360
391
 
361
392
  ```dotenv
362
393
  NWC_URI=
@@ -365,25 +396,28 @@ LSC_URI_BACKUP=
365
396
  ```
366
397
 
367
398
  1. Get a receive-only NWC code from a compatible wallet
368
- ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
369
- → `NWC_URI`.
370
- 2. Optionally set up a [swap provider](https://openreceive.org/set_up_swap_provider)
371
- → `LSC_URI_PRIMARY` (and `LSC_URI_BACKUP` if you have one).
399
+ ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
400
+ Put it in `NWC_URI`.
401
+ 2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
402
+ Put its connection string in `LSC_URI_PRIMARY`, and a second one in
403
+ `LSC_URI_BACKUP` if you have one.
372
404
 
373
- Never put these values in browser code. Your application refuses to start if
374
- the NWC code also advertises spend methods such as `pay_invoice`; mint a
375
- receive-only code ([Security](https://openreceive.org/guides/security.md)).
405
+ Never put these values in browser code. Your app refuses to start if the NWC
406
+ code also advertises spend methods such as `pay_invoice`. Create a
407
+ receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
376
408
 
377
- In production supply the same variables through your host's secret manager or
378
- process environment; `.env.local` is for development and is gitignored by
379
- `create-next-app`. → [Environment variables](https://openreceive.org/guides/environment-variables.md).
409
+ In production, supply the same variables through your host's secret manager
410
+ or process environment. `.env.local` is for development, and `create-next-app`
411
+ gitignores it. → [Environment variables](https://openreceive.org/guides/environment-variables.md).
380
412
 
381
413
  ### 4. Wire OpenReceive
382
414
 
383
- One catch-all route file: your hooks plus a database handle. The adapter
384
- builds the wallet client and the host and returns the `GET`/`POST` exports the
385
- App Router expects; there is no background reconciler — settlement piggybacks
386
- on requests through the durable gate, which is what makes it serverless-safe.
415
+ One catch-all route file takes your hooks and a database handle. The adapter
416
+ builds the wallet client and the host, and returns the `GET`/`POST` exports
417
+ the App Router expects. There is no background reconciler, meaning no job that
418
+ checks pending payments on a timer. Settlement runs during normal requests
419
+ instead, through the durable reconcile gate. That is what makes it safe on
420
+ serverless hosts.
387
421
 
388
422
  ```ts
389
423
  // app/openreceive/[...openreceive]/route.ts
@@ -451,15 +485,14 @@ export const { GET, POST } = openReceiveNextHandlers({
451
485
  });
452
486
  ```
453
487
 
454
- The route file is a **server module** — it imports your database handle and
455
- reads `process.env`, and nothing in it may be imported from a client
456
- component. The default prefix is `/openreceive`, which is the directory the
457
- file sits in; put the catch-all under another directory and pass `prefix` to
458
- match.
488
+ The route file is a **server module**. It imports your database handle and
489
+ reads `process.env`, so no client component may import anything from it. The
490
+ default prefix is `/openreceive`, which is the directory the file sits in. If
491
+ you put the catch-all under another directory, pass a matching `prefix`.
459
492
 
460
- When the options are themselves async (a database opened lazily, a wallet
461
- client shared with a worker), build the handlers per request instead of at
462
- module load — the Buy a Button example does exactly this:
493
+ Sometimes the options are themselves async, such as a database opened lazily
494
+ or a wallet client shared with a worker. Then build the handlers per request
495
+ instead of at module load. The Buy a Button example does exactly this:
463
496
 
464
497
  ```ts
465
498
  async function handle(request: Request): Promise<Response> {
@@ -480,35 +513,44 @@ where many payers share one IP. → [Rate limiting](https://openreceive.org/guid
480
513
 
481
514
  An optional worker, `startNotificationWorker({ service, host })`, listens for
482
515
  wallet payment notifications so settlement does not wait for the next page
483
- load. It is a separate long-lived Node process, not a route — on a serverless
484
- host, skip it and rely on the request-path settlement above.
516
+ load. It is a separate long-lived Node process, not a route. On a serverless
517
+ host, skip it and rely on the request-path settlement described above.
485
518
  → [startNotificationWorker](https://openreceive.org/guides/api-reference.md#startnotificationworker)
486
519
 
487
- Composing the pieces yourself (`createOpenReceive` + `createHost`) is
488
- supported when you need a shared wallet client or a custom repository.
520
+ You can also compose the pieces yourself (`createOpenReceive` + `createHost`)
521
+ when you need a shared wallet client or a custom repository.
489
522
  → [createOpenReceive](https://openreceive.org/guides/api-reference.md#createopenreceive) ·
490
523
  [createHost](https://openreceive.org/guides/api-reference.md#createhost)
491
524
 
492
- Your app also needs an ordinary order-creation route that validates the cart,
493
- prices with exact decimal math, and returns the order id the page will pass as
494
- the `reference`. OpenReceive never prices from payer input.
525
+ Your app also needs an ordinary route that creates the order. It validates the
526
+ cart, computes the price with exact decimal math, and returns the order id.
527
+ The page passes that id as the `reference`. OpenReceive never takes a price
528
+ from payer input.
529
+
530
+ The `reference` is a string you choose, and it identifies what gets fulfilled.
531
+ Use your order id. Make it:
495
532
 
496
- The `reference` is a string you choose, and it is the fulfillment identity:
497
- your order id — one per thing you fulfill, created before checkout, kept
498
- across retries, never reused. OpenReceive never looks inside it, but `onPaid`
499
- runs once per reference, a new checkout under a reference that already
500
- settled is refused with 409, and a fresh id per page load lets one order be
501
- paid twice.
533
+ - one per thing you fulfill,
534
+ - created before checkout,
535
+ - kept across retries,
536
+ - never reused.
537
+
538
+ OpenReceive never looks inside the `reference`, but it relies on it:
539
+
540
+ - `onPaid` commits fulfillment once per reference.
541
+ - A new checkout under a reference that already settled is refused with 409.
542
+ - A fresh id on every page load would let one order be paid twice.
502
543
 
503
544
  Naming boundary: TypeScript APIs use camelCase fields (`paymentHash`,
504
- `amountMsats`); everything on the wire — the mounted HTTP routes and the
505
- browser snapshots — is snake_case (`payment_hash`, `amount_msats`).
545
+ `amountMsats`). Everything on the wire is snake_case (`payment_hash`,
546
+ `amount_msats`). The wire means the mounted HTTP routes and the browser
547
+ snapshots.
506
548
 
507
549
  ### 5. Render checkout
508
550
 
509
551
  `<Checkout>` polls and holds state, so it is a **client component**. Put it in
510
- a file that starts with `"use client"` and import the stylesheet from that
511
- same module; the page that renders it can stay a server component.
552
+ a file that starts with `"use client"`, and import the stylesheet from that
553
+ same module. The page that renders it can stay a server component.
512
554
 
513
555
  ```tsx
514
556
  // app/checkout/[reference]/order-checkout.tsx
@@ -537,53 +579,58 @@ export default async function CheckoutPage({
537
579
  ```
538
580
 
539
581
  `/checkout/[reference]` is deliberately a page of its own rather than a modal
540
- on the cart: a payer with a swap deposit in flight has no account and no email
541
- from you, so this URL is the only thing that brings them back to their payment
542
- — it has to survive a reload and a bookmark
543
- ([Swap refunds](https://openreceive.org/guides/swap-refunds.md)). Do not render the checkout for a
544
- reference the current session may not see; the page can read the session and
545
- 404 before it renders, and `authorize` refuses the routes regardless.
582
+ on the cart. A payer with a swap deposit in flight has no account and no email
583
+ from you. This URL is the only thing that brings them back to their payment,
584
+ so it has to survive a reload and a bookmark
585
+ ([Swap refunds](https://openreceive.org/guides/swap-refunds.md)).
586
+
587
+ Do not render the checkout for a reference the current session may not see.
588
+ The page can read the session and return 404 before it renders, and
589
+ `authorize` refuses the routes regardless.
546
590
 
547
591
  The checkout renders, polls, and settles itself. The compiled `styles.css`
548
592
  sheets (`@openreceive/react`, `@openreceive/elements`) are self-contained and
549
- scoped: every rule applies only inside what OpenReceive renders. No
550
- `transpilePackages` entry is needed; the packages ship plain ESM.
593
+ scoped: every rule applies only inside what OpenReceive renders. You need no
594
+ `transpilePackages` entry, because the packages ship plain ESM.
551
595
 
552
596
  Serve the compiled `styles.css` without Tailwind processing: import it from
553
597
  JavaScript (with a CSS-capable bundler) or use a plain `<link rel="stylesheet">`.
554
598
  Do not `@import` it into the host Tailwind entry. Its zero-specificity rules
555
599
  allow host styles to override checkout styles; scoping does not prevent that.
556
600
 
557
- `<Checkout>` is complete as rendered: it already shows the `description` from
601
+ `<Checkout>` is complete as rendered. It already shows the `description` from
558
602
  `amountFor` and the collapsed transaction-details panel. Do not build a custom
559
- UI to satisfy those rules — they only become your job if you replace the
560
- drop-in ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
603
+ UI to show them. The display rules for them become your job only if you
604
+ replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
561
605
 
562
- Match the host page's theme: by default the checkout follows the payer's
563
- stored choice, then the system scheme. If this page is always one theme, lock
564
- it — `<Checkout theme="dark" … />` (`theme` attribute on the custom element) —
565
- so a white card never lands on a dark page. The checkout is styled by CSS
566
- variables under `data-theme`; [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) has
567
- the knobs.
606
+ Match the host page's theme. By default the checkout follows the payer's
607
+ stored choice, then the system color scheme. If this page always uses one
608
+ theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
609
+ the `theme` attribute. Locking the theme keeps a white card off a dark page.
610
+ CSS variables under `data-theme` style the checkout.
611
+ [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
568
612
 
569
613
  Everything the checkout draws ships inside the JavaScript: the payment-method
570
- icons, the wallet logos and the pay tutorials. There is no image file to copy
571
- or serve and no asset option to set. Deploy your normal JavaScript and CSS
614
+ icons, the wallet logos, and the pay tutorials. There is no image file to copy
615
+ or serve, and no asset option to set. Deploy your normal JavaScript and CSS
572
616
  build output, including any generated JavaScript chunks. Bundlers with code
573
- splitting can defer tutorial screenshots until first open; single-file builds
574
- (including the standalone checkout) include them upfront. If your
575
- Content-Security-Policy has a strict `img-src`, allow `data:`
617
+ splitting can wait to load tutorial screenshots until a tutorial first opens.
618
+ Single-file builds, including the standalone checkout, include them from the
619
+ start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
576
620
  ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
577
621
 
578
- That is the whole loop: your server owns the price and the order, the payer gets
579
- an invoice, and `onPaid` runs once inside the settlement transaction.
622
+ That is the whole loop. Your server owns the price and the order. The payer
623
+ gets an invoice. `onPaid` runs inside the settlement transaction. If that
624
+ transaction rolls back, the callback may run again. For delivery to outside
625
+ systems, use an outbox in your app: record the message in the transaction and
626
+ send it after commit.
580
627
 
581
- A runnable illustration of this boundary — not a template to copy models from —
582
- is Buy a Button
628
+ Buy a Button is a runnable illustration of this boundary
583
629
  (`examples/buttons/server/nextjs-fullstack`).
584
- It has products, visitors, and orders, with the three hooks as the only bridge,
585
- its shop routes as three-line App Router wrappers, and `/checkout/[reference]`
586
- as the resumable page. Map that shape onto the models in THIS app.
630
+ It is not a template to copy models from. It has products, visitors, and
631
+ orders, and the three hooks are the only bridge to OpenReceive. Its shop
632
+ routes are three-line App Router wrappers, and `/checkout/[reference]` is the
633
+ resumable page. Map that shape onto the models in THIS app.
587
634
 
588
635
  ### 6. Verify
589
636
 
@@ -591,16 +638,17 @@ as the resumable page. Map that shape onto the models in THIS app.
591
638
  npx openreceive doctor
592
639
  ```
593
640
 
594
- `openreceive doctor` checks Node, `NWC_URI`, and swap-provider configuration,
595
- and probes the wallet relay to confirm the code is receive-only. Add
596
- `--db <file-or-url>` to confirm the migration ran, and
597
- `--url http://localhost:3000` to confirm the routes are mounted; every failing
641
+ `openreceive doctor` checks Node, `NWC_URI`, and the swap-provider
642
+ configuration. It also probes the wallet relay to confirm the code is
643
+ receive-only. Add `--db <file-or-url>` to confirm the migration ran. Add
644
+ `--url http://localhost:3000` to confirm the routes are mounted. Every failing
598
645
  line states its own fix.
599
646
  → [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor)
600
647
 
601
- Then open the checkout in a browser, confirm the payment-method icons and
602
- wallet logos render, and open a wallet's pay tutorial to check its screenshots.
603
- If an image is missing, inspect the console for CSP violations and the Network
604
- panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
605
- complete build output. Do not add image routes, copy package source images, or
606
- use registry `icon_path` / tutorial `path` keys as browser URLs.
648
+ Then open the checkout in a browser. Confirm the payment-method icons and
649
+ wallet logos render. Open a wallet's pay tutorial to check its screenshots.
650
+ If an image is missing, look in the console for CSP violations and in the
651
+ Network panel for failed JavaScript chunks. To fix it, allow `data:` in
652
+ `img-src` and deploy the complete build output. Do not add image routes or
653
+ copy package source images. Do not use registry `icon_path` or tutorial
654
+ `path` keys as browser URLs.