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 (Fastify)
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 Fastify application — the app you are already working in.
6
6
  You do not need a copy of the OpenReceive source: the packages are on npm, and
@@ -34,62 +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`, the process
47
- env, the deploy config, whatever this app already uses. If the app runs in a
48
- container the value is in none of those: ask the running process
49
- (`docker exec <container> printenv NWC_URI`), because finding the NAME in a
50
- compose file proves nothing about the value. Never print or echo the value
51
- itself; only report whether it is set. Check for `LSC_URI_PRIMARY` in the
52
- same pass.
53
- 2. If BOTH are already set — the common case in an existing app — say so and go
54
- straight to the quickstart. Steps 3 and 4 are for an environment that is
55
- missing one; do not stop to ask about altcoins that are already configured.
56
- If only `NWC_URI` is set, Bitcoin already works: continue, and raise the
57
- altcoin question at step 4 rather than blocking on it.
58
- 3. If `NWC_URI` is missing or empty, stop and tell the user exactly what to
59
- create:
60
-
61
- > OpenReceive cannot issue an invoice without a receive-only NWC code. Get
62
- > one at https://openreceive.org/get_a_nwc_code_to_receive_payments, then
63
- > put `NWC_URI=<the code>` in this app's server environment — for most apps
64
- > that is a `.env` file in the project root — and tell me when it's set.
65
-
66
- Wait for the user before wiring OpenReceive; do not invent a placeholder
67
- value. Waiting is not idleness: you may write `.env.example` with the
68
- variable NAMES only (`NWC_URI=`, `LSC_URI_PRIMARY=`) so the merchant has a
69
- file to copy, and keep building the parts of the host that do not touch
70
- OpenReceive — the order model, the cart, the routes. The stop guards the
71
- credential, not the rest of the app.
72
- 4. If `LSC_URI_PRIMARY` was not already set, ask the user: "Do you want to
73
- accept altcoins and stablecoins (USDT, USDC, ETH, SOL) as well as
74
- Bitcoin?"
75
-
76
- - Yes → send them to https://openreceive.org/set_up_swap_provider for a
77
- swap-provider (LSC) code, to set as `LSC_URI_PRIMARY` in the same server
78
- environment. Do NOT wait for it: no application code reads the value, so
79
- the integration is identical with or without it — the library picks it up
80
- from the environment and swaps switch on. What a yes DOES change is the
81
- refund route back (the swap non-negotiable below): build it as part of
82
- this integration, not when the code arrives.
83
- - No → skip it. Bitcoin over Lightning works with `NWC_URI` alone, and you
84
- can add a swap provider later without changing application code.
85
- 5. Check the environment again and confirm `NWC_URI` is present.
86
- `LSC_URI_PRIMARY` may land later; swaps stay off until it does, and no code
87
- changes when it arrives.
88
- 6. If OpenReceive is ALREADY installed here, check the installed versions of
89
- `@openreceive/node` and `@openreceive/browser` against the release named at
90
- the top of this file. The headless display models below do not exist in
91
- older versions, and the first tile click throws with nothing saying why.
92
- 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`, 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, 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`, creating the file if needed.
80
+ Make sure `.gitignore` covers `.env` (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`, 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.** OpenReceive reads
101
+ `process.env`, and a `.env` file on disk is not in it. Put
102
+ `import "dotenv/config";` at the top of the server entry, as the quickstart
103
+ does. When the app is started with Docker Compose, give the service
104
+ `env_file: .env`. Restart the 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` 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.
93
121
 
94
122
  Only then start the quickstart.
95
123
 
@@ -107,7 +135,7 @@ itself, and they hold for every integration.
107
135
  payer-supplied amounts.
108
136
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
109
137
  the payer made, not proof. Read a framework session; never trust a body field.
110
- - `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
111
139
  per thing you fulfill, created before checkout, kept across retries, never
112
140
  reused. A fresh id per page load lets one order be paid twice.
113
141
  - Receive-only NWC is required; a spend-capable code fails closed at boot unless
@@ -284,6 +312,8 @@ enough; drop the `.md` for the same page a person would read.
284
312
  Questions, or a problem with the library itself:
285
313
  https://openreceive.org/contact
286
314
 
