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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/openreceive/version.rb +1 -1
- 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 +295 -246
- data/skills/integrate-openreceive/references/fastapi.md +210 -157
- data/skills/integrate-openreceive/references/fastify.md +206 -149
- data/skills/integrate-openreceive/references/laravel.md +298 -236
- data/skills/integrate-openreceive/references/next.md +216 -164
- data/skills/integrate-openreceive/references/node.md +194 -140
- data/skills/integrate-openreceive/references/php.md +248 -193
- data/skills/integrate-openreceive/references/rails.md +266 -220
- data/skills/integrate-openreceive/references/woocommerce.md +66 -51
- metadata +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenReceive agent directions (Fastify)
|
|
2
2
|
|
|
3
|
-
These directions describe OpenReceive 0.4.
|
|
3
|
+
These directions describe OpenReceive 0.4.14.
|
|
4
4
|
|
|
5
5
|
Add OpenReceive to a Fastify application — the app you are already working in.
|
|
6
6
|
You do not need a copy of the OpenReceive source: the packages are on npm, and
|
|
@@ -34,62 +34,90 @@ The one required credential is a receive-only NWC code (Nostr Wallet Connect):
|
|
|
34
34
|
a string from the merchant's wallet that can create invoices and read their
|
|
35
35
|
status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
|
|
36
36
|
payer send USDT, USDC, ETH or SOL instead, converted into that same
|
|
37
|
-
Lightning payment.
|
|
37
|
+
Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`, `amountFor`,
|
|
38
38
|
`onPaid`;
|
|
39
39
|
OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
|
|
40
40
|
owns orders, users, prices, or fulfillment.
|
|
41
41
|
|
|
42
|
-
## Step 0 —
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
42
|
+
## Step 0 — ask for the two codes, one question at a time
|
|
43
|
+
|
|
44
|
+
Before anything else, look at one file: the project's `.env`, if it exists.
|
|
45
|
+
Read it only far enough to see whether `NWC_URI` and `LSC_URI_PRIMARY` are
|
|
46
|
+
there and non-empty, and never print the values. A code that is already
|
|
47
|
+
set is not asked for again; if both are set, skip to step 5
|
|
48
|
+
(making the server load the file), then the quickstart.
|
|
49
|
+
|
|
50
|
+
Otherwise your next action is a question to the user. Do not install packages,
|
|
51
|
+
edit the app, write `.env.example`, or search anywhere else before asking
|
|
52
|
+
it. Do not read deploy config (compose files, platform secrets), Docker containers, or process environments, and never run
|
|
53
|
+
`printenv`. A new shop has neither code yet: hunting for one burns the turn and
|
|
54
|
+
can leak other secrets into the transcript.
|
|
55
|
+
|
|
56
|
+
Two server-only URIs are needed before the quickstart:
|
|
57
|
+
|
|
58
|
+
- `NWC_URI` — a receive-only Nostr Wallet Connect code,
|
|
59
|
+
`nostr+walletconnect://…`. Required for Bitcoin.
|
|
60
|
+
- `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
|
|
61
|
+
`lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
|
|
62
|
+
only when the user says they want Bitcoin alone.
|
|
63
|
+
|
|
64
|
+
The user never edits an environment file. They paste each code into the chat;
|
|
65
|
+
you store it. Ask one question per message.
|
|
66
|
+
|
|
67
|
+
1. **First message — the NWC code, and nothing else.** Ask for it and walk them
|
|
68
|
+
through getting it:
|
|
69
|
+
|
|
70
|
+
> To receive payments I need a receive-only wallet code. In Rizful: open
|
|
71
|
+
> the menu, tap NWC, choose Receive-only NWC code, and tap Copy
|
|
72
|
+
> (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
|
|
73
|
+
> rather run your own wallet, Alby Hub works too: Connections → Add
|
|
74
|
+
> Connection → Read Only. Paste the code here and I will store it.
|
|
75
|
+
|
|
76
|
+
Do not mention `.env`, exports, or "tell me when it's set".
|
|
77
|
+
2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
|
|
78
|
+
ask them to copy the receive-only code again. Otherwise write
|
|
79
|
+
`NWC_URI=<paste>` into the project's `.env`, creating the file if needed.
|
|
80
|
+
Make sure `.gitignore` covers `.env` (and `.dockerignore`, if the app has
|
|
81
|
+
one). Never echo the value, commit it, or put it in client code. Reply only
|
|
82
|
+
that it is saved, then ask the next question.
|
|
83
|
+
3. **Second message — swaps.** If the user already asked for stablecoins or
|
|
84
|
+
altcoins, skip the yes/no and go straight to the walkthrough. Otherwise ask
|
|
85
|
+
whether payers should also be able to pay with USDT, USDC, ETH or SOL. The
|
|
86
|
+
walkthrough:
|
|
87
|
+
|
|
88
|
+
> Go to https://lightning-swap.com, sign in for API keys, create a key, and
|
|
89
|
+
> copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
|
|
90
|
+
> it here and I will store it — or say "Bitcoin only" and I will continue
|
|
91
|
+
> without it.
|
|
92
|
+
|
|
93
|
+
Mention FixedFloat only if they already use it.
|
|
94
|
+
4. **When they paste it.** If it does not start with
|
|
95
|
+
`lightning+swapconnect://`, ask them to copy it again. Otherwise add
|
|
96
|
+
`LSC_URI_PRIMARY=<paste>` to the same `.env`, without echoing it. Swaps
|
|
97
|
+
are now on, so build the refund route back (the swap non-negotiable below) as
|
|
98
|
+
part of this integration. If they chose Bitcoin only, leave
|
|
99
|
+
`LSC_URI_PRIMARY` unset and skip that route.
|
|
100
|
+
5. **Make the server load the file — yourself.** OpenReceive reads
|
|
101
|
+
`process.env`, and a `.env` file on disk is not in it. Put
|
|
102
|
+
`import "dotenv/config";` at the top of the server entry, as the quickstart
|
|
103
|
+
does. When the app is started with Docker Compose, give the service
|
|
104
|
+
`env_file: .env`. Restart the server after writing the file.
|
|
105
|
+
|
|
106
|
+
Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
|
|
107
|
+
saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
|
|
108
|
+
runs the receive-only preflight: if it reports spend methods such as
|
|
109
|
+
`pay_invoice`, remove `NWC_URI` from `.env` and ask for a receive-only code
|
|
110
|
+
again. Never set the spend-capable override to get past it.
|
|
111
|
+
|
|
112
|
+
### Upgrading an existing install
|
|
113
|
+
|
|
114
|
+
This is not the opening move of a new integration. When OpenReceive is ALREADY
|
|
115
|
+
installed here, `npx openreceive doctor` reports every credential as set/unset
|
|
116
|
+
(never the value) and probes the wallet. Check the installed
|
|
117
|
+
`@openreceive/node` and `@openreceive/browser` against the release named at the
|
|
118
|
+
top of this file: the headless display models below do not exist in older
|
|
119
|
+
versions, and the first tile click throws with nothing saying why. Upgrade
|
|
120
|
+
first.
|
|
93
121
|
|
|
94
122
|
Only then start the quickstart.
|
|
95
123
|
|
|
@@ -121,15 +149,19 @@ itself, and they hold for every integration.
|
|
|
121
149
|
late becomes `refund_required`, and the payer claims it on a SECOND VISIT,
|
|
122
150
|
after leaving your page to fetch an address from another wallet. Three things
|
|
123
151
|
must exist or that money is unreachable through your UI: a per-order URL your
|
|
124
|
-
server serves (`/checkout/:reference` — `syncUrl` on
|
|
125
|
-
|
|
152
|
+
server serves (`/checkout/:reference` — `syncUrl` on `<Checkout>`, `sync-url`
|
|
153
|
+
or `resumable` on `<openreceive-checkout>`), your own order-summary route to
|
|
154
|
+
restore the order from, and the ATTEMPT.
|
|
126
155
|
`/checkouts/prepare` returns no attempts, so a checkout rebuilt from the
|
|
127
156
|
reference alone opens on the method grid. Re-picking the same coin
|
|
128
157
|
(`POST /swaps`) re-serves the committed attempt — but only while it is live,
|
|
129
158
|
and the shadow invoice behind a swap lasts about half an hour, after which the
|
|
130
159
|
same click mints a NEW deposit address and the refund is off-screen. Keep the
|
|
131
160
|
`payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
|
|
132
|
-
such window.
|
|
161
|
+
such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
|
|
162
|
+
`<Checkout>`; the `resume-payment-hash` attribute, fed from the
|
|
163
|
+
`openreceive-state` event (`event.detail.state.payment_hash`), on
|
|
164
|
+
`<openreceive-checkout>`. https://openreceive.org/guides/swap-refunds.md
|
|
133
165
|
- Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
|
|
134
166
|
the price from `amountFor` and both drop-ins render it above the amount.
|
|
135
167
|
Without it the checkout is a QR and "$1.00" with no sign of what the dollar
|
|
@@ -303,11 +335,11 @@ Fastify + React. Requires Node ≥ 22.
|
|
|
303
335
|
npm install @openreceive/fastify @openreceive/react
|
|
304
336
|
```
|
|
305
337
|
|
|
306
|
-
Install the adapter for your server and the UI package for your frontend
|
|
338
|
+
Install the adapter for your server and the UI package for your frontend. The
|
|
307
339
|
wallet client, HTTP handler, and contracts come along as dependencies. The
|
|
308
|
-
`openreceive` package is the CLI
|
|
309
|
-
install.
|
|
310
|
-
|
|
340
|
+
`openreceive` package is only the CLI, and `npx openreceive …` below needs no
|
|
341
|
+
install. On a different stack, swap the two packages; the rest of this guide
|
|
342
|
+
stays the same.
|
|
311
343
|
|
|
312
344
|
| | Packages |
|
|
313
345
|
| -------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -317,15 +349,17 @@ identical.
|
|
|
317
349
|
Express: [quickstart-node.md](https://openreceive.org/guides/quickstart-node.md) · Next.js:
|
|
318
350
|
[quickstart-next.md](https://openreceive.org/guides/quickstart-next.md). This page is the Fastify one.
|
|
319
351
|
|
|
320
|
-
On a fresh project, also install what this guide assumes
|
|
352
|
+
On a fresh project, also install what this guide assumes you already have: the
|
|
321
353
|
framework, a static-file plugin for the checkout page, and an env loader
|
|
322
|
-
(`npm install fastify @fastify/static dotenv`)
|
|
323
|
-
(`npm install prisma @prisma/client` on the Prisma path)
|
|
324
|
-
`openreceive scaffold` emits files for the ORM you name but never installs
|
|
354
|
+
(`npm install fastify @fastify/static dotenv`). Install your ORM before step 2
|
|
355
|
+
too (`npm install prisma @prisma/client` on the Prisma path).
|
|
356
|
+
`openreceive scaffold` emits files for the ORM you name, but it never installs
|
|
357
|
+
that ORM.
|
|
325
358
|
|
|
326
|
-
|
|
327
|
-
Prisma's engine download and esbuild's binary postinstall
|
|
328
|
-
build
|
|
359
|
+
Some editor sandboxes run npm with `ignore-scripts`. That setting skips
|
|
360
|
+
Prisma's engine download and esbuild's binary postinstall. If a typecheck or
|
|
361
|
+
build fails only in such an environment, the environment is the cause, not
|
|
362
|
+
your code.
|
|
329
363
|
|
|
330
364
|
### 2. Migrate the payment tables
|
|
331
365
|
|
|
@@ -333,19 +367,21 @@ build that fails only there is environmental, not a code problem.
|
|
|
333
367
|
npx openreceive scaffold payments --orm prisma # or drizzle | typeorm | sequelize | knex
|
|
334
368
|
```
|
|
335
369
|
|
|
336
|
-
`openreceive scaffold payments`
|
|
337
|
-
|
|
370
|
+
`openreceive scaffold payments` writes one schema or migration file for your
|
|
371
|
+
ORM, plus a wiring guide. It never touches a database.
|
|
338
372
|
→ [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments)
|
|
339
373
|
|
|
340
|
-
Then run the
|
|
341
|
-
`npx prisma migrate dev`). OpenReceive
|
|
342
|
-
is nothing else to generate. Details:
|
|
374
|
+
Then run the generated migration the way you normally do (for example
|
|
375
|
+
`npx prisma migrate dev`). OpenReceive runs the tables' logic at runtime, so
|
|
376
|
+
there is nothing else to generate. Details:
|
|
343
377
|
[Payment storage](https://openreceive.org/guides/storage.md), [Node ORM recipes](https://openreceive.org/guides/node-orms.md).
|
|
344
378
|
|
|
345
|
-
No ORM?
|
|
346
|
-
|
|
347
|
-
same DDL once yourself
|
|
348
|
-
`@openreceive/http
|
|
379
|
+
No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
|
|
380
|
+
`better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
|
|
381
|
+
Instead of scaffolding, run the same DDL once yourself, using
|
|
382
|
+
`paymentsSchemaSql(dialect)` from `@openreceive/http`. Your adapter already
|
|
383
|
+
pulls that package in, but this import is yours, so install it too:
|
|
384
|
+
`npm install @openreceive/http`.
|
|
349
385
|
|
|
350
386
|
### 3. Add wallet credentials
|
|
351
387
|
|
|
@@ -358,28 +394,33 @@ LSC_URI_BACKUP=
|
|
|
358
394
|
```
|
|
359
395
|
|
|
360
396
|
1. Get a receive-only NWC code from a compatible wallet
|
|
361
|
-
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
|
|
362
|
-
|
|
363
|
-
2.
|
|
364
|
-
|
|
397
|
+
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
|
|
398
|
+
Put it in `NWC_URI`.
|
|
399
|
+
2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
|
|
400
|
+
Put its connection string in `LSC_URI_PRIMARY`, and a second one in
|
|
401
|
+
`LSC_URI_BACKUP` if you have one.
|
|
365
402
|
|
|
366
|
-
Never put these values in browser code. Your
|
|
367
|
-
|
|
368
|
-
receive-only code ([Security](https://openreceive.org/guides/security.md)).
|
|
403
|
+
Never put these values in browser code. Your app refuses to start if the NWC
|
|
404
|
+
code also advertises spend methods such as `pay_invoice`. Create a
|
|
405
|
+
receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
|
|
369
406
|
|
|
370
|
-
OpenReceive reads `process.env
|
|
371
|
-
own.
|
|
372
|
-
|
|
373
|
-
|
|
407
|
+
OpenReceive reads `process.env`, so creating a `.env` file is not enough on
|
|
408
|
+
its own. [Environment variables](https://openreceive.org/guides/environment-variables.md) explains how that
|
|
409
|
+
file or your production secrets get into the process: `dotenv` on
|
|
410
|
+
Express/Fastify, auto-load on Next.js, and secret managers in production.
|
|
374
411
|
|
|
375
412
|
### 4. Wire OpenReceive
|
|
376
413
|
|
|
377
|
-
One plugin
|
|
378
|
-
client and the host
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
414
|
+
One plugin takes your hooks and a database handle. The plugin builds the
|
|
415
|
+
wallet client and the host. There is no background reconciler, meaning no job that checks pending
|
|
416
|
+
payments on a timer. Settlement runs during normal requests instead, through
|
|
417
|
+
the durable reconcile gate.
|
|
418
|
+
|
|
419
|
+
Two things are specific to Fastify:
|
|
420
|
+
|
|
421
|
+
- You pass the mount prefix **at `register()`**, so Fastify scopes the
|
|
422
|
+
plugin's routes to it.
|
|
423
|
+
- You add no body parser, because Fastify parses JSON itself.
|
|
383
424
|
|
|
384
425
|
```ts
|
|
385
426
|
import "dotenv/config"; // loads .env into process.env; nothing else does
|
|
@@ -448,11 +489,11 @@ await app.register(openReceiveFastify, {
|
|
|
448
489
|
});
|
|
449
490
|
```
|
|
450
491
|
|
|
451
|
-
Register the plugin after
|
|
452
|
-
decorations,
|
|
453
|
-
|
|
454
|
-
client with the app, so
|
|
455
|
-
health check awaits `fastify.ready()` instead.
|
|
492
|
+
Register the plugin after whichever plugin gives you sessions or auth
|
|
493
|
+
decorations, because `authorize` sees the same request object. The plugin
|
|
494
|
+
handles shutdown for you. It registers an `onClose` hook that closes the
|
|
495
|
+
wallet client together with the app, so you have no `ready`/`close` pair to
|
|
496
|
+
manage. A deploy health check awaits `fastify.ready()` instead.
|
|
456
497
|
|
|
457
498
|
The first request checks the wallet. Later OpenReceive requests also settle
|
|
458
499
|
pending invoices, so a payer who closes the tab is still covered.
|
|
@@ -467,25 +508,34 @@ An optional worker, `startNotificationWorker({ service, host })`, listens for
|
|
|
467
508
|
wallet payment notifications so settlement does not wait for the next page
|
|
468
509
|
load. → [startNotificationWorker](https://openreceive.org/guides/api-reference.md#startnotificationworker)
|
|
469
510
|
|
|
470
|
-
|
|
471
|
-
|
|
511
|
+
You can also compose the pieces yourself (`createOpenReceive` + `createHost`)
|
|
512
|
+
when you need a shared wallet client or a custom repository.
|
|
472
513
|
→ [createOpenReceive](https://openreceive.org/guides/api-reference.md#createopenreceive) ·
|
|
473
514
|
[createHost](https://openreceive.org/guides/api-reference.md#createhost)
|
|
474
515
|
|
|
475
|
-
Your app also needs an ordinary
|
|
476
|
-
|
|
477
|
-
the `reference`. OpenReceive never
|
|
516
|
+
Your app also needs an ordinary route that creates the order. It validates the
|
|
517
|
+
cart, computes the price with exact decimal math, and returns the order id.
|
|
518
|
+
The page passes that id as the `reference`. OpenReceive never takes a price
|
|
519
|
+
from payer input.
|
|
520
|
+
|
|
521
|
+
The `reference` is a string you choose, and it identifies what gets fulfilled.
|
|
522
|
+
Use your order id. Make it:
|
|
478
523
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
across retries,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
524
|
+
- one per thing you fulfill,
|
|
525
|
+
- created before checkout,
|
|
526
|
+
- kept across retries,
|
|
527
|
+
- never reused.
|
|
528
|
+
|
|
529
|
+
OpenReceive never looks inside the `reference`, but it relies on it:
|
|
530
|
+
|
|
531
|
+
- `onPaid` commits fulfillment once per reference.
|
|
532
|
+
- A new checkout under a reference that already settled is refused with 409.
|
|
533
|
+
- A fresh id on every page load would let one order be paid twice.
|
|
485
534
|
|
|
486
535
|
Naming boundary: TypeScript APIs use camelCase fields (`paymentHash`,
|
|
487
|
-
`amountMsats`)
|
|
488
|
-
|
|
536
|
+
`amountMsats`). Everything on the wire is snake_case (`payment_hash`,
|
|
537
|
+
`amount_msats`). The wire means the mounted HTTP routes and the browser
|
|
538
|
+
snapshots.
|
|
489
539
|
|
|
490
540
|
### 5. Render checkout
|
|
491
541
|
|
|
@@ -496,46 +546,52 @@ import "@openreceive/react/styles.css";
|
|
|
496
546
|
<Checkout reference={order.id} prefix="/openreceive" />;
|
|
497
547
|
```
|
|
498
548
|
|
|
499
|
-
The checkout renders, polls, and settles itself.
|
|
500
|
-
|
|
501
|
-
|
|
549
|
+
The checkout renders, polls, and settles itself.
|
|
550
|
+
|
|
551
|
+
`@openreceive/react` and `@openreceive/elements` each ship a compiled
|
|
552
|
+
`styles.css`. Each sheet is self-contained, so a plain
|
|
553
|
+
`<link rel="stylesheet">` works with no build step. Each is also scoped: every
|
|
502
554
|
rule applies only inside what OpenReceive renders.
|
|
503
555
|
|
|
504
|
-
Serve the compiled `styles.css` without Tailwind processing
|
|
505
|
-
JavaScript
|
|
506
|
-
Do not `@import` it into
|
|
507
|
-
|
|
556
|
+
Serve the compiled `styles.css` without Tailwind processing. Import it from
|
|
557
|
+
JavaScript if your bundler handles CSS, or use a plain
|
|
558
|
+
`<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
|
|
559
|
+
Its rules have zero specificity, so your page's styles can override checkout
|
|
560
|
+
styles. Scoping does not prevent that.
|
|
508
561
|
|
|
509
|
-
`<Checkout>` is complete as rendered
|
|
562
|
+
`<Checkout>` is complete as rendered. It already shows the `description` from
|
|
510
563
|
`amountFor` and the collapsed transaction-details panel. Do not build a custom
|
|
511
|
-
UI to
|
|
512
|
-
drop-in ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
|
|
564
|
+
UI to show them. The display rules for them become your job only if you
|
|
565
|
+
replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
|
|
513
566
|
|
|
514
|
-
Match the host page's theme
|
|
515
|
-
stored choice, then the system scheme. If this page
|
|
516
|
-
it
|
|
517
|
-
|
|
518
|
-
variables under `data-theme
|
|
519
|
-
the
|
|
567
|
+
Match the host page's theme. By default the checkout follows the payer's
|
|
568
|
+
stored choice, then the system color scheme. If this page always uses one
|
|
569
|
+
theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
|
|
570
|
+
the `theme` attribute. Locking the theme keeps a white card off a dark page.
|
|
571
|
+
CSS variables under `data-theme` style the checkout.
|
|
572
|
+
[Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
|
|
520
573
|
|
|
521
574
|
Everything the checkout draws ships inside the JavaScript: the payment-method
|
|
522
|
-
icons, the wallet logos and the pay tutorials. There is no image file to copy
|
|
523
|
-
or serve and no asset option to set. Deploy your normal JavaScript and CSS
|
|
575
|
+
icons, the wallet logos, and the pay tutorials. There is no image file to copy
|
|
576
|
+
or serve, and no asset option to set. Deploy your normal JavaScript and CSS
|
|
524
577
|
build output, including any generated JavaScript chunks. Bundlers with code
|
|
525
|
-
splitting can
|
|
526
|
-
|
|
527
|
-
Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
578
|
+
splitting can wait to load tutorial screenshots until a tutorial first opens.
|
|
579
|
+
Single-file builds, including the standalone checkout, include them from the
|
|
580
|
+
start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
528
581
|
([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
|
|
529
582
|
|
|
530
|
-
That is the whole loop
|
|
531
|
-
an invoice
|
|
583
|
+
That is the whole loop. Your server owns the price and the order. The payer
|
|
584
|
+
gets an invoice. `onPaid` runs inside the settlement transaction. If that
|
|
585
|
+
transaction rolls back, the callback may run again. For delivery to outside
|
|
586
|
+
systems, use an outbox in your app: record the message in the transaction and
|
|
587
|
+
send it after commit.
|
|
532
588
|
|
|
533
|
-
|
|
534
|
-
is Buy a Button
|
|
589
|
+
Buy a Button is a runnable illustration of this boundary
|
|
535
590
|
(`examples/buttons/server/fastify`).
|
|
536
|
-
It
|
|
537
|
-
and
|
|
538
|
-
|
|
591
|
+
It is not a template to copy models from. It has products, visitors, and
|
|
592
|
+
orders, and the three hooks are the only bridge to OpenReceive. Its host is
|
|
593
|
+
the smallest correct Fastify integration of the packaged checkout. Map that
|
|
594
|
+
shape onto the models in THIS app.
|
|
539
595
|
|
|
540
596
|
### 6. Verify
|
|
541
597
|
|
|
@@ -543,16 +599,17 @@ checkout. Map that shape onto the models in THIS app.
|
|
|
543
599
|
npx openreceive doctor
|
|
544
600
|
```
|
|
545
601
|
|
|
546
|
-
`openreceive doctor` checks Node, `NWC_URI`, and swap-provider
|
|
547
|
-
|
|
548
|
-
`--db <file-or-url>` to confirm the migration ran
|
|
549
|
-
`--url http://localhost:3000` to confirm the routes are mounted
|
|
602
|
+
`openreceive doctor` checks Node, `NWC_URI`, and the swap-provider
|
|
603
|
+
configuration. It also probes the wallet relay to confirm the code is
|
|
604
|
+
receive-only. Add `--db <file-or-url>` to confirm the migration ran. Add
|
|
605
|
+
`--url http://localhost:3000` to confirm the routes are mounted. Every failing
|
|
550
606
|
line states its own fix.
|
|
551
607
|
→ [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor)
|
|
552
608
|
|
|
553
|
-
Then open the checkout in a browser
|
|
554
|
-
wallet logos render
|
|
555
|
-
If an image is missing,
|
|
556
|
-
panel for failed JavaScript chunks.
|
|
557
|
-
complete build output. Do not add image routes
|
|
558
|
-
use registry `icon_path`
|
|
609
|
+
Then open the checkout in a browser. Confirm the payment-method icons and
|
|
610
|
+
wallet logos render. Open a wallet's pay tutorial to check its screenshots.
|
|
611
|
+
If an image is missing, look in the console for CSP violations and in the
|
|
612
|
+
Network panel for failed JavaScript chunks. To fix it, allow `data:` in
|
|
613
|
+
`img-src` and deploy the complete build output. Do not add image routes or
|
|
614
|
+
copy package source images. Do not use registry `icon_path` or tutorial
|
|
615
|
+
`path` keys as browser URLs.
|