@openreceive/react 0.4.10 → 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.10.
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
 
@@ -116,7 +143,7 @@ itself, and they hold for every integration.
116
143
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
117
144
  the payer made, not proof. Read the Starlette request's session, cookie or
118
145
  auth dependency; never trust a body field.
119
- - `on_paid` must be idempotent. It runs once per `reference` — your order id, one
146
+ - `on_paid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
120
147
  per thing you fulfill, created before checkout, kept across retries, never
121
148
  reused. A fresh id per page load lets one order be paid twice.
122
149
  - Receive-only NWC is required; a spend-capable code fails closed at boot unless
@@ -301,6 +328,8 @@ enough; drop the `.md` for the same page a person would read.
301
328
  Questions, or a problem with the library itself:
302
329
  https://openreceive.org/contact
303
330
 
331
+ - https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
332
+
304
333
  ---
305
334
 
306
335
  ## The quickstart, in full
@@ -320,19 +349,20 @@ pip install "openreceive[fastapi]"
320
349
  npm install @openreceive/react
321
350
  ```
322
351
 
323
- One Python distribution with framework extras: `openreceive[fastapi]` brings
324
- FastAPI, Starlette and SQLAlchemy; the wallet client (websockets, coincurve,
325
- cryptography), the HTTP engine and the `openreceive` CLI come with the base
326
- package. The npm package is the checkout UI for your frontend. Different
327
- stack? Swap the two: `openreceive[django]` with the Django quickstart; a
328
- 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.
329
359
 
330
360
  | | Packages |
331
361
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
332
362
  | Server | `openreceive[fastapi]`, `openreceive[django]`, `openreceive[sqlalchemy]` (Flask and plain WSGI/ASGI: the Flask recipe) |
333
363
  | Frontend | `@openreceive/react`, `@openreceive/vue`, `@openreceive/svelte`, `@openreceive/angular`, `@openreceive/elements` (plain HTML) |
334
364
 
335
- 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
336
366
  install the package.
337
367
 
338
368
  ### 2. Migrate the payment tables
@@ -342,24 +372,27 @@ openreceive scaffold payments --alembic --dialect postgres # or sqlite | mysq
342
372
  ```
343
373
 
344
374
  `openreceive scaffold payments --alembic` writes one Alembic revision into
345
- `alembic/versions/` that creates `openreceive_payments` (the payment attempts)
346
- and `openreceive_meta` (the reconcile gate) with the DDL frozen in the file.
347
- Set its `down_revision` to your current head (`alembic heads`), then apply it
348
- the way you apply your own: `alembic upgrade head`. It never opens a database
349
- 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.
350
383
  → [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments-python)
351
384
 
352
385
  No Alembic? `openreceive scaffold payments --sql --dialect postgres` prints
353
- the same DDL for `psql`, a Flyway file, or whatever runs your migrations; in
354
- code, `payments_schema_sql(dialect)` from `openreceive.storage.sql` is the
355
- same string. OpenReceive owns the tables' logic at runtime — locking,
356
- write-once settlement, the reconciliation state machine — and there is
357
- 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).
358
391
 
359
392
  ### 3. Add wallet credentials
360
393
 
361
- Put the credentials in the server's environment (a `.env` your process
362
- 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:
363
396
 
364
397
  ```dotenv
365
398
  NWC_URI=
@@ -368,27 +401,33 @@ LSC_URI_BACKUP=
368
401
  ```
369
402
 
370
403
  1. Get a receive-only NWC code from a compatible wallet
371
- ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
372
- → `NWC_URI`.
373
- 2. Optionally set up a [swap provider](https://openreceive.org/set_up_swap_provider)
374
- → `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.
375
409
 
376
- Never put these values in browser code. Your application refuses to start if
377
- the NWC code also advertises spend methods such as `pay_invoice`; mint a
378
- 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)).
379
413
 