315
+ - https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
316
+
287
317
  ---
288
318
 
289
319
  ## The quickstart, in full
@@ -301,11 +331,11 @@ Fastify + React. Requires Node ≥ 22.
301
331
  npm install @openreceive/fastify @openreceive/react
302
332
  ```
303
333
 
304
- Install the adapter for your server and the UI package for your frontend; the
334
+ Install the adapter for your server and the UI package for your frontend. The
305
335
  wallet client, HTTP handler, and contracts come along as dependencies. The
306
- `openreceive` package is the CLI only — `npx openreceive …` below needs no
307
- install. Different stack? Swap the two packages; the rest of this guide is
308
- identical.
336
+ `openreceive` package is only the CLI, and `npx openreceive …` below needs no
337
+ install. On a different stack, swap the two packages; the rest of this guide
338
+ stays the same.
309
339
 
310
340
  | | Packages |
311
341
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
@@ -315,15 +345,17 @@ identical.
315
345
  Express: [quickstart-node.md](https://openreceive.org/guides/quickstart-node.md) · Next.js:
316
346
  [quickstart-next.md](https://openreceive.org/guides/quickstart-next.md). This page is the Fastify one.
317
347
 
318
- On a fresh project, also install what this guide assumes is already there: the
348
+ On a fresh project, also install what this guide assumes you already have: the
319
349
  framework, a static-file plugin for the checkout page, and an env loader
320
- (`npm install fastify @fastify/static dotenv`), plus your ORM before step 2
321
- (`npm install prisma @prisma/client` on the Prisma path) —
322
- `openreceive scaffold` emits files for the ORM you name but never installs it.
350
+ (`npm install fastify @fastify/static dotenv`). Install your ORM before step 2
351
+ too (`npm install prisma @prisma/client` on the Prisma path).
352
+ `openreceive scaffold` emits files for the ORM you name, but it never installs
353
+ that ORM.
323
354
 
324
- npm environments that run with `ignore-scripts` (some editor sandboxes) skip
325
- Prisma's engine download and esbuild's binary postinstall, so a typecheck or
326
- build that fails only there is environmental, not a code problem.
355
+ Some editor sandboxes run npm with `ignore-scripts`. That setting skips
356
+ Prisma's engine download and esbuild's binary postinstall. If a typecheck or
357
+ build fails only in such an environment, the environment is the cause, not
358
+ your code.
327
359
 
328
360
  ### 2. Migrate the payment tables
329
361
 
@@ -331,19 +363,19 @@ build that fails only there is environmental, not a code problem.
331
363
  npx openreceive scaffold payments --orm prisma # or drizzle | typeorm | sequelize | knex
332
364
  ```
333
365
 
334
- `openreceive scaffold payments` emits one schema/migration file for your ORM
335
- and a wiring guide. It never touches a database.
366
+ `openreceive scaffold payments` writes one schema or migration file for your
367
+ ORM, plus a wiring guide. It never touches a database.
336
368
  → [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments)
337
369
 
