@openreceive/fastify 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.
- package/package.json +2 -2
- package/skills/integrate-openreceive/SKILL.md +4 -3
- package/skills/integrate-openreceive/references/btcpay.md +67 -36
- package/skills/integrate-openreceive/references/django.md +291 -244
- package/skills/integrate-openreceive/references/fastapi.md +206 -155
- package/skills/integrate-openreceive/references/fastify.md +200 -147
- package/skills/integrate-openreceive/references/laravel.md +294 -234
- package/skills/integrate-openreceive/references/next.md +210 -162
- package/skills/integrate-openreceive/references/node.md +188 -138
- package/skills/integrate-openreceive/references/php.md +248 -193
- package/skills/integrate-openreceive/references/rails.md +262 -218
- package/skills/integrate-openreceive/references/woocommerce.md +68 -51
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenReceive agent directions (FastAPI)
|
|
2
2
|
|
|
3
|
-
These directions describe OpenReceive 0.4.
|
|
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.
|
|
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 —
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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.
|
|
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
|
-
|
|
324
|
-
FastAPI, Starlette and SQLAlchemy
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
stack
|
|
328
|
-
|
|
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
|
|
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
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
|
354
|
-
code, `payments_schema_sql(dialect)` from
|
|
355
|
-
same string. OpenReceive owns the
|
|
356
|
-
write-once settlement,
|
|
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
|
|
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
|
-
|
|
373
|
-
2.
|
|
374
|
-
|
|
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
|
|
377
|
-
|
|
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
|
|
381
|
-
own. `uvicorn --env-file .env` loads one in development
|
|
382
|
-
process manager or secret store injects the values.
|
|
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
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
|
479
|
+
`authorize` receives the Starlette `Request`. Cookies, headers, and whatever
|
|
441
480
|
`SessionMiddleware` or auth dependency this app already has are readable
|
|
442
|
-
there
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
|
457
|
-
the deploy fails instead of the first payer. Pass `lazy=True`
|
|
458
|
-
|
|
459
|
-
`503 WALLET_UNAVAILABLE` until
|
|
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
|
|
477
|
-
across retries, never
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
|
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.
|
|
496
|
-
|
|
497
|
-
|
|
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
|
|
501
|
-
JavaScript
|
|
502
|
-
Do not `@import` it into
|
|
503
|
-
|
|
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
|
|
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
|
|
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
|
|
511
|
-
stored choice, then the system scheme. If this page
|
|
512
|
-
it
|
|
513
|
-
|
|
514
|
-
variables under `data-theme
|
|
515
|
-
the
|
|
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
|
|
522
|
-
|
|
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
|
|
527
|
-
an invoice
|
|
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
|
|
532
|
-
directory
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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
|
|
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
|
|
550
|
-
mounted. Every failing line states its own fix
|
|
551
|
-
fails. `openreceive debug-report` prints the same
|
|
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
|
|
563
|
-
token live in the attempt's server-only `swap_data` column
|
|
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)).
|