openreceive 0.4.26 → 0.4.28

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/openreceive/version.rb +1 -1
  4. data/skills/integrate-openreceive/SKILL.md +37 -5
  5. data/skills/integrate-openreceive/references/astro.md +653 -0
  6. data/skills/integrate-openreceive/references/bolt.md +580 -0
  7. data/skills/integrate-openreceive/references/btcpay.md +1 -1
  8. data/skills/integrate-openreceive/references/django.md +23 -2
  9. data/skills/integrate-openreceive/references/edd.md +407 -0
  10. data/skills/integrate-openreceive/references/fastapi.md +23 -2
  11. data/skills/integrate-openreceive/references/fastify.md +31 -6
  12. data/skills/integrate-openreceive/references/flask.md +23 -2
  13. data/skills/integrate-openreceive/references/fossbilling.md +433 -0
  14. data/skills/integrate-openreceive/references/laravel.md +1 -1
  15. data/skills/integrate-openreceive/references/lovable.md +6 -2
  16. data/skills/integrate-openreceive/references/medusa.md +468 -0
  17. data/skills/integrate-openreceive/references/mobile.md +492 -0
  18. data/skills/integrate-openreceive/references/nestjs.md +41 -16
  19. data/skills/integrate-openreceive/references/next.md +34 -7
  20. data/skills/integrate-openreceive/references/node.md +34 -7
  21. data/skills/integrate-openreceive/references/nuxt.md +606 -0
  22. data/skills/integrate-openreceive/references/paymenter.md +369 -0
  23. data/skills/integrate-openreceive/references/php.md +7 -4
  24. data/skills/integrate-openreceive/references/rails.md +14 -9
  25. data/skills/integrate-openreceive/references/react-router.md +617 -0
  26. data/skills/integrate-openreceive/references/sveltekit.md +650 -0
  27. data/skills/integrate-openreceive/references/tanstack-start.md +734 -0
  28. data/skills/integrate-openreceive/references/woocommerce.md +8 -6
  29. metadata +12 -1
