openreceive-rails 0.4.10 → 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 +33 -0
- data/README.md +33 -0
- data/app/models/open_receive_meta.rb +49 -28
- data/app/models/open_receive_payment.rb +107 -13
- data/lib/generators/openreceive/install/templates/initializer.rb +1 -1
- data/lib/openreceive/configuration.rb +3 -1
- data/lib/openreceive/generated/fulfillment_note.rb +17 -8
- data/lib/openreceive/rails/version.rb +1 -1
- data/lib/openreceive/reconcile.rb +108 -64
- data/lib/openreceive/reconcile_scan.rb +106 -0
- data/skills/debug-openreceive-payment/SKILL.md +1 -1
- data/skills/integrate-openreceive/SKILL.md +4 -3
- data/skills/integrate-openreceive/references/btcpay.md +67 -36
- data/skills/integrate-openreceive/references/django.md +291 -244
- data/skills/integrate-openreceive/references/fastapi.md +206 -155
- data/skills/integrate-openreceive/references/fastify.md +200 -147
- data/skills/integrate-openreceive/references/laravel.md +294 -234
- data/skills/integrate-openreceive/references/next.md +210 -162
- data/skills/integrate-openreceive/references/node.md +188 -138
- data/skills/integrate-openreceive/references/php.md +248 -193
- data/skills/integrate-openreceive/references/rails.md +262 -218
- data/skills/integrate-openreceive/references/woocommerce.md +68 -51
- metadata +6 -5
|
@@ -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.13.
|
|
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
|
|
|
@@ -107,7 +135,7 @@ itself, and they hold for every integration.
|
|
|
107
135
|
payer-supplied amounts.
|
|
108
136
|
- `authorize` runs on every request, and the `resource` it receives is a CLAIM
|
|
109
137
|
the payer made, not proof. Read a framework session; never trust a body field.
|
|
110
|
-
- `onPaid` must be idempotent.
|
|
138
|
+
- `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
|
|
111
139
|
per thing you fulfill, created before checkout, kept across retries, never
|
|
112
140
|
reused. A fresh id per page load lets one order be paid twice.
|
|
113
141
|
- Receive-only NWC is required; a spend-capable code fails closed at boot unless
|
|
@@ -284,6 +312,8 @@ enough; drop the `.md` for the same page a person would read.
|
|
|
284
312
|
Questions, or a problem with the library itself:
|
|
285
313
|
https://openreceive.org/contact
|
|
286
314
|
|
|
315
|
+
- https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
|
|
316
|
+
|
|
287
317
|
---
|
|
288
318
|
|
|
289
319
|
## The quickstart, in full
|
|
@@ -301,11 +331,11 @@ Fastify + React. Requires Node ≥ 22.
|
|
|
301
331
|
npm install @openreceive/fastify @openreceive/react
|
|
302
332
|
```
|
|
303
333
|
|
|
304
|
-
Install the adapter for your server and the UI package for your frontend
|
|
334
|
+
Install the adapter for your server and the UI package for your frontend. The
|
|
305
335
|
wallet client, HTTP handler, and contracts come along as dependencies. The
|
|
306
|
-
`openreceive` package is the CLI
|
|
307
|
-
install.
|
|
308
|
-
|
|
336
|
+
`openreceive` package is only the CLI, and `npx openreceive …` below needs no
|
|
337
|
+
install. On a different stack, swap the two packages; the rest of this guide
|
|
338
|
+
stays the same.
|
|
309
339
|
|
|
310
340
|
| | Packages |
|
|
311
341
|
| -------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -315,15 +345,17 @@ identical.
|
|
|
315
345
|
Express: [quickstart-node.md](https://openreceive.org/guides/quickstart-node.md) · Next.js:
|
|
316
346
|
[quickstart-next.md](https://openreceive.org/guides/quickstart-next.md). This page is the Fastify one.
|
|
317
347
|
|
|
318
|
-
On a fresh project, also install what this guide assumes
|
|
348
|
+
On a fresh project, also install what this guide assumes you already have: the
|
|
319
349
|
framework, a static-file plugin for the checkout page, and an env loader
|
|
320
|
-
(`npm install fastify @fastify/static dotenv`)
|
|
321
|
-
(`npm install prisma @prisma/client` on the Prisma path)
|
|
322
|
-
`openreceive scaffold` emits files for the ORM you name but never installs
|
|
350
|
+
(`npm install fastify @fastify/static dotenv`). Install your ORM before step 2
|
|
351
|
+
too (`npm install prisma @prisma/client` on the Prisma path).
|
|
352
|
+
`openreceive scaffold` emits files for the ORM you name, but it never installs
|
|
353
|
+
that ORM.
|
|
323
354
|
|
|
324
|
-
|
|
325
|
-
Prisma's engine download and esbuild's binary postinstall
|
|
326
|
-
build
|
|
355
|
+
Some editor sandboxes run npm with `ignore-scripts`. That setting skips
|
|
356
|
+
Prisma's engine download and esbuild's binary postinstall. If a typecheck or
|
|
357
|
+
build fails only in such an environment, the environment is the cause, not
|
|
358
|
+
your code.
|
|
327
359
|
|
|
328
360
|
### 2. Migrate the payment tables
|
|
329
361
|
|
|
@@ -331,19 +363,19 @@ build that fails only there is environmental, not a code problem.
|
|
|
331
363
|
npx openreceive scaffold payments --orm prisma # or drizzle | typeorm | sequelize | knex
|
|
332
364
|
```
|
|
333
365
|
|
|
334
|
-
`openreceive scaffold payments`
|
|
335
|
-
|
|
366
|
+
`openreceive scaffold payments` writes one schema or migration file for your
|
|
367
|
+
ORM, plus a wiring guide. It never touches a database.
|
|
336
368
|
→ [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments)
|
|
337
369
|
|
|
338
|
-
Then run the
|
|
339
|
-
`npx prisma migrate dev`). OpenReceive
|
|
340
|
-
is nothing else to generate. Details:
|
|
370
|
+
Then run the generated migration the way you normally do (for example
|
|
371
|
+
`npx prisma migrate dev`). OpenReceive runs the tables' logic at runtime, so
|
|
372
|
+
there is nothing else to generate. Details:
|
|
341
373
|
[Payment storage](https://openreceive.org/guides/storage.md), [Node ORM recipes](https://openreceive.org/guides/node-orms.md).
|
|
342
374
|
|
|
343
|
-
No ORM?
|
|
344
|
-
|
|
345
|
-
same DDL once yourself
|
|
346
|
-
`@openreceive/http
|
|
375
|
+
No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
|
|
376
|
+
`better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
|
|
377
|
+
Instead of scaffolding, run the same DDL once yourself, using
|
|
378
|
+
`paymentsSchemaSql(dialect)` from `@openreceive/http`.
|
|
347
379
|
|
|
348
380
|
### 3. Add wallet credentials
|
|
349
381
|
|
|
@@ -356,28 +388,33 @@ LSC_URI_BACKUP=
|
|
|
356
388
|
```
|
|
357
389
|
|
|
358
390
|
1. Get a receive-only NWC code from a compatible wallet
|
|
359
|
-
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
|
|
360
|
-
|
|
361
|
-
2.
|
|
362
|
-
|
|
391
|
+
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
|
|
392
|
+
Put it in `NWC_URI`.
|
|
393
|
+
2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
|
|
394
|
+
Put its connection string in `LSC_URI_PRIMARY`, and a second one in
|
|
395
|
+
`LSC_URI_BACKUP` if you have one.
|
|
363
396
|
|
|
364
|
-
Never put these values in browser code. Your
|
|
365
|
-
|
|
366
|
-
receive-only code ([Security](https://openreceive.org/guides/security.md)).
|
|
397
|
+
Never put these values in browser code. Your app refuses to start if the NWC
|
|
398
|
+
code also advertises spend methods such as `pay_invoice`. Create a
|
|
399
|
+
receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
|
|
367
400
|
|
|
368
|
-
OpenReceive reads `process.env
|
|
369
|
-
own.
|
|
370
|
-
|
|
371
|
-
|
|
401
|
+
OpenReceive reads `process.env`, so creating a `.env` file is not enough on
|
|
402
|
+
its own. [Environment variables](https://openreceive.org/guides/environment-variables.md) explains how that
|
|
403
|
+
file or your production secrets get into the process: `dotenv` on
|
|
404
|
+
Express/Fastify, auto-load on Next.js, and secret managers in production.
|
|
372
405
|
|
|
373
406
|
### 4. Wire OpenReceive
|
|
374
407
|
|
|
375
|
-
One plugin
|
|
376
|
-
client and the host
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
408
|
+
One plugin takes your hooks and a database handle. The plugin builds the
|
|
409
|
+
wallet client and the host. There is no background reconciler, meaning no job that checks pending
|
|
410
|
+
payments on a timer. Settlement runs during normal requests instead, through
|
|
411
|
+
the durable reconcile gate.
|
|
412
|
+
|
|
413
|
+
Two things are specific to Fastify:
|
|
414
|
+
|
|
415
|
+
- You pass the mount prefix **at `register()`**, so Fastify scopes the
|
|
416
|
+
plugin's routes to it.
|
|
417
|
+
- You add no body parser, because Fastify parses JSON itself.
|
|
381
418
|
|
|
382
419
|
```ts
|
|
383
420
|
import "dotenv/config"; // loads .env into process.env; nothing else does
|
|
@@ -446,11 +483,11 @@ await app.register(openReceiveFastify, {
|
|
|
446
483
|
});
|
|
447
484
|
```
|
|
448
485
|
|
|
449
|
-
Register the plugin after
|
|
450
|
-
decorations,
|
|
451
|
-
|
|
452
|
-
client with the app, so
|
|
453
|
-
health check awaits `fastify.ready()` instead.
|
|
486
|
+
Register the plugin after whichever plugin gives you sessions or auth
|
|
487
|
+
decorations, because `authorize` sees the same request object. The plugin
|
|
488
|
+
handles shutdown for you. It registers an `onClose` hook that closes the
|
|
489
|
+
wallet client together with the app, so you have no `ready`/`close` pair to
|
|
490
|
+
manage. A deploy health check awaits `fastify.ready()` instead.
|
|
454
491
|
|
|
455
492
|
The first request checks the wallet. Later OpenReceive requests also settle
|
|
456
493
|
pending invoices, so a payer who closes the tab is still covered.
|
|
@@ -465,25 +502,34 @@ An optional worker, `startNotificationWorker({ service, host })`, listens for
|
|
|
465
502
|
wallet payment notifications so settlement does not wait for the next page
|
|
466
503
|
load. → [startNotificationWorker](https://openreceive.org/guides/api-reference.md#startnotificationworker)
|
|
467
504
|
|
|
468
|
-
|
|
469
|
-
|
|
505
|
+
You can also compose the pieces yourself (`createOpenReceive` + `createHost`)
|
|
506
|
+
when you need a shared wallet client or a custom repository.
|
|
470
507
|
→ [createOpenReceive](https://openreceive.org/guides/api-reference.md#createopenreceive) ·
|
|
471
508
|
[createHost](https://openreceive.org/guides/api-reference.md#createhost)
|
|
472
509
|
|
|
473
|
-
Your app also needs an ordinary
|
|
474
|
-
|
|
475
|
-
the `reference`. OpenReceive never
|
|
510
|
+
Your app also needs an ordinary route that creates the order. It validates the
|
|
511
|
+
cart, computes the price with exact decimal math, and returns the order id.
|
|
512
|
+
The page passes that id as the `reference`. OpenReceive never takes a price
|
|
513
|
+
from payer input.
|
|
514
|
+
|
|
515
|
+
The `reference` is a string you choose, and it identifies what gets fulfilled.
|
|
516
|
+
Use your order id. Make it:
|
|
476
517
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
across retries,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
518
|
+
- one per thing you fulfill,
|
|
519
|
+
- created before checkout,
|
|
520
|
+
- kept across retries,
|
|
521
|
+
- never reused.
|
|
522
|
+
|
|
523
|
+
OpenReceive never looks inside the `reference`, but it relies on it:
|
|
524
|
+
|
|
525
|
+
- `onPaid` commits fulfillment once per reference.
|
|
526
|
+
- A new checkout under a reference that already settled is refused with 409.
|
|
527
|
+
- A fresh id on every page load would let one order be paid twice.
|
|
483
528
|
|
|
484
529
|
Naming boundary: TypeScript APIs use camelCase fields (`paymentHash`,
|
|
485
|
-
`amountMsats`)
|
|
486
|
-
|
|
530
|
+
`amountMsats`). Everything on the wire is snake_case (`payment_hash`,
|
|
531
|
+
`amount_msats`). The wire means the mounted HTTP routes and the browser
|
|
532
|
+
snapshots.
|
|
487
533
|
|
|
488
534
|
### 5. Render checkout
|
|
489
535
|
|
|
@@ -494,46 +540,52 @@ import "@openreceive/react/styles.css";
|
|
|
494
540
|
<Checkout reference={order.id} prefix="/openreceive" />;
|
|
495
541
|
```
|
|
496
542
|
|
|
497
|
-
The checkout renders, polls, and settles itself.
|
|
498
|
-
|
|
499
|
-
|
|
543
|
+
The checkout renders, polls, and settles itself.
|
|
544
|
+
|
|
545
|
+
`@openreceive/react` and `@openreceive/elements` each ship a compiled
|
|
546
|
+
`styles.css`. Each sheet is self-contained, so a plain
|
|
547
|
+
`<link rel="stylesheet">` works with no build step. Each is also scoped: every
|
|
500
548
|
rule applies only inside what OpenReceive renders.
|
|
501
549
|
|
|
502
|
-
Serve the compiled `styles.css` without Tailwind processing
|
|
503
|
-
JavaScript
|
|
504
|
-
Do not `@import` it into
|
|
505
|
-
|
|
550
|
+
Serve the compiled `styles.css` without Tailwind processing. Import it from
|
|
551
|
+
JavaScript if your bundler handles CSS, or use a plain
|
|
552
|
+
`<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
|
|
553
|
+
Its rules have zero specificity, so your page's styles can override checkout
|
|
554
|
+
styles. Scoping does not prevent that.
|
|
506
555
|
|
|
507
|
-
`<Checkout>` is complete as rendered
|
|
556
|
+
`<Checkout>` is complete as rendered. It already shows the `description` from
|
|
508
557
|
`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)).
|
|
558
|
+
UI to show them. The display rules for them become your job only if you
|
|
559
|
+
replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
|
|
511
560
|
|
|
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
|
|
561
|
+
Match the host page's theme. By default the checkout follows the payer's
|
|
562
|
+
stored choice, then the system color scheme. If this page always uses one
|
|
563
|
+
theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
|
|
564
|
+
the `theme` attribute. Locking the theme keeps a white card off a dark page.
|
|
565
|
+
CSS variables under `data-theme` style the checkout.
|
|
566
|
+
[Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
|
|
518
567
|
|
|
519
568
|
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
|
|
569
|
+
icons, the wallet logos, and the pay tutorials. There is no image file to copy
|
|
570
|
+
or serve, and no asset option to set. Deploy your normal JavaScript and CSS
|
|
522
571
|
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:`
|
|
572
|
+
splitting can wait to load tutorial screenshots until a tutorial first opens.
|
|
573
|
+
Single-file builds, including the standalone checkout, include them from the
|
|
574
|
+
start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
526
575
|
([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
|
|
527
576
|
|
|
528
|
-
That is the whole loop
|
|
529
|
-
an invoice
|
|
577
|
+
That is the whole loop. Your server owns the price and the order. The payer
|
|
578
|
+
gets an invoice. `onPaid` runs inside the settlement transaction. If that
|
|
579
|
+
transaction rolls back, the callback may run again. For delivery to outside
|
|
580
|
+
systems, use an outbox in your app: record the message in the transaction and
|
|
581
|
+
send it after commit.
|
|
530
582
|
|
|
531
|
-
|
|
532
|
-
is Buy a Button
|
|
583
|
+
Buy a Button is a runnable illustration of this boundary
|
|
533
584
|
(`examples/buttons/server/fastify`).
|
|
534
|
-
It
|
|
535
|
-
and
|
|
536
|
-
|
|
585
|
+
It is not a template to copy models from. It has products, visitors, and
|
|
586
|
+
orders, and the three hooks are the only bridge to OpenReceive. Its host is
|
|
587
|
+
the smallest correct Fastify integration of the packaged checkout. Map that
|
|
588
|
+
shape onto the models in THIS app.
|
|
537
589
|
|
|
538
590
|
### 6. Verify
|
|
539
591
|
|
|
@@ -541,16 +593,17 @@ checkout. Map that shape onto the models in THIS app.
|
|
|
541
593
|
npx openreceive doctor
|
|
542
594
|
```
|
|
543
595
|
|
|
544
|
-
`openreceive doctor` checks Node, `NWC_URI`, and swap-provider
|
|
545
|
-
|
|
546
|
-
`--db <file-or-url>` to confirm the migration ran
|
|
547
|
-
`--url http://localhost:3000` to confirm the routes are mounted
|
|
596
|
+
`openreceive doctor` checks Node, `NWC_URI`, and the swap-provider
|
|
597
|
+
configuration. It also probes the wallet relay to confirm the code is
|
|
598
|
+
receive-only. Add `--db <file-or-url>` to confirm the migration ran. Add
|
|
599
|
+
`--url http://localhost:3000` to confirm the routes are mounted. Every failing
|
|
548
600
|
line states its own fix.
|
|
549
601
|
→ [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor)
|
|
550
602
|
|
|
551
|
-
Then open the checkout in a browser
|
|
552
|
-
wallet logos render
|
|
553
|
-
If an image is missing,
|
|
554
|
-
panel for failed JavaScript chunks.
|
|
555
|
-
complete build output. Do not add image routes
|
|
556
|
-
use registry `icon_path`
|
|
603
|
+
Then open the checkout in a browser. Confirm the payment-method icons and
|
|
604
|
+
wallet logos render. Open a wallet's pay tutorial to check its screenshots.
|
|
605
|
+
If an image is missing, look in the console for CSP violations and in the
|
|
606
|
+
Network panel for failed JavaScript chunks. To fix it, allow `data:` in
|
|
607
|
+
`img-src` and deploy the complete build output. Do not add image routes or
|
|
608
|
+
copy package source images. Do not use registry `icon_path` or tutorial
|
|
609
|
+
`path` keys as browser URLs.
|