openreceive 0.4.11 → 0.4.14

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.14.
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
 
@@ -130,15 +157,19 @@ itself, and they hold for every integration.
130
157
  late becomes `refund_required`, and the payer claims it on a SECOND VISIT,
131
158
  after leaving your page to fetch an address from another wallet. Three things
132
159
  must exist or that money is unreachable through your UI: a per-order URL your
133
- server serves (`/checkout/:reference` — `syncUrl` on the drop-ins), your own
134
- order-summary route to restore the order from, and the ATTEMPT.
160
+ server serves (`/checkout/:reference` — `syncUrl` on `<Checkout>`, `sync-url`
161
+ or `resumable` on `<openreceive-checkout>`), your own order-summary route to
162
+ restore the order from, and the ATTEMPT.
135
163
  `/checkouts/prepare` returns no attempts, so a checkout rebuilt from the
136
164
  reference alone opens on the method grid. Re-picking the same coin
137
165
  (`POST /swaps`) re-serves the committed attempt — but only while it is live,
138
166
  and the shadow invoice behind a swap lasts about half an hour, after which the
139
167
  same click mints a NEW deposit address and the refund is off-screen. Keep the
140
168
  `payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
141
- such window. https://openreceive.org/guides/swap-refunds.md
169
+ such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
170
+ `<Checkout>`; the `resume-payment-hash` attribute, fed from the
171
+ `openreceive-state` event (`event.detail.state.payment_hash`), on
172
+ `<openreceive-checkout>`. https://openreceive.org/guides/swap-refunds.md
142
173
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
143
174
  the price from `amount_for` and both drop-ins render it above the amount.
144
175
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
@@ -322,19 +353,20 @@ pip install "openreceive[fastapi]"
322
353
  npm install @openreceive/react
323
354
  ```
324
355
 
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.
356
+ OpenReceive is one Python distribution with framework extras.
357
+ `openreceive[fastapi]` brings FastAPI, Starlette and SQLAlchemy. The base
358
+ package includes the wallet client (websockets, coincurve, cryptography), the
359
+ HTTP engine and the `openreceive` CLI. The npm package is the checkout UI for
360
+ your frontend. On a different stack, swap the two: use `openreceive[django]`
361
+ with the Django quickstart. A page without a bundler uses
362
+ `@openreceive/elements` instead of React.
331
363
 
332
364
  | | Packages |
333
365
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
334
366
  | Server | `openreceive[fastapi]`, `openreceive[django]`, `openreceive[sqlalchemy]` (Flask and plain WSGI/ASGI: the Flask recipe) |
335
367
  | Frontend | `@openreceive/react`, `@openreceive/vue`, `@openreceive/svelte`, `@openreceive/angular`, `@openreceive/elements` (plain HTML) |
336
368
 
337
- Use `uv` or a virtualenv on Python 3.10 or newer; a system Python 3.9 cannot
369
+ Use `uv` or a virtualenv on Python 3.10 or newer. A system Python 3.9 cannot
338
370
  install the package.
339
371
 
340
372
  ### 2. Migrate the payment tables
@@ -344,24 +376,27 @@ openreceive scaffold payments --alembic --dialect postgres # or sqlite | mysq
344
376
  ```
345
377
 
346
378
  `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.
379
+ `alembic/versions/`. The DDL is frozen in the file, and it creates two tables:
380
+
381
+ - `openreceive_payments`, the payment attempts
382
+ - `openreceive_meta`, the reconcile gate
383
+
384
+ Set the revision's `down_revision` to your current head (`alembic heads`).
385
+ Then apply it the way you apply your own revisions: `alembic upgrade head`.
386
+ The command never opens a database connection.
352
387
  → [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments-python)
353
388
 
354
389
  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).
390
+ the same DDL. Feed it to `psql`, a Flyway file, or whatever runs your
391
+ migrations. In code, `payments_schema_sql(dialect)` from
392
+ `openreceive.storage.sql` returns the same string. OpenReceive owns the
393
+ tables' logic at runtime: locking, write-once settlement, and the
394
+ reconciliation state machine. There is nothing else to generate. Details: [Payment storage](https://openreceive.org/guides/storage.md).
360
395
 
361
396
  ### 3. Add wallet credentials
362
397
 
363
- Put the credentials in the server's environment (a `.env` your process
364
- manager loads, `uvicorn --env-file .env`, or your secret store):
398
+ Put the credentials in the server's environment. That can be a `.env` your
399
+ process manager loads, `uvicorn --env-file .env`, or your secret store:
365
400
 