@@ -0,0 +1,606 @@
1
+ This is the full file; follow it from Step 0.
2
+
3
+ # OpenReceive agent directions (Nuxt)
4
+
5
+ ```sh
6
+ # READ THIS FIRST: this file is 33 KB and a summary drops required steps. Download it whole:
7
+ curl -fsSL https://openreceive.org/agent-directions/nuxt/full.md
8
+ # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
+ ```
10
+
11
+ **Step 0 in brief** (Step 0 below has the details):
12
+
13
+ - Before installing or editing anything, ask the user for a receive-only NWC code. One question per message.
14
+ - Next ask for the LSC code. If the user wants stablecoins, USDT, USDC, ETH, SOL or crypto, do not ask yes/no first.
15
+ - The user only pastes codes into this chat. Never ask them to edit .env or run a command to save one.
16
+ - Write each code into .env yourself, as Step 0 says. Never echo it or put it in a shell command.
17
+ - Do not suggest rotating or revoking a code because it was pasted here.
18
+ - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
+
20
+ These directions describe OpenReceive 0.4.28.
21
+
22
+ Add OpenReceive to a Nuxt application — the app you are already working in,
23
+ on Nitro's `node-server` preset. OpenReceive ships no Nuxt package: the
24
+ integration is one server route that hands each request to
25
+ `@openreceive/http`. You do not need a copy of the OpenReceive source: the
26
+ packages are on npm, and the Nuxt recipe is appended to this file in full as
27
+ the quickstart, so you can do the whole integration without fetching
28
+ anything. Prefer the published packages and the handler they export — do not
29
+ reimplement wallet RPC, settlement, or pricing.
30
+
31
+ Do not clone the OpenReceive repository into this app, and do not copy a demo's
32
+ models (`ShopOrder`, a signed-cookie visitor, an in-memory catalog) over tables
33
+ that already exist. Find this application's order, product, and user models —
34
+ whatever they are actually named — and map the three hooks onto those.
35
+
36
+ Keep this application's frontend framework, authentication and database. Pick
37
+ the UI package that matches the frontend that is already here
38
+ (`@openreceive/react`, `/vue`, `/svelte`, `/angular`, or `/elements` for
39
+ plain HTML) — do not add React to a Vue app. Reuse the app's existing
40
+ session/auth in `authorize` and its existing database handle in `storage.db`.
41
+
42
+ ## What OpenReceive is
43
+
44
+ A payment library that runs inside YOUR server. It mounts as ONE catch-all
45
+ server route (`server/routes/openreceive/[...path].ts`, on Nitro's
46
+ `node-server` preset) in the application you are editing, issues Lightning
47
+ invoices against a wallet the merchant already controls, and calls back into
48
+ your code when one settles. There is no OpenReceive account and no API key, and
49
+ OpenReceive never holds the funds — the sats land in the wallet the merchant
50
+ connected.
51
+
52
+ The one required credential is a receive-only NWC code (Nostr Wallet Connect):
53
+ a string from the merchant's wallet that can create invoices and read their
54
+ status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
55
+ payer send USDT, USDC, ETH or SOL instead, converted into that same
56
+ Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`, `amountFor`,
57
+ `onPaid`;
58
+ OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
59
+ owns orders, users, prices, or fulfillment.
60
+
61
+ ## Step 0 — ask for the two codes, one question at a time
62
+
63
+ Before anything else, check one file: the project's `.env`, if it exists.
64
+ `grep -E '^(NWC_URI|LSC_URI_PRIMARY)=.' .env | cut -d= -f1` names the codes
65
+ it sets without printing them. Check with that, here and after each write,
66
+ not by reading the file, and never print the values. A code that is already
67
+ set is not asked for again; if both are set, skip to step 5 (making the
68
+ server load the file), then the quickstart.
69
+
70
+ On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
71
+ that both codes are already set as the project's environment variables or
72
+ secrets. Believe them: do not ask for the codes, do not write `.env`, and
73
+ do not read or print the variables. Skip step 5's file loading: the platform already puts them in `process.env`. Do not add them to a compose file or any other deploy config
74
+ either: they already reach the app, and a line such as `NWC_URI: ${NWC_URI}`
75
+ replaces them with an empty value.
76
+
77
+ Otherwise your next action is a question to the user. Do not install packages,
78
+ edit the app, write `.env.example`, or search anywhere else before asking
79
+ it. Do not read deploy config (compose files, Vercel or platform secrets), Docker containers, or process environments, and never run
80
+ `printenv`. A new shop has neither code yet: hunting for one burns the turn and
81
+ can leak other secrets into the transcript.
82
+
83
+ Two server-only URIs are needed before the quickstart:
84
+
85
+ - `NWC_URI` — a receive-only Nostr Wallet Connect code,
86
+ `nostr+walletconnect://…`. Required for Bitcoin.
87
+ - `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
88
+ `lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
89
+ only when the user says they want Bitcoin alone.
90
+
91
+ The user never edits an environment file. They paste each code into the chat;
92
+ you store it. Ask one question per message.
93
+
94
+ 1. **First message — the NWC code, and nothing else.** Ask for it and walk them
95
+ through getting it:
96
+
97
+ > To receive payments I need a receive-only wallet code. In Rizful: open
98
+ > the menu, tap NWC, choose Receive-only NWC code, and tap Copy
99
+ > (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
100
+ > rather run your own wallet, Alby Hub works too: Connections → Add
101
+ > Connection → Read Only. Paste the code here and I will store it.
102
+
103
+ Do not mention `.env`, exports, or "tell me when it's set".
104
+ 2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
105
+ ask them to copy the receive-only code again. Otherwise write
106
+ `NWC_URI=<paste>` into the project's `.env` with your file-editing
107
+ tool, creating the file if needed. Never write it with a shell command
108
+ (`echo`, `printf`, a heredoc, `python -c`): the command line shows the
109
+ code. Make sure `.gitignore` covers `.env` (and `.dockerignore`, if
110
+ the app has one). Never echo the value, commit it, or put it in client
111
+ code. Reply only that it is saved, then ask the next question.
112
+ 3. **Second message — swaps.** If the user asked for stablecoins, USDT, USDC,
113
+ ETH, SOL, altcoins or "crypto" (as in "Bitcoin and stablecoin payments"),
114
+ this message IS the walkthrough below: send it as it is, and do not ask yes
115
+ or no first. Otherwise ask whether payers should also be able to pay with
116
+ USDT, USDC, ETH or SOL, then give the walkthrough. The walkthrough:
117
+
118
+ > Go to https://lightning-swap.com, sign in for API keys, create a key, and
119
+ > copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
120
+ > it here and I will store it — or say "Bitcoin only" and I will continue
121
+ > without it.
122
+
123
+ Mention FixedFloat only if they already use it.
124
+ 4. **When they paste it.** If it does not start with
125
+ `lightning+swapconnect://`, ask them to copy it again. Otherwise add
126
+ `LSC_URI_PRIMARY=<paste>` to the same `.env` with the file-editing
127
+ tool, never a shell command. Swaps are now on, so build the refund route
128
+ back (the swap non-negotiable below) as part of this integration. If they
129
+ chose Bitcoin only, leave `LSC_URI_PRIMARY` unset and skip that route.
130
+ 5. **Make the server load the file — yourself.** OpenReceive reads
131
+ `process.env`. `nuxt dev` loads `.env` into it, but the built server does
132
+ not: start it with `node --env-file=.env .output/server/index.mjs`. When
133
+ the app is started with Docker Compose, give the service `env_file: .env`.
134
+ Never copy a code into `runtimeConfig.public` or a `NUXT_PUBLIC_` variable:
135
+ both go to the browser. Restart the server after writing the file.
136
+ Under Compose, recreate the container with `docker compose up -d`:
137
+ `docker compose restart` keeps its old environment.
138
+
139
+ Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
140
+ saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
141
+ runs the receive-only preflight: if it reports spend methods such as
142
+ `pay_invoice`, remove `NWC_URI` from `.env` and ask for a receive-only code
143
+ again. Never set the spend-capable override to get past it.
144
+
145
+ ### Upgrading an existing install
146
+
147
+ This is not the opening move of a new integration. When OpenReceive is ALREADY
148
+ installed here, `npx openreceive doctor` reports every credential as set/unset
149
+ (never the value) and probes the wallet. Check the installed
150
+ `@openreceive/node` and `@openreceive/browser` against the release named at the
151
+ top of this file: the headless display models below do not exist in older
152
+ versions, and the first tile click throws with nothing saying why. Upgrade
153
+ first.
154
+
155
+ Only then start the quickstart.
156
+
157
+ ## After the quickstart — hand over, then stop
158
+
159
+ The quickstart is done when
160
+ `npx openreceive doctor --db <file-or-url> --url <app url>` is clean and this
161
+ app serves the checkout page for one of its orders. Doctor names any failed
162
+ check and exits nonzero; fix it before going on.
163
+ Doctor reads `.env` itself. Never source it into a shell: the `&` in a
164
+ code splits the value and prints the pieces.
165
+
166
+ Give the user that checkout link. The browser check of that page
167
+ (payment-method icons, wallet logos, a pay tutorial) is theirs: name it in one
168
+ line of your closing message, and do not run it yourself.
169
+
170
+ You cannot pay the invoice: the code is receive-only. Do not pay, settle or
171
+ mark an order paid, and do not look for a way to (a wallet control port, a
172
+ test endpoint, another wallet). If the user wants a real settlement test, they
173
+ pay on that link from their own wallet, and `onPaid` marks the order paid.
174
+
175
+ Setup ends here. Your last message starts "Setup is finished" and has at most
176
+ five short lines (about 80 characters each): the link, the methods it offers,
177
+ and one line of what to look at. Send nothing after it. Do not list what
178
+ changed, copy out the quickstart's browser checklist, offer more work, or end
179
+ the message on a question.
180
+
181
+ - The link is to a real unpaid order. Keep that order; do not delete it.
182
+ - When this app's orders belong to a session or cookie, the user's browser
183
+ cannot open the order you made. Then the link is the shop's own page:
184
+ "Open <shop url> and click Buy: it opens the checkout." Do not explain order
185
+ ownership or mention your test order.
186
+ - Name the methods it offers: Bitcoin, plus USDT, USDC, ETH and SOL when
187
+ `LSC_URI_PRIMARY` is saved. Do not mention minimums, and never say a coin
188
+ will not work or will not be offered.
189
+
190
+ ## Non-negotiables
191
+
192
+ The quickstart below has the code. These are the rules it cannot state for
193
+ itself, and they hold for every integration.
194
+
195
+ - OpenReceive never owns orders, users, prices, or fulfillment. The section
196
+ below is how those tables sit next to the library — not a second order model,
197
+ and not a Prisma/Drizzle relation to `openreceive_payments`.
198
+ - Keep `NWC_URI` / `LSC_URI_*` server-only. Never put them in browser code,
199
+ logs, or assets.
200
+ - Do not suggest rotating, revoking or replacing a code because it was pasted
201
+ into this chat; that is the supported path.
202
+ - Work only in this application. Never read or run anything from another
203
+ project on this machine (its `node_modules`, tools or source), for any
204
+ reason. A browser and Playwright are not part of setup.
205
+ - Restart only this app's server, on the port it already uses: stop the
206
+ process you started, or the one listening on that port, by its pid (or
207
+ restart its Compose service). Never `pkill` or `killall` by name: that
208
+ stops other people's servers too. Start it the way this project already
209
+ does (its README, Procfile, compose file or package script), on its own
210
+ port, not a port you pick.
211
+ - Run commands where the app runs. When a compose file builds it, run its
212
+ package manager, generators, migrations and doctor inside that service
213
+ (`docker compose exec` or `run`), and rebuild the image after adding a
214
+ package. This machine's language version and database path are not the
215
+ app's.
216
+ - To check that the running app sees the codes, run doctor: it reports each
217
+ one as present or missing and never prints a value. Never print the
218
+ environment (`printenv`, `env`, `docker compose config`), even filtered to
219
+ names.
220
+ - The host owns the price. `amountFor` reads it from your own data; reject
221
+ payer-supplied amounts.
222
+ - `authorize` runs on every request, and the `resource` it receives is a CLAIM
223
+ the payer made, not proof. Read a framework session; never trust a body field.
224
+ - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
225
+ per thing you fulfill, created before checkout, kept across retries, never
226
+ reused. A fresh id per page load lets one order be paid twice.
227
+ - Receive-only NWC is required; a spend-capable code fails closed at boot unless
228
+ explicitly overridden.
229
+ - There is NO merchant-initiated refund of a settled Lightning payment, because
230
+ the wallet cannot spend. Swap refunds — a payer reclaiming a deposit that
231
+ never converted — are the only refund OpenReceive performs, and only from the
232
+ `refund_required` provider state. Do not build, promise, or imply a Lightning
233
+ refund path.
234
+ - IF YOU TURN SWAPS ON, BUILD THE ROUTE BACK. A deposit that arrives short or
235
+ late becomes `refund_required`, and the payer claims it on a SECOND VISIT,
236
+ after leaving your page to fetch an address from another wallet. Three things
237
+ must exist or that money is unreachable through your UI: a per-order URL your
238
+ server serves (`/checkout/:reference` — `syncUrl` on `<Checkout>`, `sync-url`
239
+ or `resumable` on `<openreceive-checkout>`), your own order-summary route to
240
+ restore the order from, and the ATTEMPT.
241
+ `/checkouts/prepare` returns no attempts, so a checkout rebuilt from the
242
+ reference alone opens on the method grid. Re-picking the same coin
243
+ (`POST /swaps`) re-serves the committed attempt — but only while it is live,
244
+ and the shadow invoice behind a swap lasts about half an hour, after which the
245
+ same click mints a NEW deposit address and the refund is off-screen. Keep the
246
+ `payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
247
+ such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
248
+ `<Checkout>`; the `resume-payment-hash` attribute, fed from the
249
+ `openreceive-state` event (`event.detail.state.payment_hash`), on
250
+ `<openreceive-checkout>`.
251
+ That visit can come hours later, and `authorize` must still know the payer:
252
+ a session that expired in between answers 403 and strands the deposit. On a
253
+ guest shop, tie the order to a long-lived signed cookie, or put a secret
254
+ per-order token in its URL that your page trades for that cookie.
255
+ https://openreceive.org/guides/swap-refunds.md
256
+ - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
257
+ the price from `amountFor` and both drop-ins render it above the amount.
258
+ Without it the checkout is a QR and "$1.00" with no sign of what the dollar
259
+ is for.
260
+ - Show the payer the transaction record: `createTransactionDetails(...)` rows,
261
+ collapsed behind a caret, on the live checkout AND on the receipt. A payment
262
+ hash and a deposit txid are the only evidence a payer has that they paid you.
263
+ `<Checkout>` / `<openreceive-checkout>` already render this panel and the
264
+ `description` — these two rules cost you code only on a custom UI or your own
265
+ receipt page, never a reason to replace the drop-in. (It returns no rows
266
+ while the rail is `checkout_lock` — before the payer has chosen anything
267
+ there is no transaction — so render the caret only when the rows are
268
+ non-empty.)
269
+ - The handler lives in `server/utils/`, and the stack is built on the first
270
+ request, never at import, so the build and prerendering never connect to the
271
+ wallet. The route goes in `server/routes/`, not `server/api/` (which adds
272
+ `/api` to the path), runs on Node — never an edge preset — and hands
273
+ `@openreceive/http` `toWebRequest(event)`.
274
+ - Pass the `H3Event` as `native`, so `authorize` reads the session the app
275
+ already has, and give `rateLimiting` `ip: ({ native }) =>
276
+ getRequestIP(native)`. Add `{ xForwardedFor: true }` only behind your own
277
+ reverse proxy, which sets that header.
278
+ - `<Checkout>` comes from `@openreceive/vue/checkout.vue`, with
279
+ `@openreceive/vue/styles.css`, on the order's own page: its resumable URL.
280
+ - HTTP JSON is snake_case; TypeScript APIs are camelCase.
281
+ - Money is integers or decimal strings — never binary floats.
282
+
283
+ ## Your tables, not ours
284
+
285
+ `npx openreceive scaffold payments` emits `openreceive_payments` and
286
+ `openreceive_meta` for THIS application's database. That is the whole
287
+ persistence OpenReceive needs. It does not replace your orders, users, or
288
+ products, and you do not join them.
289
+
290
+ - **Find this app's models first.** They may be named `Order`, `Invoice`,
291
+ `Booking`, `Product`, `Variant`, `User`, `Account` — anything. Wire the hooks
292
+ to those. Do not generate a parallel `ShopOrder` / `ShopProduct` / `ShopUser`
293
+ stack.
294
+ - **The payable row's id is the `reference`.** Create it before checkout, keep
295
+ it across retries, never reuse it. Pass that id to `<Checkout>` /
296
+ `<openreceive-checkout>`. A fresh id per page load lets one order be paid
297
+ twice.
298
+ - **Products (or the catalog) are the price authority.** Order creation reads
299
+ live prices into the order (snapshot line items if this app has them).
300
+ `amountFor` reads only that order — never a payer-supplied amount, never a
301
+ live catalog lookup that could re-price a cart already placed. Return
302
+ `{ currency, value }` as a decimal STRING, plus a `description` of what they
303
+ are buying.
304
+ - **Users own the order; OpenReceive never sees them.** `authorize` uses the
305
+ same ownership check this app already uses on the order show / pay page —
306
+ `getCookie(event, …)`, the user its session module reads from the event,
307
+ whatever it is. `native` is the request's `H3Event`.
308
+ `resource.reference` is a claim the payer sent, not proof.
309
+ - **The order is unpaid or paid.** Do not copy `pending` / `expired` / `failed`
310
+ / `attention` onto it. Those are attempt statuses on `openreceive_payments`. An
311
+ expired invoice does not cancel the order; a later checkout may mint another
312
+ attempt. The library refuses a new checkout under a reference that already
313
+ settled (409).
314
+ - **A paid order's page says it is paid and shows no checkout.** Nothing is left
315
+ to pay, and a checkout cannot start a new payment for a paid order. Mount the
316
+ checkout only while the order is unpaid. When it settles on the page, update
317
+ the page's status line from `@settled` on `<Checkout>`: `onPaid` has already
318
+ marked the order paid. Keep that checkout mounted, because it is the payer's
319
+ receipt.
320
+ - **Pass this app's `db` handle.** Do not add a Prisma/Drizzle relation from
321
+ Order to `openreceive_payments`, and do not implement `PaymentRepository`
322
+ unless no supported handle can reach this database. `reference` is not unique
323
+ (many attempts per order). Fulfillment is a guarded transition on YOUR order
324
+ row inside `onPaid` — `UPDATE … WHERE state = 'awaiting_payment'` (or this
325
+ app's equivalent) through the `query` the library hands you, on that same
326
+ settlement transaction, not a second connection from your ORM. Database writes
327
+ only in the hook; emails, jobs, and pushes after commit. Placeholder style is
328
+ the dialect you declared: `?` on sqlite and mysql, `$1` on postgres.
329
+
330
+ ## If you build your own checkout UI
331
+
332
+ The drop-ins (`<Checkout>`, `<openreceive-checkout>`) already obey all of this.
333
+ This list is the short form of https://openreceive.org/guides/checkout-ux.md, for a
334
+ UI built on `@openreceive/browser/headless`. Read that before writing
335
+ components.
336
+
337
+ - Check Bitcoin → Switch payment method → Bitcoin: the grid must hide the
338
+ Lightning invoice, then restore the same bolt11 without another mint.
339
+ - `createCheckoutController` is the engine. Do not hand-roll a poll loop.
340
+ - `createCheckoutStatusModel` for the status line. Do not draw a
341
+ Cart → Pay → Done stepper. Read the model's `phase`, not the snapshot's.
342
+ - `resolveWizardSelection` decides whether to ask "which network?". A
343
+ one-network asset starts the swap from the tile. Key `selectedAssetByGroup`
344
+ by group (`USDT`), valued by `pay_in_asset` (`USDT_TRON`).
345
+ - `createMethodGridDisplay` for tiles, including `limitMessage` so an
346
+ unavailable method says the minimum in the payer's currency.
347
+ - `createSwapDisplayModel` → `display.copyRows` for deposits: address, memo,
348
+ and the bare amount each get a copy row. Render `swap.networkWarning*` as
349
+ the model gives it.
350
+ - `swap.deposit_amount` is the only amount a payer is told to send. Never put
351
+ a fiat valuation of it (`swap.fee.pay_in_fiat`) next to a stablecoin amount:
352
+ "$50.03" under "50.05 USDC" reads as a typo, and the payer asks which one to
353
+ send. The one fiat figure on a USDT/USDC deposit panel is the cart total
354
+ (`payout_fiat`); express "you send" and the fee in the token. Use
355
+ `createSwapFeeBreakdown(fee, swap)` — with the swap, not the fee alone — and
356
+ it applies this for you; SOL and ETH keep a fiat breakdown.
357
+ - `createCheckoutSession` owns mint and swap start. To start swaps, pass its
358
+ `swap` option (`selection`, `prefix`, `fetch`) together. Without it
359
+ `startSwap` reports through `onError`.
360
+ - `createQrSvg` is async. Use `createQrSvgController` so you do not render
361
+ `[object Promise]`.
362
+ - `checkoutLabels` for every payer-facing string. Only write copy it lacks.
363
+ - `stageSwapRefund` then `confirmSwapRefund` — only the second submits.
364
+ Validate with `getSwapRefundFormError`. Treat `409` as a normal outcome.
365
+ - Pass `{ resumable: true }` to `createSwapDisplayModel` when the payer has
366
+ a URL they can come back to, and render `display.refundReturnLabel`.
367
+ Resume helpers (`createGuestCheckoutResume`, `createGuestOrderFetcher`)
368
+ are on `@openreceive/browser`, not `/headless`.
369
+ - A refund replaces the deposit panel. On `refund_required` also drop
370
+ "switch payment method".
371
+ - No "Open wallet" button on desktop.
372
+ - Wallet suggestions: `getPaymentWizardRoutes()` +
373
+ `createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
374
+ images load from a JavaScript chunk. For a custom headless UI, load it when
375
+ a tutorial opens and look up the returned table by the tutorial's `path`:
376
+
377
+ ```js
378
+ import { loadPayTutorialImages } from "@openreceive/browser/headless";
379
+
380
+ const images = await loadPayTutorialImages();
381
+ const src = images[tutorial.path]; // data URI for the selected tutorial
382
+ ```
383
+
384
+ Render `src` as the image source and update your UI after loading. Existing
385
+ display objects do not update: their `tutorial.image` stays `undefined` if
386
+ created before loading. Alternatively, await the loader, recreate the displays
387
+ with `createWizardRouteDisplays`, and render the new `tutorial.image`.
388
+ Show the caption while loading or if loading fails; never use an empty image
389
+ source. Deploy all JavaScript chunks and allow `data:` in CSP `img-src`.
390
+ For missing images, check CSP errors, failed chunks, and stale displays.
391
+ Registry paths are lookup keys; there is no asset option or image route.
392
+
393
+ ## More documentation
394
+
395
+ Fetch one when the moment comes. Each is raw markdown, so a plain GET is
396
+ enough; drop the `.md` for the same page a person would read.
397
+
398
+ - https://openreceive.org/guides/authorization.md — before you write `authorize`
399
+ - https://openreceive.org/guides/environment-variables.md — every variable, and what is deliberately not one
400
+ - https://openreceive.org/guides/storage.md — the payment tables and the attempt state machine
401
+ - https://openreceive.org/guides/supabase.md — when the database is Supabase: its pooler, its certificate, and locking the tables away from its Data API
402
+ - https://openreceive.org/guides/serverless.md — when the app runs serverless (Netlify, AWS Lambda, Cloud Run, Google AI Studio): pooled database URLs, timeouts, and why it needs no cron or worker
403
+ - https://openreceive.org/guides/node-orms.md — recipes for Prisma, Drizzle, Knex, TypeORM, Sequelize
404
+ - https://openreceive.org/guides/frontend-checkout.md — the drop-in's props, attributes and slots
405
+ - https://openreceive.org/guides/mobile-apps.md — when a mobile app takes the payment: the checkout page it opens, and what the App Store and Google Play allow
406
+ - https://openreceive.org/guides/checkout-ux.md — read before building any custom UI
407
+ - https://openreceive.org/guides/headless-checkout.md — the controller, the display models, refunds
408
+ - https://openreceive.org/guides/provider-registry.md — where the wallet logos and pay
409
+ tutorials come from: inside the JavaScript, nothing to serve. This is the page
410
+ that owns the image rule, not the summary in checkout-ux.md
411
+ - https://openreceive.org/guides/automated-swaps.md — only if `LSC_URI_PRIMARY` is set
412
+ - https://openreceive.org/guides/swap-refunds.md — the refund flow, and the route back to it. Read it before you turn swaps on
413
+ - https://openreceive.org/guides/lightning-swap-connect.md — what an `LSC_URI_*` code actually is
414
+ - https://openreceive.org/guides/price-feeds.md — where the fiat→sats rate comes from, and how to replace it
415
+ - https://openreceive.org/guides/host-testing.md — testing your three hooks without a live wallet or provider
416
+ - https://openreceive.org/guides/rate-limiting.md — before a public shop goes live
417
+ - https://openreceive.org/guides/security.md and https://openreceive.org/guides/deploying.md — before this goes anywhere real
418
+ - https://openreceive.org/guides/api-reference.md — every route, option and error code
419
+ - https://openreceive.org/guides/custom-checkout-route.md — advanced: replacing the shipped adapter's routes with your own
420
+ - https://openreceive.org/guides/react-material-ui-recipe.md — a worked custom UI on a component library
421
+ - https://openreceive.org/guides/quickstart-next.md — each hook explained step by step, on Next.js; they are the same here
422
+ - https://openreceive.org/guides.md — the index, if what you need is not above
423
+
424
+ Questions, or a problem with the library itself:
425
+ https://openreceive.org/contact
426
+
427
+ - https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
428
+
429
+ ---
430
+
431
+ ## The quickstart, in full
432
+
433
+ Inlined verbatim so this file needs no network access — follow it once Step 0
434
+ passes. The page it comes from is https://openreceive.org/guides/nuxt-recipe.
435
+
436
+ ## Nuxt recipe
437
+
438
+ OpenReceive ships no Nuxt package. A Nuxt server route can hand the request
439
+ to `@openreceive/http` as a Web-standard `Request` and send back the
440
+ `Response` it returns, so the integration is the route below. Your server code
441
+ creates each Lightning invoice, the payment goes straight to your wallet, and
442
+ payment attempts are stored in your app's database. There is no OpenReceive
443
+ account and no background worker.
444
+
445
+ Optional swaps let customers pay with **USDT, USDC, SOL, and ETH**. A swap
446
+ provider you configure converts the payment to **BTC over Lightning**, and it
447
+ settles into the same wallet. Available assets and networks depend on the
448
+ provider.
449
+
450
+ This recipe was checked with `nuxt` 4.6 (Nitro 2, h3 1.15) and
451
+ `@openreceive/*` 0.4.25. The built app ran on Node in Docker
452
+ (`node .output/server/index.mjs`), with Postgres and a test wallet on a public
453
+ NWC relay. In Chromium, the buyer's checkout page showed the Lightning
454
+ invoice. A stranger got 403 from the payment routes and 404 from the page, and
455
+ a request that named its own amount got 400. When the wallet marked the
456
+ invoice paid, the page showed it paid and `onPaid` marked the order paid.
457
+
458
+ ```sh
459
+ npm install @openreceive/http @openreceive/vue pg
460
+ ```
461
+
462
+ ### Where it runs
463
+
464
+ On Node, with Nitro's default `node-server` preset. The wallet connection and
465
+ your database driver need Node, so the route cannot run on an edge runtime.
466
+ The Vercel, Netlify and AWS Lambda presets deploy Node functions: read
467
+ Bitcoin checkout on serverless hosts first. For
468
+ Cloudflare Workers, the [TanStack Start recipe](https://openreceive.org/guides/tanstack-start-recipe.md#where-it-runs)
469
+ explains what a Worker needs. This recipe was not run on those hosts.
470
+
471
+ ### The payment route
472
+
473
+ Files in `server/` run only on the server, and Nuxt auto-imports the h3
474
+ helpers and everything in `server/utils/` there:
475
+
476
+ ```ts
477
+ // server/utils/openreceive.ts
478
+ import { createStack, type Stack } from "@openreceive/http";
479
+ import type { H3Event } from "h3";
480
+
481
+ let stack: Stack | undefined;
482
+
483
+ // Built on the first request, not at import, so the build and prerendering
484
+ // never connect to the wallet.
485
+ function openReceive(): Stack {
486
+ stack ??= createStack({
487
+ wallet: { nwc: process.env.NWC_URI ?? "" },
488
+ storage: {
489
+ db, // your existing pg Pool, from server/utils/db.ts
490
+ // Runs once, inside the transaction that records the payment.
491
+ onPaid: async ({ reference, paidAt, query }) => {
492
+ await query(
493
+ "UPDATE orders SET state = 'paid', paid_at = $1 WHERE id = $2 AND state = 'awaiting_payment'",
494
+ [paidAt, reference],
495
+ );
496
+ },
497
+ },
498
+ // The price comes from the order row, never from the request.
499
+ amountFor: async (reference) => {
500
+ const order = await findOrder(reference); // your own orders
501
+ return order?.state === "awaiting_payment"
502
+ ? { currency: order.currency, value: order.amount, description: order.title }
503
+ : null;
504
+ },
505
+ // Only the buyer may pay for their order.
506
+ authorize: async ({ native, resource }) => {
507
+ const event = native as H3Event;
508
+ const order = resource.reference ? await findOrder(resource.reference) : undefined;
509
+ return Boolean(order && order.visitor === getCookie(event, "visitor"));
510
+ },
511
+ // The socket address. Behind your own proxy, pass { xForwardedFor: true }.
512
+ rateLimiting: {
513
+ ip: ({ native }) => getRequestIP(native as H3Event),
514
+ },
515
+ });
516
+ return stack;
517
+ }
518
+
519
+ export function handleOpenReceive(event: H3Event): Promise<Response> {
520
+ return openReceive().handler(toWebRequest(event), { native: event });
521
+ }
522
+ ```
523
+
524
+ ```ts
525
+ // server/routes/openreceive/[...path].ts — every route under /openreceive/
526
+ export default defineEventHandler((event) => handleOpenReceive(event));
527
+ ```
528
+
529
+ Put it in `server/routes/`, not `server/api/`, which would add `/api` to
530
+ the path. `native` is the request's `H3Event`, so `authorize` can check the
531
+ session your app already has: its cookies, or the user your session module
532
+ reads from the event. The Next.js quickstart
533
+ explains each hook. They are the same here.
534
+
535
+ One stack serves the whole server process. `getRequestIP` returns the socket
536
+ address. Behind your own reverse proxy, `{ xForwardedFor: true }` reads the
537
+ first address in `x-forwarded-for`, which is safe only when that proxy sets
538
+ the header (Rate limiting).
539
+
540
+ ### Your database
541
+
542
+ `db` is a `pg` Pool, `node:sqlite` or `better-sqlite3`, or one of the
543
+ adapters in Node ORM recipes. With Drizzle, pass
544
+ the `pg` Pool underneath it.
545
+
546
+ Create OpenReceive's two tables with your migrations
547
+ (`npx openreceive scaffold payments --orm <your orm>`), or run
548
+ `paymentsSchemaSql("postgres")` from `@openreceive/http` once. It is
549
+ idempotent. See Payment storage.
550
+
551
+ ### The checkout page
552
+
553
+ The page asks your own server route whether this visitor owns the order:
554
+
555
+ ```ts
556
+ // server/api/checkout/[reference].get.ts
557
+ export default defineEventHandler(async (event) => {
558
+ const order = await findOrder(getRouterParam(event, "reference") ?? "");
559
+ if (!order || order.visitor !== getCookie(event, "visitor")) {
560
+ throw createError({ statusCode: 404, statusMessage: "Not found" });
561
+ }
562
+ return { reference: order.id };
563
+ });
564
+ ```
565
+
566
+ ```vue
567
+ <!-- app/pages/checkout/[reference].vue -->
568
+ <script setup lang="ts">
569
+ import Checkout from "@openreceive/vue/checkout.vue";
570
+ import "@openreceive/vue/styles.css";
571
+
572
+ const route = useRoute();
573
+ // During server rendering, useFetch passes the visitor's cookies to your own routes.
574
+ const { data, error } = await useFetch(`/api/checkout/${route.params.reference}`);
575
+ if (error.value) {
576
+ throw createError({ statusCode: 404, statusMessage: "Not found", fatal: true });
577
+ }
578
+ </script>
579
+
580
+ <template>
581
+ <Checkout v-if="data" :reference="data.reference" prefix="/openreceive" />
582
+ </template>
583
+ ```
584
+
585
+ The page renders on the server and starts the checkout in the browser. The
586
+ payer picks Bitcoin and gets the invoice. Keep it at the order's own URL: a
587
+ payer with a swap deposit in flight comes back to it
588
+ (Swap refunds).
589
+
590
+ ### Settings
591
+
592
+ - `NWC_URI`: a receive-only code from your wallet
593
+ ([get one](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
594
+ - `DATABASE_URL`: your Postgres. On serverless hosts use the pooled URL.
595
+ - Optional: `LSC_URI_PRIMARY` for swaps
596
+ ([set one up](https://openreceive.org/set_up_swap_provider)), and
597
+ `LSC_URI_BACKUP`.
598
+
599
+ The route reads them from `process.env` when the first request arrives.
600
+ `nuxt dev` loads `.env` into `process.env`. In production, set them in the
601
+ server's environment: the built server does not read `.env`. Do not copy them
602
+ into `runtimeConfig.public`, which goes to the browser.
603
+
604
+ No worker or cron job is needed. Each request to the payment routes also
605
+ checks the wallet for settled invoices, through a lock in your database. A
606
+ payer who closes the tab is settled on the next request.