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 (Node.js)
|
|
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 Node application — the app you are already working in. You
|
|
6
6
|
do not need a copy of the OpenReceive source: the packages are on npm, and the
|
|
@@ -31,62 +31,90 @@ The one required credential is a receive-only NWC code (Nostr Wallet Connect):
|
|
|
31
31
|
a string from the merchant's wallet that can create invoices and read their
|
|
32
32
|
status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
|
|
33
33
|
payer send USDT, USDC, ETH or SOL instead, converted into that same
|
|
34
|
-
Lightning payment.
|
|
34
|
+
Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`, `amountFor`,
|
|
35
35
|
`onPaid`;
|
|
36
36
|
OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
|
|
37
37
|
owns orders, users, prices, or fulfillment.
|
|
38
38
|
|
|
39
|
-
## Step 0 —
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
39
|
+
## Step 0 — ask for the two codes, one question at a time
|
|
40
|
+
|
|
41
|
+
Before anything else, look at one file: the project's `.env`, if it exists.
|
|
42
|
+
Read it only far enough to see whether `NWC_URI` and `LSC_URI_PRIMARY` are
|
|
43
|
+
there and non-empty, and never print the values. A code that is already
|
|
44
|
+
set is not asked for again; if both are set, skip to step 5
|
|
45
|
+
(making the server load the file), then the quickstart.
|
|
46
|
+
|
|
47
|
+
Otherwise your next action is a question to the user. Do not install packages,
|
|
48
|
+
edit the app, write `.env.example`, or search anywhere else before asking
|
|
49
|
+
it. Do not read deploy config (compose files, platform secrets), Docker containers, or process environments, and never run
|
|
50
|
+
`printenv`. A new shop has neither code yet: hunting for one burns the turn and
|
|
51
|
+
can leak other secrets into the transcript.
|
|
52
|
+
|
|
53
|
+
Two server-only URIs are needed before the quickstart:
|
|
54
|
+
|
|
55
|
+
- `NWC_URI` — a receive-only Nostr Wallet Connect code,
|
|
56
|
+
`nostr+walletconnect://…`. Required for Bitcoin.
|
|
57
|
+
- `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
|
|
58
|
+
`lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
|
|
59
|
+
only when the user says they want Bitcoin alone.
|
|
60
|
+
|
|
61
|
+
The user never edits an environment file. They paste each code into the chat;
|
|
62
|
+
you store it. Ask one question per message.
|
|
63
|
+
|
|
64
|
+
1. **First message — the NWC code, and nothing else.** Ask for it and walk them
|
|
65
|
+
through getting it:
|
|
66
|
+
|
|
67
|
+
> To receive payments I need a receive-only wallet code. In Rizful: open
|
|
68
|
+
> the menu, tap NWC, choose Receive-only NWC code, and tap Copy
|
|
69
|
+
> (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
|
|
70
|
+
> rather run your own wallet, Alby Hub works too: Connections → Add
|
|
71
|
+
> Connection → Read Only. Paste the code here and I will store it.
|
|
72
|
+
|
|
73
|
+
Do not mention `.env`, exports, or "tell me when it's set".
|
|
74
|
+
2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
|
|
75
|
+
ask them to copy the receive-only code again. Otherwise write
|
|
76
|
+
`NWC_URI=<paste>` into the project's `.env`, creating the file if needed.
|
|
77
|
+
Make sure `.gitignore` covers `.env` (and `.dockerignore`, if the app has
|
|
78
|
+
one). Never echo the value, commit it, or put it in client code. Reply only
|
|
79
|
+
that it is saved, then ask the next question.
|
|
80
|
+
3. **Second message — swaps.** If the user already asked for stablecoins or
|
|
81
|
+
altcoins, skip the yes/no and go straight to the walkthrough. Otherwise ask
|
|
82
|
+
whether payers should also be able to pay with USDT, USDC, ETH or SOL. The
|
|
83
|
+
walkthrough:
|
|
84
|
+
|
|
85
|
+
> Go to https://lightning-swap.com, sign in for API keys, create a key, and
|
|
86
|
+
> copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
|
|
87
|
+
> it here and I will store it — or say "Bitcoin only" and I will continue
|
|
88
|
+
> without it.
|
|
89
|
+
|
|
90
|
+
Mention FixedFloat only if they already use it.
|
|
91
|
+
4. **When they paste it.** If it does not start with
|
|
92
|
+
`lightning+swapconnect://`, ask them to copy it again. Otherwise add
|
|
93
|
+
`LSC_URI_PRIMARY=<paste>` to the same `.env`, without echoing it. Swaps
|
|
94
|
+
are now on, so build the refund route back (the swap non-negotiable below) as
|
|
95
|
+
part of this integration. If they chose Bitcoin only, leave
|
|
96
|
+
`LSC_URI_PRIMARY` unset and skip that route.
|
|
97
|
+
5. **Make the server load the file — yourself.** OpenReceive reads
|
|
98
|
+
`process.env`, and a `.env` file on disk is not in it. Put
|
|
99
|
+
`import "dotenv/config";` at the top of the server entry, as the quickstart
|
|
100
|
+
does. When the app is started with Docker Compose, give the service
|
|
101
|
+
`env_file: .env`. Restart the server after writing the file.
|
|
102
|
+
|
|
103
|
+
Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
|
|
104
|
+
saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
|
|
105
|
+
runs the receive-only preflight: if it reports spend methods such as
|
|
106
|
+
`pay_invoice`, remove `NWC_URI` from `.env` and ask for a receive-only code
|
|
107
|
+
again. Never set the spend-capable override to get past it.
|
|
108
|
+
|
|
109
|
+
### Upgrading an existing install
|
|
110
|
+
|
|
111
|
+
This is not the opening move of a new integration. When OpenReceive is ALREADY
|
|
112
|
+
installed here, `npx openreceive doctor` reports every credential as set/unset
|
|
113
|
+
(never the value) and probes the wallet. Check the installed
|
|
114
|
+
`@openreceive/node` and `@openreceive/browser` against the release named at the
|
|
115
|
+
top of this file: the headless display models below do not exist in older
|
|
116
|
+
versions, and the first tile click throws with nothing saying why. Upgrade
|
|
117
|
+
first.
|
|
90
118
|
|
|
91
119
|
Only then start the quickstart.
|
|
92
120
|
|
|
@@ -104,7 +132,7 @@ itself, and they hold for every integration.
|
|
|
104
132
|
payer-supplied amounts.
|
|
105
133
|
- `authorize` runs on every request, and the `resource` it receives is a CLAIM
|
|
106
134
|
the payer made, not proof. Read a framework session; never trust a body field.
|
|
107
|
-
- `onPaid` must be idempotent.
|
|
135
|
+
- `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
|
|
108
136
|
per thing you fulfill, created before checkout, kept across retries, never
|
|
109
137
|
reused. A fresh id per page load lets one order be paid twice.
|
|
110
138
|
- Receive-only NWC is required; a spend-capable code fails closed at boot unless
|
|
@@ -276,6 +304,8 @@ enough; drop the `.md` for the same page a person would read.
|
|
|
276
304
|
Questions, or a problem with the library itself:
|
|
277
305
|
https://openreceive.org/contact
|
|
278
306
|
|
|
307
|
+
- https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
|
|
308
|
+
|
|
279
309
|
---
|
|
280
310
|
|
|
281
311
|
## The quickstart, in full
|
|
@@ -293,11 +323,11 @@ Express + React. Requires Node ≥ 22.
|
|
|
293
323
|
npm install @openreceive/express @openreceive/react
|
|
294
324
|
```
|
|
295
325
|
|
|
296
|
-
Install the adapter for your server and the UI package for your frontend
|
|
326
|
+
Install the adapter for your server and the UI package for your frontend. The
|
|
297
327
|
wallet client, HTTP handler, and contracts come along as dependencies. The
|
|
298
|
-
`openreceive` package is the CLI
|
|
299
|
-
install.
|
|
300
|
-
|
|
328
|
+
`openreceive` package is only the CLI, and `npx openreceive …` below needs no
|
|
329
|
+
install. On a different stack, swap the two packages; the rest of this guide
|
|
330
|
+
stays the same.
|
|
301
331
|
|
|
302
332
|
| | Packages |
|
|
303
333
|
| -------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -307,14 +337,16 @@ identical.
|
|
|
307
337
|
Fastify: [quickstart-fastify.md](https://openreceive.org/guides/quickstart-fastify.md) · Next.js:
|
|
308
338
|
[quickstart-next.md](https://openreceive.org/guides/quickstart-next.md). This page is the Express one.
|
|
309
339
|
|
|
310
|
-
On a fresh project, also install what this guide assumes
|
|
311
|
-
framework and an env loader (`npm install express dotenv`)
|
|
312
|
-
before step 2 (`npm install prisma @prisma/client` on the Prisma path)
|
|
313
|
-
`openreceive scaffold` emits files for the ORM you name but never installs
|
|
340
|
+
On a fresh project, also install what this guide assumes you already have: the
|
|
341
|
+
framework and an env loader (`npm install express dotenv`). Install your ORM
|
|
342
|
+
before step 2 too (`npm install prisma @prisma/client` on the Prisma path).
|
|
343
|
+
`openreceive scaffold` emits files for the ORM you name, but it never installs
|
|
344
|
+
that ORM.
|
|
314
345
|
|
|
315
|
-
|
|
316
|
-
Prisma's engine download and esbuild's binary postinstall
|
|
317
|
-
build
|
|
346
|
+
Some editor sandboxes run npm with `ignore-scripts`. That setting skips
|
|
347
|
+
Prisma's engine download and esbuild's binary postinstall. If a typecheck or
|
|
348
|
+
build fails only in such an environment, the environment is the cause, not
|
|
349
|
+
your code.
|
|
318
350
|
|
|
319
351
|
### 2. Migrate the payment tables
|
|
320
352
|
|
|
@@ -322,19 +354,19 @@ build that fails only there is environmental, not a code problem.
|
|
|
322
354
|
npx openreceive scaffold payments --orm prisma # or drizzle | typeorm | sequelize | knex
|
|
323
355
|
```
|
|
324
356
|
|
|
325
|
-
`openreceive scaffold payments`
|
|
326
|
-
|
|
357
|
+
`openreceive scaffold payments` writes one schema or migration file for your
|
|
358
|
+
ORM, plus a wiring guide. It never touches a database.
|
|
327
359
|
→ [openreceive scaffold payments](https://openreceive.org/guides/api-reference.md#openreceive-scaffold-payments)
|
|
328
360
|
|
|
329
|
-
Then run the
|
|
330
|
-
`npx prisma migrate dev`). OpenReceive
|
|
331
|
-
is nothing else to generate. Details:
|
|
361
|
+
Then run the generated migration the way you normally do (for example
|
|
362
|
+
`npx prisma migrate dev`). OpenReceive runs the tables' logic at runtime, so
|
|
363
|
+
there is nothing else to generate. Details:
|
|
332
364
|
[Payment storage](https://openreceive.org/guides/storage.md), [Node ORM recipes](https://openreceive.org/guides/node-orms.md).
|
|
333
365
|
|
|
334
|
-
No ORM?
|
|
335
|
-
|
|
336
|
-
same DDL once yourself
|
|
337
|
-
`@openreceive/http
|
|
366
|
+
No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
|
|
367
|
+
`better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
|
|
368
|
+
Instead of scaffolding, run the same DDL once yourself, using
|
|
369
|
+
`paymentsSchemaSql(dialect)` from `@openreceive/http`.
|
|
338
370
|
|
|
339
371
|
### 3. Add wallet credentials
|
|
340
372
|
|
|
@@ -347,25 +379,27 @@ LSC_URI_BACKUP=
|
|
|
347
379
|
```
|
|
348
380
|
|
|
349
381
|
1. Get a receive-only NWC code from a compatible wallet
|
|
350
|
-
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments))
|
|
351
|
-
|
|
352
|
-
2.
|
|
353
|
-
|
|
382
|
+
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
|
|
383
|
+
Put it in `NWC_URI`.
|
|
384
|
+
2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
|
|
385
|
+
Put its connection string in `LSC_URI_PRIMARY`, and a second one in
|
|
386
|
+
`LSC_URI_BACKUP` if you have one.
|
|
354
387
|
|
|
355
|
-
Never put these values in browser code. Your
|
|
356
|
-
|
|
357
|
-
receive-only code ([Security](https://openreceive.org/guides/security.md)).
|
|
388
|
+
Never put these values in browser code. Your app refuses to start if the NWC
|
|
389
|
+
code also advertises spend methods such as `pay_invoice`. Create a
|
|
390
|
+
receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
|
|
358
391
|
|
|
359
|
-
OpenReceive reads `process.env
|
|
360
|
-
own.
|
|
361
|
-
|
|
362
|
-
|
|
392
|
+
OpenReceive reads `process.env`, so creating a `.env` file is not enough on
|
|
393
|
+
its own. [Environment variables](https://openreceive.org/guides/environment-variables.md) explains how that
|
|
394
|
+
file or your production secrets get into the process: `dotenv` on
|
|
395
|
+
Express/Fastify, auto-load on Next.js, and secret managers in production.
|
|
363
396
|
|
|
364
397
|
### 4. Wire OpenReceive
|
|
365
398
|
|
|
366
|
-
One factory
|
|
367
|
-
wallet client and the host
|
|
368
|
-
|
|
399
|
+
One factory call takes your hooks and a database handle. The adapter builds
|
|
400
|
+
the wallet client and the host. There is no background reconciler, meaning no job that checks pending
|
|
401
|
+
payments on a timer. Settlement runs during normal requests instead, through
|
|
402
|
+
the durable reconcile gate.
|
|
369
403
|
|
|
370
404
|
```ts
|
|
371
405
|
import "dotenv/config"; // loads .env into process.env; nothing else does
|
|
@@ -442,25 +476,34 @@ An optional worker, `startNotificationWorker({ service, host })`, listens for
|
|
|
442
476
|
wallet payment notifications so settlement does not wait for the next page
|
|
443
477
|
load. → [startNotificationWorker](https://openreceive.org/guides/api-reference.md#startnotificationworker)
|
|
444
478
|
|
|
445
|
-
|
|
446
|
-
|
|
479
|
+
You can also compose the pieces yourself (`createOpenReceive` + `createHost`)
|
|
480
|
+
when you need a shared wallet client or a custom repository.
|
|
447
481
|
→ [createOpenReceive](https://openreceive.org/guides/api-reference.md#createopenreceive) ·
|
|
448
482
|
[createHost](https://openreceive.org/guides/api-reference.md#createhost)
|
|
449
483
|
|
|
450
|
-
Your app also needs an ordinary
|
|
451
|
-
|
|
452
|
-
the `reference`. OpenReceive never
|
|
484
|
+
Your app also needs an ordinary route that creates the order. It validates the
|
|
485
|
+
cart, computes the price with exact decimal math, and returns the order id.
|
|
486
|
+
The page passes that id as the `reference`. OpenReceive never takes a price
|
|
487
|
+
from payer input.
|
|
488
|
+
|
|
489
|
+
The `reference` is a string you choose, and it identifies what gets fulfilled.
|
|
490
|
+
Use your order id. Make it:
|
|
491
|
+
|
|
492
|
+
- one per thing you fulfill,
|
|
493
|
+
- created before checkout,
|
|
494
|
+
- kept across retries,
|
|
495
|
+
- never reused.
|
|
453
496
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
paid twice.
|
|
497
|
+
OpenReceive never looks inside the `reference`, but it relies on it:
|
|
498
|
+
|
|
499
|
+
- `onPaid` commits fulfillment once per reference.
|
|
500
|
+
- A new checkout under a reference that already settled is refused with 409.
|
|
501
|
+
- A fresh id on every page load would let one order be paid twice.
|
|
460
502
|
|
|
461
503
|
Naming boundary: TypeScript APIs use camelCase fields (`paymentHash`,
|
|
462
|
-
`amountMsats`)
|
|
463
|
-
|
|
504
|
+
`amountMsats`). Everything on the wire is snake_case (`payment_hash`,
|
|
505
|
+
`amount_msats`). The wire means the mounted HTTP routes and the browser
|
|
506
|
+
snapshots.
|
|
464
507
|
|
|
465
508
|
### 5. Render checkout
|
|
466
509
|
|
|
@@ -471,45 +514,51 @@ import "@openreceive/react/styles.css";
|
|
|
471
514
|
<Checkout reference={order.id} prefix="/openreceive" />;
|
|
472
515
|
```
|
|
473
516
|
|
|
474
|
-
The checkout renders, polls, and settles itself.
|
|
475
|
-
|
|
476
|
-
|
|
517
|
+
The checkout renders, polls, and settles itself.
|
|
518
|
+
|
|
519
|
+
`@openreceive/react` and `@openreceive/elements` each ship a compiled
|
|
520
|
+
`styles.css`. Each sheet is self-contained, so a plain
|
|
521
|
+
`<link rel="stylesheet">` works with no build step. Each is also scoped: every
|
|
477
522
|
rule applies only inside what OpenReceive renders.
|
|
478
523
|
|
|
479
|
-
Serve the compiled `styles.css` without Tailwind processing
|
|
480
|
-
JavaScript
|
|
481
|
-
Do not `@import` it into
|
|
482
|
-
|
|
524
|
+
Serve the compiled `styles.css` without Tailwind processing. Import it from
|
|
525
|
+
JavaScript if your bundler handles CSS, or use a plain
|
|
526
|
+
`<link rel="stylesheet">`. Do not `@import` it into your app's Tailwind entry.
|
|
527
|
+
Its rules have zero specificity, so your page's styles can override checkout
|
|
528
|
+
styles. Scoping does not prevent that.
|
|
483
529
|
|
|
484
|
-
`<Checkout>` is complete as rendered
|
|
530
|
+
`<Checkout>` is complete as rendered. It already shows the `description` from
|
|
485
531
|
`amountFor` and the collapsed transaction-details panel. Do not build a custom
|
|
486
|
-
UI to
|
|
487
|
-
drop-in ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
|
|
532
|
+
UI to show them. The display rules for them become your job only if you
|
|
533
|
+
replace the drop-in component ([Checkout UX](https://openreceive.org/guides/checkout-ux.md)).
|
|
488
534
|
|
|
489
|
-
Match the host page's theme
|
|
490
|
-
stored choice, then the system scheme. If this page
|
|
491
|
-
it
|
|
492
|
-
|
|
493
|
-
variables under `data-theme
|
|
494
|
-
the
|
|
535
|
+
Match the host page's theme. By default the checkout follows the payer's
|
|
536
|
+
stored choice, then the system color scheme. If this page always uses one
|
|
537
|
+
theme, lock it with `<Checkout theme="dark" … />`. On the custom element, set
|
|
538
|
+
the `theme` attribute. Locking the theme keeps a white card off a dark page.
|
|
539
|
+
CSS variables under `data-theme` style the checkout.
|
|
540
|
+
[Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) lists the settings you can change.
|
|
495
541
|
|
|
496
542
|
Everything the checkout draws ships inside the JavaScript: the payment-method
|
|
497
|
-
icons, the wallet logos and the pay tutorials. There is no image file to copy
|
|
498
|
-
or serve and no asset option to set. Deploy your normal JavaScript and CSS
|
|
543
|
+
icons, the wallet logos, and the pay tutorials. There is no image file to copy
|
|
544
|
+
or serve, and no asset option to set. Deploy your normal JavaScript and CSS
|
|
499
545
|
build output, including any generated JavaScript chunks. Bundlers with code
|
|
500
|
-
splitting can
|
|
501
|
-
|
|
502
|
-
Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
546
|
+
splitting can wait to load tutorial screenshots until a tutorial first opens.
|
|
547
|
+
Single-file builds, including the standalone checkout, include them from the
|
|
548
|
+
start. If your Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
503
549
|
([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
|
|
504
550
|
|
|
505
|
-
That is the whole loop
|
|
506
|
-
an invoice
|
|
551
|
+
That is the whole loop. Your server owns the price and the order. The payer
|
|
552
|
+
gets an invoice. `onPaid` runs inside the settlement transaction. If that
|
|
553
|
+
transaction rolls back, the callback may run again. For delivery to outside
|
|
554
|
+
systems, use an outbox in your app: record the message in the transaction and
|
|
555
|
+
send it after commit.
|
|
507
556
|
|
|
508
|
-
|
|
509
|
-
is Buy a Button
|
|
557
|
+
Buy a Button is a runnable illustration of this boundary
|
|
510
558
|
(`examples/buttons/server/node-express`).
|
|
511
|
-
It
|
|
512
|
-
|
|
559
|
+
It is not a template to copy models from. It has products, visitors, and
|
|
560
|
+
orders, and the three hooks are the only bridge to OpenReceive. Map that shape
|
|
561
|
+
onto the models in THIS app.
|
|
513
562
|
|
|
514
563
|
### 6. Verify
|
|
515
564
|
|
|
@@ -517,16 +566,17 @@ Map that shape onto the models in THIS app.
|
|
|
517
566
|
npx openreceive doctor
|
|
518
567
|
```
|
|
519
568
|
|
|
520
|
-
`openreceive doctor` checks Node, `NWC_URI`, and swap-provider
|
|
521
|
-
|
|
522
|
-
`--db <file-or-url>` to confirm the migration ran
|
|
523
|
-
`--url http://localhost:3000` to confirm the routes are mounted
|
|
569
|
+
`openreceive doctor` checks Node, `NWC_URI`, and the swap-provider
|
|
570
|
+
configuration. It also probes the wallet relay to confirm the code is
|
|
571
|
+
receive-only. Add `--db <file-or-url>` to confirm the migration ran. Add
|
|
572
|
+
`--url http://localhost:3000` to confirm the routes are mounted. Every failing
|
|
524
573
|
line states its own fix.
|
|
525
574
|
→ [openreceive doctor](https://openreceive.org/guides/api-reference.md#openreceive-doctor)
|
|
526
575
|
|
|
527
|
-
Then open the checkout in a browser
|
|
528
|
-
wallet logos render
|
|
529
|
-
If an image is missing,
|
|
530
|
-
panel for failed JavaScript chunks.
|
|
531
|
-
complete build output. Do not add image routes
|
|
532
|
-
use registry `icon_path`
|
|
576
|
+
Then open the checkout in a browser. Confirm the payment-method icons and
|
|
577
|
+
wallet logos render. Open a wallet's pay tutorial to check its screenshots.
|
|
578
|
+
If an image is missing, look in the console for CSP violations and in the
|
|
579
|
+
Network panel for failed JavaScript chunks. To fix it, allow `data:` in
|
|
580
|
+
`img-src` and deploy the complete build output. Do not add image routes or
|
|
581
|
+
copy package source images. Do not use registry `icon_path` or tutorial
|
|
582
|
+
`path` keys as browser URLs.
|