@openreceive/angular 0.4.11 → 0.4.12

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 (FastAPI)
2
2
 
3
- These directions describe OpenReceive 0.4.11.
3
+ These directions describe OpenReceive 0.4.12.
4
4
 
5
5
  Add OpenReceive to a FastAPI application — the app you are already working in.
6
6
  You do not need a copy of the OpenReceive source: the engine is on PyPI
@@ -37,67 +37,94 @@ The one required credential is a receive-only NWC code (Nostr Wallet Connect):
37
37
  a string from the merchant's wallet that can create invoices and read their
38
38
  status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
39
39
  payer send USDT, USDC, ETH or SOL instead, converted into that same
40
- Lightning payment. You supply those credentials and three hooks — `authorize`, `amountFor`,
40
+ Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`, `amountFor`,
41
41
  `onPaid`;
42
42
  OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
43
43
  owns orders, users, prices, or fulfillment.
44
44
 
45
- ## Step 0 — check the environment before you write code
46
-
47
- Do this before installing packages or editing files.
48
-
49
- 1. Look for `NWC_URI` in this app's server environment — `.env`, the process
50
- env, the deploy config, whatever this app already uses. If the app runs in a
51
- container the value is in none of those: ask the running process
52
- (`docker exec <container> printenv NWC_URI`), because finding the NAME in a
53
- compose file proves nothing about the value. Never print or echo the value
54
- itself; only report whether it is set. Check for `LSC_URI_PRIMARY` in the
55
- same pass.
56
- 2. If BOTH are already set — the common case in an existing app — say so and go
57
- straight to the quickstart. Steps 3 and 4 are for an environment that is
58
- missing one; do not stop to ask about altcoins that are already configured.
59
- If only `NWC_URI` is set, Bitcoin already works: continue, and raise the
60
- altcoin question at step 4 rather than blocking on it.
61
- 3. If `NWC_URI` is missing or empty, stop and tell the user exactly what to
62
- create:
63
-
64
- > OpenReceive cannot issue an invoice without a receive-only NWC code. Get
65
- > one at https://openreceive.org/get_a_nwc_code_to_receive_payments, then
66
- > put `NWC_URI=<the code>` in this app's server environment — for most apps
67
- > that is a `.env` file in the project root — and tell me when it's set.
68
-
69
- Wait for the user before wiring OpenReceive; do not invent a placeholder
70
- value. Waiting is not idleness: you may write `.env.example` with the
71
- variable NAMES only (`NWC_URI=`, `LSC_URI_PRIMARY=`) so the merchant has a
72
- file to copy, and keep building the parts of the host that do not touch
73
- OpenReceive — the order model, the cart, the routes. The stop guards the
74
- credential, not the rest of the app.
75
- 4. If `LSC_URI_PRIMARY` was not already set, ask the user: "Do you want to
76
- accept altcoins and stablecoins (USDT, USDC, ETH, SOL) as well as
77
- Bitcoin?"
78
-
79
- - Yes → send them to https://openreceive.org/set_up_swap_provider for a
80
- swap-provider (LSC) code, to set as `LSC_URI_PRIMARY` in the same server
81
- environment. Do NOT wait for it: no application code reads the value, so
82
- the integration is identical with or without it — the library picks it up
83
- from the environment and swaps switch on. What a yes DOES change is the
84
- refund route back (the swap non-negotiable below): build it as part of
85
- this integration, not when the code arrives.
86
- - No → skip it. Bitcoin over Lightning works with `NWC_URI` alone, and you
87
- can add a swap provider later without changing application code.
88
- 5. Check the environment again and confirm `NWC_URI` is present.
89
- `LSC_URI_PRIMARY` may land later; swaps stay off until it does, and no code
90
- changes when it arrives.
91
- 6. If OpenReceive is ALREADY installed here, check the installed versions of
92
- `openreceive` (`pip show openreceive`) and `@openreceive/browser` against
93
- the release named at the top of this file. The headless display models
94
- below do not exist in older versions, and the first tile click throws with
95
- nothing saying why. Upgrade first.
96
- 7. Run `openreceive doctor --app <module>:app` (or `--offline` before the
97
- router exists). It reports `NWC_URI` presence without printing it, probes
98
- the wallet, and once the router is wired names any hook still on a
99
- placeholder and whether the migration ran. Exit code 1 is a finding to
100
- fix, not a reason to skip the check.
45
+ ## Step 0 — ask for the two codes, one question at a time
46
+
47
+ Before anything else, look at one file: the project's `.env`, if it exists.
48
+ Read it only far enough to see whether `NWC_URI` and `LSC_URI_PRIMARY` are
49
+ there and non-empty, and never print the values. A code that is already
50
+ set is not asked for again; if both are set, skip to step 5
51
+ (making the server load the file), then the quickstart.
52
+
53
+ Otherwise your next action is a question to the user. Do not install packages,
54
+ edit the app, write `.env.example`, or search anywhere else before asking
55
+ it. Do not read deploy config (compose files, platform secrets), Docker containers, or process environments, and never run
56
+ `printenv`. A new shop has neither code yet: hunting for one burns the turn and
57
+ can leak other secrets into the transcript.
58
+
59
+ Two server-only URIs are needed before the quickstart:
60
+
61
+ - `NWC_URI` — a receive-only Nostr Wallet Connect code,
62
+ `nostr+walletconnect://…`. Required for Bitcoin.
63
+ - `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
64
+ `lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
65
+ only when the user says they want Bitcoin alone.
66
+
67
+ The user never edits an environment file. They paste each code into the chat;
68
+ you store it. Ask one question per message.
69
+
70
+ 1. **First message — the NWC code, and nothing else.** Ask for it and walk them
71
+ through getting it:
72
+
73
+ > To receive payments I need a receive-only wallet code. In Rizful: open
74
+ > the menu, tap NWC, choose Receive-only NWC code, and tap Copy
75
+ > (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
76
+ > rather run your own wallet, Alby Hub works too: Connections → Add
77
+ > Connection → Read Only. Paste the code here and I will store it.
78
+
79
+ Do not mention `.env`, exports, or "tell me when it's set".
80
+ 2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
81
+ ask them to copy the receive-only code again. Otherwise write
82
+ `NWC_URI=<paste>` into the project's `.env`, creating the file if needed.
83
+ Make sure `.gitignore` covers `.env` (and `.dockerignore`, if the app has
84
+ one). Never echo the value, commit it, or put it in client code. Reply only
85
+ that it is saved, then ask the next question.
86
+ 3. **Second message — swaps.** If the user already asked for stablecoins or
87
+ altcoins, skip the yes/no and go straight to the walkthrough. Otherwise ask
88
+ whether payers should also be able to pay with USDT, USDC, ETH or SOL. The
89
+ walkthrough:
90
+
91
+ > Go to https://lightning-swap.com, sign in for API keys, create a key, and
92
+ > copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
93
+ > it here and I will store it — or say "Bitcoin only" and I will continue
94
+ > without it.
95
+
96
+ Mention FixedFloat only if they already use it.
97
+ 4. **When they paste it.** If it does not start with
98
+ `lightning+swapconnect://`, ask them to copy it again. Otherwise add
99
+ `LSC_URI_PRIMARY=<paste>` to the same `.env`, without echoing it. Swaps
100
+ are now on, so build the refund route back (the swap non-negotiable below) as
101
+ part of this integration. If they chose Bitcoin only, leave
102
+ `LSC_URI_PRIMARY` unset and skip that route.
103
+ 5. **Make the server load the file — yourself.** OpenReceive reads
104
+ `os.environ`, and a `.env` file on disk is not in it. Start the dev server
105
+ with `uvicorn --env-file .env` (update the app's run script or Procfile, not
106
+ just your own command). When it is started with Docker Compose, give the
107
+ service `env_file: .env`. Restart the server after writing the file.
108
+
109
+ Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
110
+ saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
111
+ runs the receive-only preflight: if it reports spend methods such as
112
+ `pay_invoice`, remove `NWC_URI` from `.env` and ask for a receive-only code
113
+ again. Never set the spend-capable override to get past it.
114
+
115
+ After the router is wired, run `openreceive doctor --app <module>:app`. It
116
+ reports `NWC_URI` presence without printing it, probes the wallet, and names
117
+ any hook still on a placeholder and whether the migration ran. Exit code 1 is a
118
+ finding to fix, not a reason to skip the check.
119
+
120
+ ### Upgrading an existing install
121
+
122
+ This is not the opening move of a new integration. When OpenReceive is ALREADY
123
+ installed here, the doctor above is the first check. Compare the installed
124
+ `openreceive` (`pip show openreceive`) and `@openreceive/browser` against the
125
+ release named at the top of this file: the headless display models below do
126
+ not exist in older versions, and the first tile click throws with nothing
127
+ saying why. Upgrade first.
101
128
 
102
129
  Only then start the quickstart.
103
130
 
@@ -322,19 +349,20 @@ pip install "openreceive[fastapi]"
322
349
  npm install @openreceive/react
323
350
  ```
324
351
 
325
- One Python distribution with framework extras: `openreceive[fastapi]` brings
326
- FastAPI, Starlette and SQLAlchemy; the wallet client (websockets, coincurve,
327
- cryptography), the HTTP engine and the `openreceive` CLI come with the base
328
- package. The npm package is the checkout UI for your frontend. Different
329
- stack? Swap the two: `openreceive[django]` with the Django quickstart; a
330
- bundler-less page uses `@openreceive/elements` instead of React.
352
+ OpenReceive is one Python distribution with framework extras.
353
+ `openreceive[fastapi]` brings FastAPI, Starlette and SQLAlchemy. The base
354
+ package includes the wallet client (websockets, coincurve, cryptography), the
355
+ HTTP engine and the `openreceive` CLI. The npm package is the checkout UI for
356
+ your frontend. On a different stack, swap the two: use `openreceive[django]`
357
+ with the Django quickstart. A page without a bundler uses
358
+ `@openreceive/elements` instead of React.
331
359
 
332
360
  | | Packages |
333
361
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
334
362
  | Server | `openreceive[fastapi]`, `openreceive[django]`, `openreceive[sqlalchemy]` (Flask and plain WSGI/ASGI: the Flask recipe) |
335
363
  | Frontend | `@openreceive/react`, `@openreceive/vue`, `@openreceive/svelte`, `@openreceive/angular`, `@openreceive/elements` (plain HTML) |
336
364
 
337
- Use `uv` or a virtualenv on Python 3.10 or newer; a system Python 3.9 cannot
365
+ Use `uv` or a virtualenv on Python 3.10 or newer. A system Python 3.9 cannot
338
366
  install the package.
339
367
 
340
368
  ### 2. Migrate the payment tables
@@ -344,24 +372,27 @@ openreceive scaffold payments --alembic --dialect postgres # or sqlite | mysq
344
372
  ```
345
373
 
346
374
  `openreceive scaffold payments --alembic` writes one Alembic revision into
347
- `alembic/versions/` that creates `openreceive_payments` (the payment attempts)
348
- and `openreceive_meta` (the reconcile gate) with the DDL frozen in the file.
349
- Set its `down_revision` to your current head (`alembic heads`), then apply it
350
- the way you apply your own: `alembic upgrade head`. It never opens a database
351
- connection.
375
+ `alembic/versions/`. The DDL is frozen in the file, and it creates two tables:
376
+
377
+ - `openreceive_payments`, the payment attempts
378
+ - `openreceive_meta`, the reconcile gate
379
+
380
+ Set the revision's `down_revision` to your current head (`alembic heads`).
381
+ Then apply it the way you apply your own revisions: `alembic upgrade head`.
382
+ The command never opens a database connection.
352
383
  → [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments-python)
353
384
 
354
385
  No Alembic? `openreceive scaffold payments --sql --dialect postgres` prints
355
- the same DDL for `psql`, a Flyway file, or whatever runs your migrations; in
356
- code, `payments_schema_sql(dialect)` from `openreceive.storage.sql` is the
357
- same string. OpenReceive owns the tables' logic at runtime — locking,
358
- write-once settlement, the reconciliation state machine — and there is
359
- nothing else to generate. Details: [Payment storage](https://openreceive.org/guides/storage.md).
386
+ the same DDL. Feed it to `psql`, a Flyway file, or whatever runs your
387
+ migrations. In code, `payments_schema_sql(dialect)` from
388
+ `openreceive.storage.sql` returns the same string. OpenReceive owns the
389
+ tables' logic at runtime: locking, write-once settlement, and the
390
+ reconciliation state machine. There is nothing else to generate. Details: [Payment storage](https://openreceive.org/guides/storage.md).
360
391
 
361
392
  ### 3. Add wallet credentials
362
393
 
363
- Put the credentials in the server's environment (a `.env` your process
364
- manager loads, `uvicorn --env-file .env`, or your secret store):
394
+ Put the credentials in the server's environment. That can be a `.env` your
395
+ process manager loads, `uvicorn --env-file .env`, or your secret store:
365
396
 
366
397
  ```dotenv
367
398
  NWC_URI=
@@ -370,27 +401,33 @@ LSC_URI_BACKUP=
370
401
  ```
371
402
 
372
403
  1. Get a receive-only NWC code from a compatible wallet
373
- ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
374
- → `NWC_URI`.
375
- 2. Optionally set up a [swap provider](https://openreceive.org/set_up_swap_provider)
376
- → `LSC_URI_PRIMARY` (and `LSC_URI_BACKUP` if you have one).
404
+ ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
405
+ Put it in `NWC_URI`.
406
+ 2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
407
+ Put its connection string in `LSC_URI_PRIMARY`, and a second one in
408
+ `LSC_URI_BACKUP` if you have one.
377
409
 
378
- Never put these values in browser code. Your application refuses to start if
379
- the NWC code also advertises spend methods such as `pay_invoice`; mint a
380
- receive-only code ([Security](https://openreceive.org/guides/security.md)).
410
+ Never put these values in browser code. Your app refuses to start if the NWC
411
+ code also advertises spend methods such as `pay_invoice`. Create a
412
+ receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
381
413
 
382
- OpenReceive reads `os.environ`; a `.env` file on disk is not enough on its
383
- own. `uvicorn --env-file .env` loads one in development; in production the
384
- process manager or secret store injects the values. Every variable is on
385
- [Environment variables](https://openreceive.org/guides/environment-variables.md).
414
+ OpenReceive reads `os.environ`, so a `.env` file on disk is not enough on its
415
+ own. `uvicorn --env-file .env` loads one in development. In production, the
416
+ process manager or secret store injects the values.
417
+ [Environment variables](https://openreceive.org/guides/environment-variables.md) lists every variable.
386
418
 
387
419
  ### 4. Wire OpenReceive
388
420
 
389
- Twelve lines: your three hooks as a `Host`, a router included under a
390
- prefix, and a lifespan that checks the wallet at startup. The router builds
391
- the wallet client from `NWC_URI` and mounts the framework-free engine; there
392
- is no background reconciler — settlement piggybacks on requests through the
393
- durable gate.
421
+ The wiring takes twelve lines:
422
+
423
+ - your three hooks as a `Host`
424
+ - a router included under a prefix
425
+ - a lifespan that checks the wallet at startup
426
+
427
+ The router builds the wallet client from `NWC_URI` and mounts the
428
+ framework-free engine. There is no background reconciler, meaning no job that checks pending
429
+ payments on a timer. Settlement runs during normal requests instead, through
430
+ the durable reconcile gate.
394
431
 
395
432
  ```python
396
433
  from fastapi import FastAPI
@@ -439,26 +476,28 @@ app.include_router(
439
476
  )
440
477
  ```
441
478
 
442
- `authorize` receives the Starlette `Request`, so cookies, headers and whatever
479
+ `authorize` receives the Starlette `Request`. Cookies, headers, and whatever
443
480
  `SessionMiddleware` or auth dependency this app already has are readable
444
- there — FastAPI ships no session of its own, so the payer's `reference` must
445
- be bound to something the request proves. Run uvicorn with `--proxy-headers`
446
- behind a reverse proxy, or `rate_limiting` counts the proxy as the one payer.
447
-
448
- **There is no CSRF layer to add.** FastAPI has none, and OpenReceive does not
449
- want one: every mounted route refuses a request whose `Sec-Fetch-Site` header
450
- says `cross-site`, which is what stops another origin's page from minting or
451
- refunding on a logged-in payer's behalf — exactly the protection the Express
452
- and Fastify adapters rely on. Its limit is the header itself: a client that
453
- does not send it (a non-browser, an old browser) is not refused, so
454
- `authorize` stays the actual boundary. [Security](https://openreceive.org/guides/security.md) has the full
455
- account.
481
+ there. FastAPI ships no session of its own, so you must bind the payer's
482
+ `reference` to something the request proves. Behind a reverse proxy, run
483
+ uvicorn with `--proxy-headers`. Otherwise `rate_limiting` counts the proxy as
484
+ the one payer.
485
+
486
+ **There is no CSRF layer to add.** FastAPI has no CSRF (cross-site request
487
+ forgery) layer, and OpenReceive does not want one. Every mounted route refuses
488
+ a request whose `Sec-Fetch-Site` header says `cross-site`. That stops another
489
+ origin's page from minting or refunding on a logged-in payer's behalf. The
490
+ Express and Fastify adapters rely on exactly the same protection. Its limit is
491
+ the header itself. A client that does not send it, such as a non-browser or an
492
+ old browser, is not refused. So `authorize` stays the actual boundary.
493
+ [Security](https://openreceive.org/guides/security.md) has the full account.
456
494
 
457
495
  `openreceive_lifespan` runs the receive-only wallet preflight when uvicorn
458
- starts and stops the process on a missing, unreachable or spend-capable code —
459
- the deploy fails instead of the first payer. Pass `lazy=True` for tests and
460
- secretless build steps; the first request then checks the wallet and answers
461
- `503 WALLET_UNAVAILABLE` until it passes.
496
+ starts. It stops the process if the code is missing, unreachable, or able to
497
+ spend. That way the deploy fails instead of the first payer. Pass `lazy=True`
498
+ for tests and for build steps that have no secrets. The first request then
499
+ checks the wallet, and requests get `503 WALLET_UNAVAILABLE` until the check
500
+ passes.
462
501
  → [openreceive_router](https://openreceive.org/guides/api-reference.md#openreceive_router) ·
463
502
  [openreceive_lifespan](https://openreceive.org/guides/api-reference.md#openreceive_lifespan) ·
464
503
  [the authorize context](https://openreceive.org/guides/api-reference.md#the-authorize-context)
@@ -475,14 +514,16 @@ prices with exact decimal math, and returns the order id the page will pass as
475
514
  the `reference`. OpenReceive never prices from payer input.
476
515
 
477
516
  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 `on_paid`
480
- commits fulfillment 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.
517
+ your order id. Use one per thing you fulfill, create it before checkout, keep
518
+ it across retries, and never reuse it. OpenReceive never looks inside it, but
519
+ the reference still matters:
520
+
521
+ - `on_paid` commits fulfillment once per reference.
522
+ - A new checkout under a reference that already settled is refused with 409.
523
+ - A fresh id per page load lets one order be paid twice.
483
524
 
484
525
  Naming boundary: the Python API is snake_case (`payment_hash`,
485
- `amount_msats`) and so is everything on the wire — the mounted HTTP routes and
526
+ `amount_msats`), and so is everything on the wire. The mounted HTTP routes and
486
527
  the browser snapshots use the same names.
487
528
 
488
529
  ### 5. Render checkout
@@ -494,49 +535,57 @@ import "@openreceive/react/styles.css";
494
535
  <Checkout reference={order.id} prefix="/openreceive" />;
495
536
  ```
496
537
 
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
538
+ The checkout renders, polls, and settles itself.
539
+
540
+ `@openreceive/react` and `@openreceive/elements` each ship a compiled
541
+ `styles.css`. Each sheet is self-contained, so a plain
542
+ `<link rel="stylesheet">` works with no build step. Each is also scoped: every
500
543
  rule applies only inside what OpenReceive renders.
501
544
 
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.
545
+ Serve the compiled `styles.css` without Tailwind processing. Import it from
546
+ JavaScript if your bundler handles CSS, or use a plain
547
+ `<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
548
+ Its rules have zero specificity, so your page's styles can override checkout
549
+ styles. Scoping does not prevent that.
506
550
 
507
- `<Checkout>` is complete as rendered: it already shows the `description` from
551
+ `<Checkout>` is complete as rendered. It already shows the `description` from
508
552
  `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)).
553
+ UI to show them. The display rules for them become your job only if you
554
+ replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
511
555
 
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.
556
+ Match the host page's theme. By default the checkout follows the payer's
557
+ stored choice, then the system color scheme. If this page always uses one
558
+ theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
559
+ the `theme` attribute. Locking the theme keeps a white card off a dark page.
560
+ CSS variables under `data-theme` style the checkout.
561
+ [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
518
562
 
519
563
  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
564
+ icons, the wallet logos, and the pay tutorials. There is no image file to copy
565
+ or serve, and no asset option to set. Deploy your normal JavaScript and CSS
522
566
  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:`
567
+ splitting can wait to load tutorial screenshots until a tutorial first opens.
568
+ Single-file builds, including the standalone checkout, include them from the
569
+ start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
526
570
  ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
527
571
 
528
- That is the whole loop: your server owns the price and the order, the payer gets
529
- an invoice, and `onPaid` runs inside the settlement transaction. Rolled-back transactions may retry the callback; use a host outbox for external delivery.
572
+ That is the whole loop. Your server owns the price and the order. The payer
573
+ gets an invoice. `onPaid` runs inside the settlement transaction. If that
574
+ transaction rolls back, the callback may run again. For delivery to outside
575
+ systems, use an outbox in your app: record the message in the transaction and
576
+ send it after commit.
530
577
 
531
578
  A page without a bundler renders the same checkout as a custom element:
532
579
  `<openreceive-checkout reference="…" prefix="/openreceive">` from
533
- `@openreceive/elements` (or its standalone build, served from your static
534
- directory). A runnable illustration of the boundary — not a template to copy
535
- models from — is Buy a Button
536
- (`examples/buttons/server/fastapi`):
537
- products, visitors and orders in SQLite, the three hooks as the only bridge,
538
- and the smallest correct FastAPI integration of the packaged checkout. Map
539
- that shape onto the models in THIS app.
580
+ `@openreceive/elements`. You can also serve its standalone build from your
581
+ static directory.
582
+
583
+ Buy a Button is a runnable illustration of the boundary
584
+ (`examples/buttons/server/fastapi`).
585
+ It is not a template to copy models from. It keeps products, visitors and
586
+ orders in SQLite, and the three hooks are the only bridge to OpenReceive. It
587
+ is the smallest correct FastAPI integration of the packaged checkout. Map that
588
+ shape onto the models in THIS app.
540
589
 
541
590
  ### 6. Verify
542
591
 
@@ -545,13 +594,13 @@ openreceive doctor --app main:app
545
594
  ```
546
595
 
547
596
  `openreceive doctor` checks Python, `NWC_URI`, and swap-provider
548
- configuration, and probes the wallet relay to confirm the code is
597
+ configuration. It also probes the wallet relay to confirm the code is
549
598
  receive-only. With `--app module:attr` (your FastAPI app, the router, or an
550
- `OpenReceiveApp`) it also confirms the migration ran and names any hook still
551
- on a placeholder; add `--url http://localhost:8000` to confirm the routes are
552
- mounted. Every failing line states its own fix; exit code 1 when anything
553
- fails. `openreceive debug-report` prints the same as a redacted support
554
- report.
599
+ `OpenReceiveApp`), it also confirms the migration ran and names any hook still
600
+ on a placeholder. Add `--url http://localhost:8000` to confirm the routes are
601
+ mounted. Every failing line states its own fix, and the command exits with
602
+ code 1 when anything fails. `openreceive debug-report` prints the same output
603
+ as a redacted support report.
555
604
  → [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor-python)
556
605
 
557
606
  Then open the checkout in a browser, confirm the payment-method icons and
@@ -561,6 +610,6 @@ panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
561
610
  complete build output. Do not add image routes, copy package source images, or
562
611
  use registry `icon_path` / tutorial `path` keys as browser URLs.
563
612
 
564
- Swap credentials (`LSC_URI_*`) stay server-side too: the provider order id and
565
- token live in the attempt's server-only `swap_data` column and never reach a
613
+ Swap credentials (`LSC_URI_*`) stay server-side too. The provider order id and
614
+ token live in the attempt's server-only `swap_data` column. They never reach a
566
615
  response or a log ([Automated swaps](https://openreceive.org/guides/automated-swaps.md)).