openreceive-rails 0.4.11 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/generators/openreceive/install/templates/initializer.rb +1 -1
- data/lib/openreceive/configuration.rb +1 -1
- data/lib/openreceive/rails/version.rb +1 -1
- data/lib/openreceive/reconcile.rb +11 -6
- data/lib/openreceive/reconcile_scan.rb +15 -2
- data/skills/debug-openreceive-payment/SKILL.md +1 -1
- data/skills/integrate-openreceive/SKILL.md +4 -3
- data/skills/integrate-openreceive/references/btcpay.md +65 -36
- data/skills/integrate-openreceive/references/django.md +288 -243
- data/skills/integrate-openreceive/references/fastapi.md +203 -154
- data/skills/integrate-openreceive/references/fastify.md +197 -146
- data/skills/integrate-openreceive/references/laravel.md +291 -233
- data/skills/integrate-openreceive/references/next.md +207 -161
- data/skills/integrate-openreceive/references/node.md +185 -137
- data/skills/integrate-openreceive/references/php.md +245 -192
- data/skills/integrate-openreceive/references/rails.md +259 -217
- data/skills/integrate-openreceive/references/woocommerce.md +66 -51
- metadata +5 -5
|
@@ -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.13.
|
|
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
|
|
|
@@ -322,19 +349,20 @@ pip install "openreceive[fastapi]"
|
|
|
322
349
|
npm install @openreceive/react
|
|
323
350
|
```
|
|
324
351
|
|
|
325
|
-
|
|
326
|
-
FastAPI, Starlette and SQLAlchemy
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
stack
|
|
330
|
-
|
|
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
|
|
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
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
|
356
|
-
code, `payments_schema_sql(dialect)` from
|
|
357
|
-
same string. OpenReceive owns the
|
|
358
|
-
write-once settlement,
|
|
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
|
|
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
|
-
|
|
375
|
-
2.
|
|
376
|
-
|
|
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
|
|
379
|
-
|
|
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
|
|
383
|
-
own. `uvicorn --env-file .env` loads one in development
|
|
384
|
-
process manager or secret store injects the values.
|
|
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
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
|
479
|
+
`authorize` receives the Starlette `Request`. Cookies, headers, and whatever
|
|
443
480
|
`SessionMiddleware` or auth dependency this app already has are readable
|
|
444
|
-
there
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
|
459
|
-
the deploy fails instead of the first payer. Pass `lazy=True`
|
|
460
|
-
|
|
461
|
-
`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.
|
|
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
|
|
479
|
-
across retries, never
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
|
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.
|
|
498
|
-
|
|
499
|
-
|
|
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
|
|
503
|
-
JavaScript
|
|
504
|
-
Do not `@import` it into
|
|
505
|
-
|
|
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
|
|
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
|
|
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
|
|
513
|
-
stored choice, then the system scheme. If this page
|
|
514
|
-
it
|
|
515
|
-
|
|
516
|
-
variables under `data-theme
|
|
517
|
-
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.
|
|
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
|
|
524
|
-
|
|
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
|
|
529
|
-
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.
|
|
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
|
|
534
|
-
directory
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
|
|
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
|
|
552
|
-
mounted. Every failing line states its own fix
|
|
553
|
-
fails. `openreceive debug-report` prints the same
|
|
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
|
|
565
|
-
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
|
|
566
615
|
response or a log ([Automated swaps](https://openreceive.org/guides/automated-swaps.md)).
|