338
- Then run the emitted migration through your normal workflow (for example
339
- `npx prisma migrate dev`). OpenReceive owns the tables' logic at runtime; there
340
- is nothing else to generate. Details:
370
+ Then run the generated migration the way you normally do (for example
371
+ `npx prisma migrate dev`). OpenReceive runs the tables' logic at runtime, so
372
+ there is nothing else to generate. Details:
341
373
  [Payment storage](https://openreceive.org/guides/storage.md), [Node ORM recipes](https://openreceive.org/guides/node-orms.md).
342
374
 
343
- No ORM? A bare driver handle (`pg`, `node:sqlite`, `better-sqlite3`) is a
344
- supported `db` in step 4, and there is no scaffold flavor for it — execute the
345
- same DDL once yourself with `paymentsSchemaSql(dialect)` from
346
- `@openreceive/http` instead of scaffolding.
375
+ No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
376
+ `better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
377
+ Instead of scaffolding, run the same DDL once yourself, using
378
+ `paymentsSchemaSql(dialect)` from `@openreceive/http`.
347
379
 
348
380
  ### 3. Add wallet credentials
349
381
 
@@ -356,28 +388,33 @@ LSC_URI_BACKUP=
356
388
  ```
357
389
 
358
390
  1. Get a receive-only NWC code from a compatible wallet
359
- ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
360
- → `NWC_URI`.
361
- 2. Optionally set up a [swap provider](https://openreceive.org/set_up_swap_provider)
362
- → `LSC_URI_PRIMARY` (and `LSC_URI_BACKUP` if you have one).
391
+ ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
392
+ Put it in `NWC_URI`.
393
+ 2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
394
+ Put its connection string in `LSC_URI_PRIMARY`, and a second one in
395
+ `LSC_URI_BACKUP` if you have one.
363
396
 
364
- Never put these values in browser code. Your application refuses to start if
365
- the NWC code also advertises spend methods such as `pay_invoice`; mint a
366
- receive-only code ([Security](https://openreceive.org/guides/security.md)).
397
+ Never put these values in browser code. Your app refuses to start if the NWC
398
+ code also advertises spend methods such as `pay_invoice`. Create a
399
+ receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
367
400
 
368
- OpenReceive reads `process.env`; creating a `.env` file is not enough on its
369
- own. How that file (or production secrets) get into the process —
370
- `dotenv` on Express/Fastify, Next.js auto-load, secret managers in
371
- production — is on [Environment variables](https://openreceive.org/guides/environment-variables.md).
401
+ OpenReceive reads `process.env`, so creating a `.env` file is not enough on
402
+ its own. [Environment variables](https://openreceive.org/guides/environment-variables.md) explains how that
403
+ file or your production secrets get into the process: `dotenv` on
404
+ Express/Fastify, auto-load on Next.js, and secret managers in production.
372
405
 
373
406
  ### 4. Wire OpenReceive
374
407
 
375
- One plugin: your hooks plus a database handle. The plugin builds the wallet
376
- client and the host; there is no background reconciler — settlement
377
- piggybacks on requests through the durable gate. Two things are Fastify's
378
- own: the mount prefix is passed **at `register()`**, so Fastify scopes the
379
- plugin's routes to it, and there is no body parser to add — Fastify parses
380
- JSON itself.
408
+ One plugin takes your hooks and a database handle. The plugin builds the
409
+ wallet client and the host. There is no background reconciler, meaning no job that checks pending
410
+ payments on a timer. Settlement runs during normal requests instead, through
411
+ the durable reconcile gate.
412
+
413
+ Two things are specific to Fastify:
414
+
415
+ - You pass the mount prefix **at `register()`**, so Fastify scopes the
416
+ plugin's routes to it.
417
+ - You add no body parser, because Fastify parses JSON itself.
381
418
 
382
419
  ```ts
383
420
  import "dotenv/config"; // loads .env into process.env; nothing else does
@@ -446,11 +483,11 @@ await app.register(openReceiveFastify, {
446
483
  });
447
484
  ```
448
485
 
449
- Register the plugin after whatever plugin gives you sessions or auth
450
- decorations, since `authorize` sees the same request object. Shutdown is
451
- handled for you: the plugin registers an `onClose` hook that closes the wallet
452
- client with the app, so there is no `ready`/`close` pair to hold — a deploy
453
- health check awaits `fastify.ready()` instead.
486
+ Register the plugin after whichever plugin gives you sessions or auth
487
+ decorations, because `authorize` sees the same request object. The plugin
488
+ handles shutdown for you. It registers an `onClose` hook that closes the
489
+ wallet client together with the app, so you have no `ready`/`close` pair to
490
+ manage. A deploy health check awaits `fastify.ready()` instead.
454
491
 
455
492
  The first request checks the wallet. Later OpenReceive requests also settle
456
493
  pending invoices, so a payer who closes the tab is still covered.
@@ -465,25 +502,34 @@ An optional worker, `startNotificationWorker({ service, host })`, listens for
465
502
  wallet payment notifications so settlement does not wait for the next page
466
503
  load. → [startNotificationWorker](https://openreceive.org/guides/api-reference.md#startnotificationworker)
467
504
 
468
- Composing the pieces yourself (`createOpenReceive` + `createHost`) is
469
- supported when you need a shared wallet client or a custom repository.
505
+ You can also compose the pieces yourself (`createOpenReceive` + `createHost`)
506
+ when you need a shared wallet client or a custom repository.
470
507
  → [createOpenReceive](https://openreceive.org/guides/api-reference.md#createopenreceive) ·
471
508
  [createHost](https://openreceive.org/guides/api-reference.md#createhost)
472
509
 
473
- Your app also needs an ordinary order-creation route that validates the cart,
474
- prices with exact decimal math, and returns the order id the page will pass as
475
- the `reference`. OpenReceive never prices from payer input.
510
+ Your app also needs an ordinary route that creates the order. It validates the
511
+ cart, computes the price with exact decimal math, and returns the order id.
512
+ The page passes that id as the `reference`. OpenReceive never takes a price
513
+ from payer input.
514
+
515
+ The `reference` is a string you choose, and it identifies what gets fulfilled.
516
+ Use your order id. Make it:
476
517
 
477
- The `reference` is a string you choose, and it is the fulfillment identity:
478
- your order id — one per thing you fulfill, created before checkout, kept
479
- across retries, never reused. OpenReceive never looks inside it, but `onPaid`
480
- runs once per reference, a new checkout under a reference that already
481
- settled is refused with 409, and a fresh id per page load lets one order be
482
- paid twice.
518
+ - one per thing you fulfill,
519
+ - created before checkout,
520
+ - kept across retries,
521
+ - never reused.
522
+
523
+ OpenReceive never looks inside the `reference`, but it relies on it:
524
+
525
+ - `onPaid` commits fulfillment once per reference.
526
+ - A new checkout under a reference that already settled is refused with 409.
527
+ - A fresh id on every page load would let one order be paid twice.
483
528
 
484
529
  Naming boundary: TypeScript APIs use camelCase fields (`paymentHash`,
485
- `amountMsats`); everything on the wire — the mounted HTTP routes and the
486
- browser snapshots — is snake_case (`payment_hash`, `amount_msats`).
530
+ `amountMsats`). Everything on the wire is snake_case (`payment_hash`,
531
+ `amount_msats`). The wire means the mounted HTTP routes and the browser
532
+ snapshots.
487
533
 
488
534
  ### 5. Render checkout
489
535
 
@@ -494,46 +540,52 @@ import "@openreceive/react/styles.css";
494
540
  <Checkout reference={order.id} prefix="/openreceive" />;
495
541
  ```
496
542
 
497
- The checkout renders, polls, and settles itself. The compiled `styles.css`
498
- sheets (`@openreceive/react`, `@openreceive/elements`) are self-contained — a
499
- plain `<link rel="stylesheet">` works with no build step — and scoped: every
543
+ The checkout renders, polls, and settles itself.
544
+
545
+ `@openreceive/react` and `@openreceive/elements` each ship a compiled
546
+ `styles.css`. Each sheet is self-contained, so a plain
547
+ `<link rel="stylesheet">` works with no build step. Each is also scoped: every
500
548
  rule applies only inside what OpenReceive renders.
501
549
 
502
- Serve the compiled `styles.css` without Tailwind processing: import it from
503
- JavaScript (with a CSS-capable bundler) or use a plain `<link rel="stylesheet">`.
504
- Do not `@import` it into the host Tailwind entry. Its zero-specificity rules
505
- allow host styles to override checkout styles; scoping does not prevent that.
550
+ Serve the compiled `styles.css` without Tailwind processing. Import it from
551
+ JavaScript if your bundler handles CSS, or use a plain
552
+ `<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
553
+ Its rules have zero specificity, so your page's styles can override checkout
554
+ styles. Scoping does not prevent that.
506
555
 
507
- `<Checkout>` is complete as rendered: it already shows the `description` from
556
+ `<Checkout>` is complete as rendered. It already shows the `description` from
508
557
  `amountFor` and the collapsed transaction-details panel. Do not build a custom
509
- UI to satisfy those rules — they only become your job if you replace the
510
- drop-in ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
558
+ UI to show them. The display rules for them become your job only if you
559
+ replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
511
560
 
512
- Match the host page's theme: by default the checkout follows the payer's
513
- stored choice, then the system scheme. If this page is always one theme, lock
514
- it — `<Checkout theme="dark" … />` (`theme` attribute on the custom element) —
515
- so a white card never lands on a dark page. The checkout is styled by CSS
516
- variables under `data-theme`; [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) has
517
- the knobs.
561
+ Match the host page's theme. By default the checkout follows the payer's
562
+ stored choice, then the system color scheme. If this page always uses one
563
+ theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
564
+ the `theme` attribute. Locking the theme keeps a white card off a dark page.
565
+ CSS variables under `data-theme` style the checkout.
566
+ [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
518
567
 
519
568
  Everything the checkout draws ships inside the JavaScript: the payment-method
520
- icons, the wallet logos and the pay tutorials. There is no image file to copy
521
- or serve and no asset option to set. Deploy your normal JavaScript and CSS
569
+ icons, the wallet logos, and the pay tutorials. There is no image file to copy
570
+ or serve, and no asset option to set. Deploy your normal JavaScript and CSS
522
571
  build output, including any generated JavaScript chunks. Bundlers with code
523
- splitting can defer tutorial screenshots until first open; single-file builds
524
- (including the standalone checkout) include them upfront. If your
525
- Content-Security-Policy has a strict `img-src`, allow `data:`
572
+ splitting can wait to load tutorial screenshots until a tutorial first opens.
573
+ Single-file builds, including the standalone checkout, include them from the
574
+ start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
526
575
  ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
527
576
 
528
- That is the whole loop: your server owns the price and the order, the payer gets
529
- an invoice, and `onPaid` runs once inside the settlement transaction.
577
+ That is the whole loop. Your server owns the price and the order. The payer
578
+ gets an invoice. `onPaid` runs inside the settlement transaction. If that
579
+ transaction rolls back, the callback may run again. For delivery to outside
580
+ systems, use an outbox in your app: record the message in the transaction and
581
+ send it after commit.
530
582
 
531
- A runnable illustration of this boundary — not a template to copy models from —
532
- is Buy a Button
583
+ Buy a Button is a runnable illustration of this boundary
533
584
  (`examples/buttons/server/fastify`).
534
- It has products, visitors, and orders, with the three hooks as the only bridge,
535
- and its host is the smallest correct Fastify integration of the packaged
536
- checkout. Map that shape onto the models in THIS app.
585
+ It is not a template to copy models from. It has products, visitors, and
586
+ orders, and the three hooks are the only bridge to OpenReceive. Its host is
587
+ the smallest correct Fastify integration of the packaged checkout. Map that
588
+ shape onto the models in THIS app.
537
589
 
538
590
  ### 6. Verify
539
591
 
@@ -541,16 +593,17 @@ checkout. Map that shape onto the models in THIS app.
541
593
  npx openreceive doctor
542
594
  ```
543
595
 
544
- `openreceive doctor` checks Node, `NWC_URI`, and swap-provider configuration,
545
- and probes the wallet relay to confirm the code is receive-only. Add
546
- `--db <file-or-url>` to confirm the migration ran, and
547
- `--url http://localhost:3000` to confirm the routes are mounted; every failing
596
+ `openreceive doctor` checks Node, `NWC_URI`, and the swap-provider
597
+ configuration. It also probes the wallet relay to confirm the code is
598
+ receive-only. Add `--db <file-or-url>` to confirm the migration ran. Add
599
+ `--url http://localhost:3000` to confirm the routes are mounted. Every failing
548
600
  line states its own fix.
549
601
  → [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor)
550
602
 
551
- Then open the checkout in a browser, confirm the payment-method icons and
552
- wallet logos render, and open a wallet's pay tutorial to check its screenshots.
553
- If an image is missing, inspect the console for CSP violations and the Network
554
- panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
555
- complete build output. Do not add image routes, copy package source images, or
556
- use registry `icon_path` / tutorial `path` keys as browser URLs.
603
+ Then open the checkout in a browser. Confirm the payment-method icons and
604
+ wallet logos render. Open a wallet's pay tutorial to check its screenshots.
605
+ If an image is missing, look in the console for CSP violations and in the
606
+ Network panel for failed JavaScript chunks. To fix it, allow `data:` in
607
+ `img-src` and deploy the complete build output. Do not add image routes or
608
+ copy package source images. Do not use registry `icon_path` or tutorial
609
+ `path` keys as browser URLs.