380
- OpenReceive reads `os.environ`; a `.env` file on disk is not enough on its
381
- own. `uvicorn --env-file .env` loads one in development; in production the
382
- process manager or secret store injects the values. Every variable is on
383
- [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.
384
418
 
385
419
  ### 4. Wire OpenReceive
386
420
 
387
- Twelve lines: your three hooks as a `Host`, a router included under a
388
- prefix, and a lifespan that checks the wallet at startup. The router builds
389
- the wallet client from `NWC_URI` and mounts the framework-free engine; there
390
- is no background reconciler — settlement piggybacks on requests through the
391
- 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.
392
431
 
393
432
  ```python
394
433
  from fastapi import FastAPI
@@ -437,26 +476,28 @@ app.include_router(
437
476
  )
438
477
  ```
439
478
 
440
- `authorize` receives the Starlette `Request`, so cookies, headers and whatever
479
+ `authorize` receives the Starlette `Request`. Cookies, headers, and whatever
441
480
  `SessionMiddleware` or auth dependency this app already has are readable
442
- there — FastAPI ships no session of its own, so the payer's `reference` must
443
- be bound to something the request proves. Run uvicorn with `--proxy-headers`
444
- behind a reverse proxy, or `rate_limiting` counts the proxy as the one payer.
445
-
446
- **There is no CSRF layer to add.** FastAPI has none, and OpenReceive does not
447
- want one: every mounted route refuses a request whose `Sec-Fetch-Site` header
448
- says `cross-site`, which is what stops another origin's page from minting or
449
- refunding on a logged-in payer's behalf — exactly the protection the Express
450
- and Fastify adapters rely on. Its limit is the header itself: a client that
451
- does not send it (a non-browser, an old browser) is not refused, so
452
- `authorize` stays the actual boundary. [Security](https://openreceive.org/guides/security.md) has the full
453
- 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.
454
494
 
455
495
  `openreceive_lifespan` runs the receive-only wallet preflight when uvicorn
456
- starts and stops the process on a missing, unreachable or spend-capable code —
457
- the deploy fails instead of the first payer. Pass `lazy=True` for tests and
458
- secretless build steps; the first request then checks the wallet and answers
459
- `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.
460
501
  → [openreceive_router](https://openreceive.org/guides/api-reference.md#openreceive_router) ·
461
502
  [openreceive_lifespan](https://openreceive.org/guides/api-reference.md#openreceive_lifespan) ·
462
503
  [the authorize context](https://openreceive.org/guides/api-reference.md#the-authorize-context)
@@ -473,14 +514,16 @@ prices with exact decimal math, and returns the order id the page will pass as
473
514
  the `reference`. OpenReceive never prices from payer input.
474
515
 
475
516
  The `reference` is a string you choose, and it is the fulfillment identity:
476
- your order id — one per thing you fulfill, created before checkout, kept
477
- across retries, never reused. OpenReceive never looks inside it, but `on_paid`
478
- runs once per reference, a new checkout under a reference that already
479
- settled is refused with 409, and a fresh id per page load lets one order be
480
- 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.
481
524
 
482
525
  Naming boundary: the Python API is snake_case (`payment_hash`,
483
- `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
484
527
  the browser snapshots use the same names.
485
528
 
486
529
  ### 5. Render checkout
@@ -492,49 +535,57 @@ import "@openreceive/react/styles.css";
492
535
  <Checkout reference={order.id} prefix="/openreceive" />;
493
536
  ```
494
537
 
495
- The checkout renders, polls, and settles itself. The compiled `styles.css`
496
- sheets (`@openreceive/react`, `@openreceive/elements`) are self-contained — a
497
- 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
498
543
  rule applies only inside what OpenReceive renders.
499
544
 
500
- Serve the compiled `styles.css` without Tailwind processing: import it from
501
- JavaScript (with a CSS-capable bundler) or use a plain `<link rel="stylesheet">`.
502
- Do not `@import` it into the host Tailwind entry. Its zero-specificity rules
503
- 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.
504
550
 
505
- `<Checkout>` is complete as rendered: it already shows the `description` from
551
+ `<Checkout>` is complete as rendered. It already shows the `description` from
506
552
  `amountFor` and the collapsed transaction-details panel. Do not build a custom
507
- UI to satisfy those rules — they only become your job if you replace the
508
- 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)).
509
555
 
510
- Match the host page's theme: by default the checkout follows the payer's
511
- stored choice, then the system scheme. If this page is always one theme, lock
512
- it — `<Checkout theme="dark" … />` (`theme` attribute on the custom element) —
513
- so a white card never lands on a dark page. The checkout is styled by CSS
514
- variables under `data-theme`; [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) has
515
- 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.
516
562
 
517
563
  Everything the checkout draws ships inside the JavaScript: the payment-method
518
- icons, the wallet logos and the pay tutorials. There is no image file to copy
519
- 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
520
566
  build output, including any generated JavaScript chunks. Bundlers with code
521
- splitting can defer tutorial screenshots until first open; single-file builds
522
- (including the standalone checkout) include them upfront. If your
523
- 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:`
524
570
  ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
525
571
 
526
- That is the whole loop: your server owns the price and the order, the payer gets
527
- an invoice, and `onPaid` runs once inside the settlement transaction.
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.
528
577
 
529
578
  A page without a bundler renders the same checkout as a custom element:
530
579
  `<openreceive-checkout reference="…" prefix="/openreceive">` from
531
- `@openreceive/elements` (or its standalone build, served from your static
532
- directory). A runnable illustration of the boundary — not a template to copy
533
- models from — is Buy a Button
534
- (`examples/buttons/server/fastapi`):
535
- products, visitors and orders in SQLite, the three hooks as the only bridge,
536
- and the smallest correct FastAPI integration of the packaged checkout. Map
537
- 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.
538
589
 
539
590
  ### 6. Verify
540
591
 
@@ -543,13 +594,13 @@ openreceive doctor --app main:app
543
594
  ```
544
595
 
545
596
  `openreceive doctor` checks Python, `NWC_URI`, and swap-provider
546
- configuration, and probes the wallet relay to confirm the code is
597
+ configuration. It also probes the wallet relay to confirm the code is
547
598
  receive-only. With `--app module:attr` (your FastAPI app, the router, or an
548
- `OpenReceiveApp`) it also confirms the migration ran and names any hook still
549
- on a placeholder; add `--url http://localhost:8000` to confirm the routes are
550
- mounted. Every failing line states its own fix; exit code 1 when anything
551
- fails. `openreceive debug-report` prints the same as a redacted support
552
- 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.
553
604
  → [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor-python)
554
605
 
555
606
  Then open the checkout in a browser, confirm the payment-method icons and
@@ -559,6 +610,6 @@ panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
559
610
  complete build output. Do not add image routes, copy package source images, or
560
611
  use registry `icon_path` / tutorial `path` keys as browser URLs.
561
612
 
562
- Swap credentials (`LSC_URI_*`) stay server-side too: the provider order id and
563
- 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
564
615
  response or a log ([Automated swaps](https://openreceive.org/guides/automated-swaps.md)).