366
401
  ```dotenv
367
402
  NWC_URI=
@@ -370,27 +405,33 @@ LSC_URI_BACKUP=
370
405
  ```
371
406
 
372
407
  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).
408
+ ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
409
+ Put it in `NWC_URI`.
410
+ 2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
411
+ Put its connection string in `LSC_URI_PRIMARY`, and a second one in
412
+ `LSC_URI_BACKUP` if you have one.
377
413
 
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)).
414
+ Never put these values in browser code. Your app refuses to start if the NWC
415
+ code also advertises spend methods such as `pay_invoice`. Create a
416
+ receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
381
417
 
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).
418
+ OpenReceive reads `os.environ`, so a `.env` file on disk is not enough on its
419
+ own. `uvicorn --env-file .env` loads one in development. In production, the
420
+ process manager or secret store injects the values.
421
+ [Environment variables](https://openreceive.org/guides/environment-variables.md) lists every variable.
386
422
 
387
423
  ### 4. Wire OpenReceive
388
424
 
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.
425
+ The wiring takes twelve lines:
426
+
427
+ - your three hooks as a `Host`
428
+ - a router included under a prefix
429
+ - a lifespan that checks the wallet at startup
430
+
431
+ The router builds the wallet client from `NWC_URI` and mounts the
432
+ framework-free engine. There is no background reconciler, meaning no job that checks pending
433
+ payments on a timer. Settlement runs during normal requests instead, through
434
+ the durable reconcile gate.
394
435
 
395
436
  ```python
396
437
  from fastapi import FastAPI
@@ -439,26 +480,28 @@ app.include_router(
439
480
  )
440
481
  ```
441
482
 
442
- `authorize` receives the Starlette `Request`, so cookies, headers and whatever
483
+ `authorize` receives the Starlette `Request`. Cookies, headers, and whatever
443
484
  `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.
485
+ there. FastAPI ships no session of its own, so you must bind the payer's
486
+ `reference` to something the request proves. Behind a reverse proxy, run
487
+ uvicorn with `--proxy-headers`. Otherwise `rate_limiting` counts the proxy as
488
+ the one payer.
489
+
490
+ **There is no CSRF layer to add.** FastAPI has no CSRF (cross-site request
491
+ forgery) layer, and OpenReceive does not want one. Every mounted route refuses
492
+ a request whose `Sec-Fetch-Site` header says `cross-site`. That stops another
493
+ origin's page from minting or refunding on a logged-in payer's behalf. The
494
+ Express and Fastify adapters rely on exactly the same protection. Its limit is
495
+ the header itself. A client that does not send it, such as a non-browser or an
496
+ old browser, is not refused. So `authorize` stays the actual boundary.
497
+ [Security](https://openreceive.org/guides/security.md) has the full account.
456
498
 
457
499
  `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.
500
+ starts. It stops the process if the code is missing, unreachable, or able to
501
+ spend. That way the deploy fails instead of the first payer. Pass `lazy=True`
502
+ for tests and for build steps that have no secrets. The first request then
503
+ checks the wallet, and requests get `503 WALLET_UNAVAILABLE` until the check
504
+ passes.
462
505
  → [openreceive_router](https://openreceive.org/guides/api-reference.md#openreceive_router) ·
463
506
  [openreceive_lifespan](https://openreceive.org/guides/api-reference.md#openreceive_lifespan) ·
464
507
  [the authorize context](https://openreceive.org/guides/api-reference.md#the-authorize-context)
@@ -475,14 +518,16 @@ prices with exact decimal math, and returns the order id the page will pass as
475
518
  the `reference`. OpenReceive never prices from payer input.
476
519
 
477
520
  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.
521
+ your order id. Use one per thing you fulfill, create it before checkout, keep
522
+ it across retries, and never reuse it. OpenReceive never looks inside it, but
523
+ the reference still matters:
524
+
525
+ - `on_paid` commits fulfillment once per reference.
526
+ - A new checkout under a reference that already settled is refused with 409.
527
+ - A fresh id per page load lets one order be paid twice.
483
528
 
484
529
  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
530
+ `amount_msats`), and so is everything on the wire. The mounted HTTP routes and
486
531
  the browser snapshots use the same names.
487
532
 
488
533
  ### 5. Render checkout
@@ -494,49 +539,57 @@ import "@openreceive/react/styles.css";
494
539
  <Checkout reference={order.id} prefix="/openreceive" />;
495
540
  ```
496
541
 
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
542
+ The checkout renders, polls, and settles itself.
543
+
544
+ `@openreceive/react` and `@openreceive/elements` each ship a compiled
545
+ `styles.css`. Each sheet is self-contained, so a plain
546
+ `<link rel="stylesheet">` works with no build step. Each is also scoped: every
500
547
  rule applies only inside what OpenReceive renders.
501
548
 
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.
549
+ Serve the compiled `styles.css` without Tailwind processing. Import it from
550
+ JavaScript if your bundler handles CSS, or use a plain
551
+ `<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
552
+ Its rules have zero specificity, so your page's styles can override checkout
553
+ styles. Scoping does not prevent that.
506
554
 
507
- `<Checkout>` is complete as rendered: it already shows the `description` from
555
+ `<Checkout>` is complete as rendered. It already shows the `description` from
508
556
  `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)).
557
+ UI to show them. The display rules for them become your job only if you
558
+ replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
511
559
 
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.
560
+ Match the host page's theme. By default the checkout follows the payer's
561
+ stored choice, then the system color scheme. If this page always uses one
562
+ theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
563
+ the `theme` attribute. Locking the theme keeps a white card off a dark page.
564
+ CSS variables under `data-theme` style the checkout.
565
+ [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
518
566
 
519
567
  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
568
+ icons, the wallet logos, and the pay tutorials. There is no image file to copy
569
+ or serve, and no asset option to set. Deploy your normal JavaScript and CSS
522
570
  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:`
571
+ splitting can wait to load tutorial screenshots until a tutorial first opens.
572
+ Single-file builds, including the standalone checkout, include them from the
573
+ start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
526
574
  ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
527
575
 
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.
576
+ That is the whole loop. Your server owns the price and the order. The payer
577
+ gets an invoice. `onPaid` runs inside the settlement transaction. If that
578
+ transaction rolls back, the callback may run again. For delivery to outside
579
+ systems, use an outbox in your app: record the message in the transaction and
580
+ send it after commit.
530
581
 
531
582
  A page without a bundler renders the same checkout as a custom element:
532
583
  `<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.
584
+ `@openreceive/elements`. You can also serve its standalone build from your
585
+ static directory.
586
+
587
+ Buy a Button is a runnable illustration of the boundary
588
+ (`examples/buttons/server/fastapi`).
589
+ It is not a template to copy models from. It keeps products, visitors and
590
+ orders in SQLite, and the three hooks are the only bridge to OpenReceive. It
591
+ is the smallest correct FastAPI integration of the packaged checkout. Map that
592
+ shape onto the models in THIS app.
540
593
 
541
594
  ### 6. Verify
542
595
 
@@ -545,13 +598,13 @@ openreceive doctor --app main:app
545
598
  ```
546
599
 
547
600
  `openreceive doctor` checks Python, `NWC_URI`, and swap-provider
548
- configuration, and probes the wallet relay to confirm the code is
601
+ configuration. It also probes the wallet relay to confirm the code is
549
602
  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.
603
+ `OpenReceiveApp`), it also confirms the migration ran and names any hook still
604
+ on a placeholder. Add `--url http://localhost:8000` to confirm the routes are
605
+ mounted. Every failing line states its own fix, and the command exits with
606
+ code 1 when anything fails. `openreceive debug-report` prints the same output
607
+ as a redacted support report.
555
608
  → [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor-python)
556
609
 
557
610
  Then open the checkout in a browser, confirm the payment-method icons and
@@ -561,6 +614,6 @@ panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
561
614
  complete build output. Do not add image routes, copy package source images, or
562
615
  use registry `icon_path` / tutorial `path` keys as browser URLs.
563
616
 
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
617
+ Swap credentials (`LSC_URI_*`) stay server-side too. The provider order id and
618
+ token live in the attempt's server-only `swap_data` column. They never reach a
566
619
  response or a log ([Automated swaps](https://openreceive.org/guides/automated-swaps.md)).