openreceive 0.4.31 → 0.4.33

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/lib/openreceive/nwc_ruby.rb +27 -0
  4. data/lib/openreceive/version.rb +1 -1
  5. data/skills/debug-openreceive-payment/SKILL.md +1 -0
  6. data/skills/integrate-openreceive/references/astro.md +35 -12
  7. data/skills/integrate-openreceive/references/bolt.md +3 -3
  8. data/skills/integrate-openreceive/references/btcpay.md +2 -1
  9. data/skills/integrate-openreceive/references/django.md +28 -8
  10. data/skills/integrate-openreceive/references/edd.md +12 -10
  11. data/skills/integrate-openreceive/references/fastapi.md +54 -30
  12. data/skills/integrate-openreceive/references/fastify.md +39 -13
  13. data/skills/integrate-openreceive/references/flask.md +38 -12
  14. data/skills/integrate-openreceive/references/fossbilling.md +25 -15
  15. data/skills/integrate-openreceive/references/laravel.md +36 -7
  16. data/skills/integrate-openreceive/references/lovable.md +2 -2
  17. data/skills/integrate-openreceive/references/medusa.md +2 -1
  18. data/skills/integrate-openreceive/references/mobile.md +2 -1
  19. data/skills/integrate-openreceive/references/nestjs.md +36 -12
  20. data/skills/integrate-openreceive/references/next.md +55 -29
  21. data/skills/integrate-openreceive/references/node.md +46 -14
  22. data/skills/integrate-openreceive/references/nuxt.md +35 -12
  23. data/skills/integrate-openreceive/references/odoo.md +13 -12
  24. data/skills/integrate-openreceive/references/paymenter.md +11 -7
  25. data/skills/integrate-openreceive/references/php.md +35 -10
  26. data/skills/integrate-openreceive/references/prestashop.md +28 -18
  27. data/skills/integrate-openreceive/references/rails.md +44 -13
  28. data/skills/integrate-openreceive/references/react-router.md +35 -12
  29. data/skills/integrate-openreceive/references/sveltekit.md +43 -14
  30. data/skills/integrate-openreceive/references/tanstack-start.md +35 -12
  31. data/skills/integrate-openreceive/references/vendure.md +2 -1
  32. data/skills/integrate-openreceive/references/woocommerce.md +17 -11
  33. metadata +1 -1
@@ -3,8 +3,9 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (NestJS)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 43 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 45 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/nestjs/full.md
8
+ # If your tool cuts long output, save it and read it in parts: curl -fsSL -o /tmp/openreceive-directions.md https://openreceive.org/agent-directions/nestjs/full.md
8
9
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
10
  ```
10
11
 
@@ -17,7 +18,7 @@ curl -fsSL https://openreceive.org/agent-directions/nestjs/full.md
17
18
  - Do not suggest rotating or revoking a code because it was pasted here.
18
19
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
20
 
20
- These directions describe OpenReceive 0.4.31.
21
+ These directions describe OpenReceive 0.4.33.
21
22
 
22
23
  Add OpenReceive to a NestJS application — the app you are already working in,
23
24
  on Nest's default Express platform. You do not need a copy of the OpenReceive
@@ -62,8 +63,9 @@ Before anything else, check one file: the project's `.env`, if it exists.
62
63
  `grep -E '^(NWC_URI|LSC_URI_PRIMARY)=.' .env | cut -d= -f1` names the codes
63
64
  it sets without printing them. Check with that, here and after each write,
64
65
  not by reading the file, and never print the values. A code that is already
65
- set is not asked for again; if both are set, skip to step 5 (making the
66
- server load the file), then the quickstart.
66
+ set is not asked for again; if both are set, make sure `.gitignore` covers
67
+ `.env` (and `.dockerignore`, if the app has one), then skip to step 5
68
+ (making the server load the file), then the quickstart.
67
69
 
68
70
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
69
71
  that both codes are already set as the project's environment variables or
@@ -211,6 +213,10 @@ itself, and they hold for every integration.
211
213
  - Work only in this application. Never read or run anything from another
212
214
  project on this machine (its `node_modules`, tools or source), for any
213
215
  reason. A browser and Playwright are not part of setup.
216
+ - The project's own rules (its `AGENTS.md`, contributing guide) win over these
217
+ directions. If one forbids a step here, such as running migrations, ask the
218
+ owner and wait for the answer, even if doctor cannot pass yet. Do not move
219
+ the step somewhere the rule does not name, such as app startup.
214
220
  - Restart only this app's server, on the port it already uses: stop the
215
221
  process you started, or the one listening on that port, by its pid (or
216
222
  restart its Compose service). Never `pkill` or `killall` by name: that
@@ -227,7 +233,8 @@ itself, and they hold for every integration.
227
233
  environment (`printenv`, `env`, `docker compose config`), even filtered to
228
234
  names.
229
235
  - The host owns the price. `amountFor` reads it from your own data; reject
230
- payer-supplied amounts.
236
+ payer-supplied amounts. A donation is no exception: its amount is saved
237
+ by your own route first (Donations, below).
231
238
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
232
239
  the payer made, not proof. Read a framework session; never trust a body field.
233
240
  - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
@@ -252,21 +259,25 @@ itself, and they hold for every integration.
252
259
  (`POST /swaps`) re-serves the committed attempt — but only while it is live,
253
260
  and the shadow invoice behind a swap lasts about half an hour, after which the
254
261
  same click mints a NEW deposit address and the refund is off-screen. Keep the
255
- `payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
256
- such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
257
- `<Checkout>`; the `resume-payment-hash` attribute, fed from the
262
+ `payment_hash` on your order row, not in browser storage, and reopen the
263
+ attempt with `POST /swaps/status`, which has no such window. On the
264
+ drop-ins: `resumePaymentHash`, fed from `onState`, on `<Checkout>`; the
265
+ `resume-payment-hash` attribute, fed from the
258
266
  `openreceive-state` event (`event.detail.state.payment_hash`), on
259
267
  `<openreceive-checkout>`.
260
268
  That visit can come hours later, and `authorize` must still know the payer:
261
269
  a session that expired in between answers 403 and strands the deposit. On a
262
- guest shop, tie the order to a long-lived signed cookie, or put a secret
263
- per-order token in its URL that your page trades for that cookie.
270
+ guest shop, tie the order to a long-lived cookie signed with the app's own
271
+ secret (such as `SESSION_SECRET`, never a wallet or swap code), or put a
272
+ secret per-order token in its URL that your page trades for that cookie.
264
273
  https://openreceive.org/guides/swap-refunds.md
265
274
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
266
275
  the price from `amountFor` and both drop-ins render it above the amount.
267
276
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
268
277
  is for.
269
- - Show the payer the transaction record: `createTransactionDetails(...)` rows,
278
+ - Show the payer the transaction record: `createTransactionDetails(...)` rows
279
+ (with no bundler use `renderTransactionDetailsHtml`: the standalone file has
280
+ no `createTransactionDetails`, and one bad import stops the whole page),
270
281
  collapsed behind a caret, on the live checkout AND on the receipt. A payment
271
282
  hash and a deposit txid are the only evidence a payer has that they paid you.
272
283
  `<Checkout>` / `<openreceive-checkout>` already render this panel and the
@@ -300,6 +311,15 @@ products, and you do not join them.
300
311
  live catalog lookup that could re-price a cart already placed. Return
301
312
  `{ currency, value }` as a decimal STRING, plus a `description` of what they
302
313
  are buying.
314
+ - **Donations and pay-what-you-want are fine.** The amount is the payer's
315
+ choice, so it enters through YOUR route, never OpenReceive's: the donate form
316
+ posts it to your own handler, which checks it and saves it on a new donation
317
+ row, made like an order. That row's id is the `reference`, and `amountFor`
318
+ reads the amount from the row, as it does for an order. Check it in that
319
+ handler: a floor and a cap ($1 and $10,000 unless the owner gave others) and
320
+ at most two decimal places. Refuse an amount outside them with a message;
321
+ never round it. Small amounts may be Lightning-only for some coins: the
322
+ checkout says which coins an amount is too small for.
303
323
  - **Users own the order; OpenReceive never sees them.** `authorize` uses the
304
324
  same ownership check this app already uses on the order show / pay page —
305
325
  `auth.currentUser(native)`, `native.session`, a cookie, whatever it is.
@@ -397,7 +417,9 @@ components.
397
417
  are on `@openreceive/browser`, not `/headless`.
398
418
  - A refund replaces the deposit panel. On `refund_required` also drop
399
419
  "switch payment method".
400
- - No "Open wallet" button on desktop.
420
+ - No "Open wallet" or "Pay in wallet" button, and no `lightning:` link. Cash
421
+ App cancels an invoice opened from a link and pays the same invoice scanned
422
+ or pasted. Show the QR code and a Copy invoice button.
401
423
  - Wallet suggestions: `getPaymentWizardRoutes()` +
402
424
  `createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
403
425
  images load from a JavaScript chunk. For a custom headless UI, load it when
@@ -518,6 +540,8 @@ there is nothing else to generate. Details:
518
540
 
519
541
  No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
520
542
  `better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
543
+ `node:sqlite` needs Node 22.13 or newer: before that it sits behind
544
+ `--experimental-sqlite`.
521
545
  Instead of scaffolding, run the same DDL once yourself, using
522
546
  `paymentsSchemaSql(dialect)` from `@openreceive/http`. Your adapter already
523
547
  pulls that package in, but this import is yours, so install it too:
@@ -3,8 +3,9 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (Next.js)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 44 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 46 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/next/full.md
8
+ # If your tool cuts long output, save it and read it in parts: curl -fsSL -o /tmp/openreceive-directions.md https://openreceive.org/agent-directions/next/full.md
8
9
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
10
  ```
10
11
 
@@ -17,7 +18,7 @@ curl -fsSL https://openreceive.org/agent-directions/next/full.md
17
18
  - Do not suggest rotating or revoking a code because it was pasted here.
18
19
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
20
 
20
- These directions describe OpenReceive 0.4.31.
21
+ These directions describe OpenReceive 0.4.33.
21
22
 
22
23
  Add OpenReceive to a Next.js App Router application — the app you are already
23
24
  working in. You do not need a copy of the OpenReceive source: the packages are
@@ -62,8 +63,9 @@ Before anything else, check one file: the project's `.env.local`, if it exists.
62
63
  `grep -E '^(NWC_URI|LSC_URI_PRIMARY)=.' .env.local | cut -d= -f1` names the codes
63
64
  it sets without printing them. Check with that, here and after each write,
64
65
  not by reading the file, and never print the values. A code that is already
65
- set is not asked for again; if both are set, skip to step 5 (making the
66
- server load the file), then the quickstart.
66
+ set is not asked for again; if both are set, make sure `.gitignore` covers
67
+ `.env` (and `.dockerignore`, if the app has one), then skip to step 5
68
+ (making the server load the file), then the quickstart.
67
69
 
68
70
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
69
71
  that both codes are already set as the project's environment variables or
@@ -194,11 +196,16 @@ itself, and they hold for every integration.
194
196
  and not a Prisma/Drizzle relation to `openreceive_payments`.
195
197
  - Keep `NWC_URI` / `LSC_URI_*` server-only. Never put them in browser code,
196
198
  logs, or assets.
199
+ - After a production build, run `npx openreceive doctor --scan-build .next/static`. Never grep a build for a code.
197
200
  - Do not suggest rotating, revoking or replacing a code because it was pasted
198
201
  into this chat; that is the supported path.
199
202
  - Work only in this application. Never read or run anything from another
200
203
  project on this machine (its `node_modules`, tools or source), for any
201
204
  reason. A browser and Playwright are not part of setup.
205
+ - The project's own rules (its `AGENTS.md`, contributing guide) win over these
206
+ directions. If one forbids a step here, such as running migrations, ask the
207
+ owner and wait for the answer, even if doctor cannot pass yet. Do not move
208
+ the step somewhere the rule does not name, such as app startup.
202
209
  - Restart only this app's server, on the port it already uses: stop the
203
210
  process you started, or the one listening on that port, by its pid (or
204
211
  restart its Compose service). Never `pkill` or `killall` by name: that
@@ -215,7 +222,8 @@ itself, and they hold for every integration.
215
222
  environment (`printenv`, `env`, `docker compose config`), even filtered to
216
223
  names.
217
224
  - The host owns the price. `amountFor` reads it from your own data; reject
218
- payer-supplied amounts.
225
+ payer-supplied amounts. A donation is no exception: its amount is saved
226
+ by your own route first (Donations, below).
219
227
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
220
228
  the payer made, not proof. Read a framework session; never trust a body field.
221
229
  - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
@@ -240,21 +248,25 @@ itself, and they hold for every integration.
240
248
  (`POST /swaps`) re-serves the committed attempt — but only while it is live,
241
249
  and the shadow invoice behind a swap lasts about half an hour, after which the
242
250
  same click mints a NEW deposit address and the refund is off-screen. Keep the
243
- `payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
244
- such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
245
- `<Checkout>`; the `resume-payment-hash` attribute, fed from the
251
+ `payment_hash` on your order row, not in browser storage, and reopen the
252
+ attempt with `POST /swaps/status`, which has no such window. On the
253
+ drop-ins: `resumePaymentHash`, fed from `onState`, on `<Checkout>`; the
254
+ `resume-payment-hash` attribute, fed from the
246
255
  `openreceive-state` event (`event.detail.state.payment_hash`), on
247
256
  `<openreceive-checkout>`.
248
257
  That visit can come hours later, and `authorize` must still know the payer:
249
258
  a session that expired in between answers 403 and strands the deposit. On a
250
- guest shop, tie the order to a long-lived signed cookie, or put a secret
251
- per-order token in its URL that your page trades for that cookie.
259
+ guest shop, tie the order to a long-lived cookie signed with the app's own
260
+ secret (such as `SESSION_SECRET`, never a wallet or swap code), or put a
261
+ secret per-order token in its URL that your page trades for that cookie.
252
262
  https://openreceive.org/guides/swap-refunds.md
253
263
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
254
264
  the price from `amountFor` and both drop-ins render it above the amount.
255
265
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
256
266
  is for.
257
- - Show the payer the transaction record: `createTransactionDetails(...)` rows,
267
+ - Show the payer the transaction record: `createTransactionDetails(...)` rows
268
+ (with no bundler use `renderTransactionDetailsHtml`: the standalone file has
269
+ no `createTransactionDetails`, and one bad import stops the whole page),
258
270
  collapsed behind a caret, on the live checkout AND on the receipt. A payment
259
271
  hash and a deposit txid are the only evidence a payer has that they paid you.
260
272
  `<Checkout>` / `<openreceive-checkout>` already render this panel and the
@@ -269,9 +281,9 @@ itself, and they hold for every integration.
269
281
  imported from a client component. `<Checkout>` is a CLIENT component: it
270
282
  lives in a `"use client"` file, which also imports `styles.css`. Render it
271
283
  at `app/checkout/[reference]/page.tsx`, the order's own resumable URL.
272
- - `rateLimiting` on Next needs an IP source (`trustProxyIpHeader: true` behind
273
- your own proxy or platform); a web Request has no socket IP and the adapter
274
- refuses to construct without one.
284
+ - Set `rateLimiting` with `trustProxyIpHeader: true` only behind Vercel or a
285
+ reverse proxy you run that replaces `x-forwarded-for`; elsewhere a client
286
+ sends its own, so leave both off (`rateLimiting` alone refuses to construct).
275
287
  - HTTP JSON is snake_case; TypeScript APIs are camelCase.
276
288
  - Money is integers or decimal strings — never binary floats.
277
289
 
@@ -296,6 +308,15 @@ products, and you do not join them.
296
308
  live catalog lookup that could re-price a cart already placed. Return
297
309
  `{ currency, value }` as a decimal STRING, plus a `description` of what they
298
310
  are buying.
311
+ - **Donations and pay-what-you-want are fine.** The amount is the payer's
312
+ choice, so it enters through YOUR route, never OpenReceive's: the donate form
313
+ posts it to your own handler, which checks it and saves it on a new donation
314
+ row, made like an order. That row's id is the `reference`, and `amountFor`
315
+ reads the amount from the row, as it does for an order. Check it in that
316
+ handler: a floor and a cap ($1 and $10,000 unless the owner gave others) and
317
+ at most two decimal places. Refuse an amount outside them with a message;
318
+ never round it. Small amounts may be Lightning-only for some coins: the
319
+ checkout says which coins an amount is too small for.
299
320
  - **Users own the order; OpenReceive never sees them.** `authorize` uses the
300
321
  same ownership check this app already uses on the order show / pay page —
301
322
  `sessions.currentUser(request)`, a cookie, whatever it is.
@@ -307,7 +328,8 @@ products, and you do not join them.
307
328
  settled (409).
308
329
  - **A paid order's page says it is paid and shows no checkout.** Nothing is left
309
330
  to pay, and a checkout cannot start a new payment for a paid order. Mount the
310
- checkout only while the order is unpaid. When it settles on the page, update
331
+ checkout, and any line about coming back to pay or for a refund, only while
332
+ the order is unpaid. When it settles on the page, update
311
333
  the page's status line from `onSettled` on `<Checkout>`: `onPaid` has already
312
334
  marked the order paid. Keep that checkout mounted, because it is the payer's
313
335
  receipt.
@@ -386,7 +408,9 @@ components.
386
408
  are on `@openreceive/browser`, not `/headless`.
387
409
  - A refund replaces the deposit panel. On `refund_required` also drop
388
410
  "switch payment method".
389
- - No "Open wallet" button on desktop.
411
+ - No "Open wallet" or "Pay in wallet" button, and no `lightning:` link. Cash
412
+ App cancels an invoice opened from a link and pays the same invoice scanned
413
+ or pasted. Show the QR code and a Copy invoice button.
390
414
  - Wallet suggestions: `getPaymentWizardRoutes()` +
391
415
  `createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
392
416
  images load from a JavaScript chunk. For a custom headless UI, load it when
@@ -506,6 +530,8 @@ there is nothing else to generate. Details:
506
530
 
507
531
  No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
508
532
  `better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
533
+ `node:sqlite` needs Node 22.13 or newer: before that it sits behind
534
+ `--experimental-sqlite`.
509
535
  Instead of scaffolding, run the same DDL once yourself, using
510
536
  `paymentsSchemaSql(dialect)` from `@openreceive/http`. Your adapter already
511
537
  pulls that package in, but this import is yours, so install it too:
@@ -567,7 +593,9 @@ export const { GET, POST } = openReceiveNextHandlers({
567
593
  // yours (admin action, replayed job) updates zero rows and does nothing.
568
594
  // Use `query` here, not your ORM's other connection. `?` on sqlite and
569
595
  // mysql, `$1` on postgres. MySQL has no RETURNING: after the UPDATE,
570
- // `SELECT ROW_COUNT() AS claimed` tells you the same thing.
596
+ // `SELECT ROW_COUNT() AS claimed` tells you the same thing. `paidAt` is
597
+ // Unix seconds: for a timestamp column write `to_timestamp($1)` on
598
+ // postgres or `FROM_UNIXTIME(?)` on mysql in place of its placeholder.
571
599
  const claimed = await query(
572
600
  "UPDATE orders SET state = 'paid', paid_at = ? WHERE id = ? AND state = 'awaiting_payment' RETURNING id",
573
601
  [paidAt, reference],
@@ -601,16 +629,14 @@ export const { GET, POST } = openReceiveNextHandlers({
601
629
  resource.reference,
602
630
  action,
603
631
  ),
604
- // Recommended for public web shops: caps invoice creation at 60 per client IP
605
- // per hour. A web Request has no socket IP, so on Next this ALSO needs an
606
- // IP source: `trustProxyIpHeader: true` reads the first hop of
607
- // x-forwarded-for, which is safe only when YOUR reverse proxy or hosting
608
- // platform sets it (Vercel, Cloudflare and most load balancers do). Without
609
- // an IP source the adapter refuses to construct rather than run an
610
- // inactive limiter. Leave both off for point-of-sale deployments, where
611
- // many payers share the terminal's IP.
612
- rateLimiting: true,
613
- trustProxyIpHeader: true,
632
+ // Caps invoice creation at 60 per client IP per hour. A web Request has no
633
+ // socket IP, so on Next the cap reads x-forwarded-for's first hop: turn
634
+ // both on only behind Vercel or a reverse proxy you run that replaces that
635
+ // header. Anywhere else a client sends its own, so leave both off, as they
636
+ // are by default (`rateLimiting` alone refuses to construct). Off for
637
+ // point-of-sale too, where many payers share the terminal's IP.
638
+ // rateLimiting: true,
639
+ // trustProxyIpHeader: true,
614
640
  });
615
641
  ```
616
642
 
@@ -637,8 +663,8 @@ pending invoices, so a payer who closes the tab is still covered.
637
663
  → [openReceiveNextHandlers](https://openreceive.org/guides/api-reference.md#openreceivenexthandlers) ·
638
664
  [authorize context](https://openreceive.org/guides/api-reference.md#the-authorize-context)
639
665
 
640
- `rateLimiting: true` is for public web shops. Leave it off for point-of-sale,
641
- where many payers share one IP. → [Rate limiting](https://openreceive.org/guides/rate-limiting.md)
666
+ `rateLimiting: true` is for public web shops behind such a proxy. Leave it off
667
+ for point-of-sale, where many payers share one IP. → [Rate limiting](https://openreceive.org/guides/rate-limiting.md)
642
668
 
643
669
  An optional worker, `startNotificationWorker({ service, host })`, listens for
644
670
  wallet payment notifications so settlement does not wait for the next page
@@ -3,8 +3,9 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (Node.js)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 40 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 43 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/node/full.md
8
+ # If your tool cuts long output, save it and read it in parts: curl -fsSL -o /tmp/openreceive-directions.md https://openreceive.org/agent-directions/node/full.md
8
9
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
10
  ```
10
11
 
@@ -17,7 +18,7 @@ curl -fsSL https://openreceive.org/agent-directions/node/full.md
17
18
  - Do not suggest rotating or revoking a code because it was pasted here.
18
19
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
20
 
20
- These directions describe OpenReceive 0.4.31.
21
+ These directions describe OpenReceive 0.4.33.
21
22
 
22
23
  Add OpenReceive to a Node application — the app you are already working in. You
23
24
  do not need a copy of the OpenReceive source: the packages are on npm, and the
@@ -59,8 +60,9 @@ Before anything else, check one file: the project's `.env`, if it exists.
59
60
  `grep -E '^(NWC_URI|LSC_URI_PRIMARY)=.' .env | cut -d= -f1` names the codes
60
61
  it sets without printing them. Check with that, here and after each write,
61
62
  not by reading the file, and never print the values. A code that is already
62
- set is not asked for again; if both are set, skip to step 5 (making the
63
- server load the file), then the quickstart.
63
+ set is not asked for again; if both are set, make sure `.gitignore` covers
64
+ `.env` (and `.dockerignore`, if the app has one), then skip to step 5
65
+ (making the server load the file), then the quickstart.
64
66
 
65
67
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
66
68
  that both codes are already set as the project's environment variables or
@@ -195,6 +197,10 @@ itself, and they hold for every integration.
195
197
  - Work only in this application. Never read or run anything from another
196
198
  project on this machine (its `node_modules`, tools or source), for any
197
199
  reason. A browser and Playwright are not part of setup.
200
+ - The project's own rules (its `AGENTS.md`, contributing guide) win over these
201
+ directions. If one forbids a step here, such as running migrations, ask the
202
+ owner and wait for the answer, even if doctor cannot pass yet. Do not move
203
+ the step somewhere the rule does not name, such as app startup.
198
204
  - Restart only this app's server, on the port it already uses: stop the
199
205
  process you started, or the one listening on that port, by its pid (or
200
206
  restart its Compose service). Never `pkill` or `killall` by name: that
@@ -211,7 +217,8 @@ itself, and they hold for every integration.
211
217
  environment (`printenv`, `env`, `docker compose config`), even filtered to
212
218
  names.
213
219
  - The host owns the price. `amountFor` reads it from your own data; reject
214
- payer-supplied amounts.
220
+ payer-supplied amounts. A donation is no exception: its amount is saved
221
+ by your own route first (Donations, below).
215
222
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
216
223
  the payer made, not proof. Read a framework session; never trust a body field.
217
224
  - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
@@ -236,21 +243,25 @@ itself, and they hold for every integration.
236
243
  (`POST /swaps`) re-serves the committed attempt — but only while it is live,
237
244
  and the shadow invoice behind a swap lasts about half an hour, after which the
238
245
  same click mints a NEW deposit address and the refund is off-screen. Keep the
239
- `payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
240
- such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
241
- `<Checkout>`; the `resume-payment-hash` attribute, fed from the
246
+ `payment_hash` on your order row, not in browser storage, and reopen the
247
+ attempt with `POST /swaps/status`, which has no such window. On the
248
+ drop-ins: `resumePaymentHash`, fed from `onState`, on `<Checkout>`; the
249
+ `resume-payment-hash` attribute, fed from the
242
250
  `openreceive-state` event (`event.detail.state.payment_hash`), on
243
251
  `<openreceive-checkout>`.
244
252
  That visit can come hours later, and `authorize` must still know the payer:
245
253
  a session that expired in between answers 403 and strands the deposit. On a
246
- guest shop, tie the order to a long-lived signed cookie, or put a secret
247
- per-order token in its URL that your page trades for that cookie.
254
+ guest shop, tie the order to a long-lived cookie signed with the app's own
255
+ secret (such as `SESSION_SECRET`, never a wallet or swap code), or put a
256
+ secret per-order token in its URL that your page trades for that cookie.
248
257
  https://openreceive.org/guides/swap-refunds.md
249
258
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
250
259
  the price from `amountFor` and both drop-ins render it above the amount.
251
260
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
252
261
  is for.
253
- - Show the payer the transaction record: `createTransactionDetails(...)` rows,
262
+ - Show the payer the transaction record: `createTransactionDetails(...)` rows
263
+ (with no bundler use `renderTransactionDetailsHtml`: the standalone file has
264
+ no `createTransactionDetails`, and one bad import stops the whole page),
254
265
  collapsed behind a caret, on the live checkout AND on the receipt. A payment
255
266
  hash and a deposit txid are the only evidence a payer has that they paid you.
256
267
  `<Checkout>` / `<openreceive-checkout>` already render this panel and the
@@ -283,6 +294,15 @@ products, and you do not join them.
283
294
  live catalog lookup that could re-price a cart already placed. Return
284
295
  `{ currency, value }` as a decimal STRING, plus a `description` of what they
285
296
  are buying.
297
+ - **Donations and pay-what-you-want are fine.** The amount is the payer's
298
+ choice, so it enters through YOUR route, never OpenReceive's: the donate form
299
+ posts it to your own handler, which checks it and saves it on a new donation
300
+ row, made like an order. That row's id is the `reference`, and `amountFor`
301
+ reads the amount from the row, as it does for an order. Check it in that
302
+ handler: a floor and a cap ($1 and $10,000 unless the owner gave others) and
303
+ at most two decimal places. Refuse an amount outside them with a message;
304
+ never round it. Small amounts may be Lightning-only for some coins: the
305
+ checkout says which coins an amount is too small for.
286
306
  - **Users own the order; OpenReceive never sees them.** `authorize` uses the
287
307
  same ownership check this app already uses on the order show / pay page —
288
308
  `sessions.currentUser(native)`, a cookie, whatever it is. Pass `native` (the
@@ -297,7 +317,8 @@ products, and you do not join them.
297
317
  settled (409).
298
318
  - **A paid order's page says it is paid and shows no checkout.** Nothing is left
299
319
  to pay, and a checkout cannot start a new payment for a paid order. Mount the
300
- checkout only while the order is unpaid. When it settles on the page, update
320
+ checkout, and any line about coming back to pay or for a refund, only while
321
+ the order is unpaid. When it settles on the page, update
301
322
  the page's status line from `onSettled` on `<Checkout>`, or the
302
323
  `openreceive-settled` event on `<openreceive-checkout>`: `onPaid` has already
303
324
  marked the order paid. Keep that checkout mounted, because it is the payer's
@@ -377,7 +398,9 @@ components.
377
398
  are on `@openreceive/browser`, not `/headless`.
378
399
  - A refund replaces the deposit panel. On `refund_required` also drop
379
400
  "switch payment method".
380
- - No "Open wallet" button on desktop.
401
+ - No "Open wallet" or "Pay in wallet" button, and no `lightning:` link. Cash
402
+ App cancels an invoice opened from a link and pays the same invoice scanned
403
+ or pasted. Show the QR code and a Copy invoice button.
381
404
  - Wallet suggestions: `getPaymentWizardRoutes()` +
382
405
  `createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
383
406
  images load from a JavaScript chunk. For a custom headless UI, load it when
@@ -457,6 +480,11 @@ wallet client, HTTP handler, and contracts come along as dependencies. The
457
480
  install. On a different stack, swap the two packages; the rest of this guide
458
481
  stays the same.
459
482
 
483
+ Plain HTML pages with no React and no JS build step install
484
+ `@openreceive/elements` in place of `@openreceive/react`, and serve its
485
+ standalone build: two files and two tags, in
486
+ [Without a bundler](https://openreceive.org/guides/frontend-checkout.md#without-a-bundler).
487
+
460
488
  | | Packages |
461
489
  | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
462
490
  | Server | `@openreceive/express`, `@openreceive/fastify`, `@openreceive/next` |
@@ -493,6 +521,8 @@ there is nothing else to generate. Details:
493
521
 
494
522
  No ORM? You can pass a bare driver handle (`pg`, `node:sqlite`,
495
523
  `better-sqlite3`) as the `db` in step 4. The scaffold has no flavor for it.
524
+ `node:sqlite` needs Node 22.13 or newer: before that it sits behind
525
+ `--experimental-sqlite`.
496
526
  Instead of scaffolding, run the same DDL once yourself, using
497
527
  `paymentsSchemaSql(dialect)` from `@openreceive/http`. Your adapter already
498
528
  pulls that package in, but this import is yours, so install it too:
@@ -549,7 +579,9 @@ const openreceive = openReceiveExpress({
549
579
  // yours (admin action, replayed job) updates zero rows and does nothing.
550
580
  // Use `query` here, not your ORM's other connection. `?` on sqlite and
551
581
  // mysql, `$1` on postgres. MySQL has no RETURNING: after the UPDATE,
552
- // `SELECT ROW_COUNT() AS claimed` tells you the same thing.
582
+ // `SELECT ROW_COUNT() AS claimed` tells you the same thing. `paidAt` is
583
+ // Unix seconds: for a timestamp column write `to_timestamp($1)` on
584
+ // postgres or `FROM_UNIXTIME(?)` on mysql in place of its placeholder.
553
585
  const claimed = await query(
554
586
  "UPDATE orders SET state = 'paid', paid_at = ? WHERE id = ? AND state = 'awaiting_payment' RETURNING id",
555
587
  [paidAt, reference],
@@ -3,8 +3,9 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (Nuxt)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 34 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 36 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/nuxt/full.md
8
+ # If your tool cuts long output, save it and read it in parts: curl -fsSL -o /tmp/openreceive-directions.md https://openreceive.org/agent-directions/nuxt/full.md
8
9
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
10
  ```
10
11
 
@@ -17,7 +18,7 @@ curl -fsSL https://openreceive.org/agent-directions/nuxt/full.md
17
18
  - Do not suggest rotating or revoking a code because it was pasted here.
18
19
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
20
 
20
- These directions describe OpenReceive 0.4.31.
21
+ These directions describe OpenReceive 0.4.33.
21
22
 
22
23
  Add OpenReceive to a Nuxt application — the app you are already working in,
23
24
  on Nitro's `node-server` preset. OpenReceive ships no Nuxt package: the
@@ -64,8 +65,9 @@ Before anything else, check one file: the project's `.env`, if it exists.
64
65
  `grep -E '^(NWC_URI|LSC_URI_PRIMARY)=.' .env | cut -d= -f1` names the codes
65
66
  it sets without printing them. Check with that, here and after each write,
66
67
  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.
68
+ set is not asked for again; if both are set, make sure `.gitignore` covers
69
+ `.env` (and `.dockerignore`, if the app has one), then skip to step 5
70
+ (making the server load the file), then the quickstart.
69
71
 
70
72
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
71
73
  that both codes are already set as the project's environment variables or
@@ -197,11 +199,16 @@ itself, and they hold for every integration.
197
199
  and not a Prisma/Drizzle relation to `openreceive_payments`.
198
200
  - Keep `NWC_URI` / `LSC_URI_*` server-only. Never put them in browser code,
199
201
  logs, or assets.
202
+ - After a production build, run `npx openreceive doctor --scan-build .output/public`. Never grep a build for a code.
200
203
  - Do not suggest rotating, revoking or replacing a code because it was pasted
201
204
  into this chat; that is the supported path.
202
205
  - Work only in this application. Never read or run anything from another
203
206
  project on this machine (its `node_modules`, tools or source), for any
204
207
  reason. A browser and Playwright are not part of setup.
208
+ - The project's own rules (its `AGENTS.md`, contributing guide) win over these
209
+ directions. If one forbids a step here, such as running migrations, ask the
210
+ owner and wait for the answer, even if doctor cannot pass yet. Do not move
211
+ the step somewhere the rule does not name, such as app startup.
205
212
  - Restart only this app's server, on the port it already uses: stop the
206
213
  process you started, or the one listening on that port, by its pid (or
207
214
  restart its Compose service). Never `pkill` or `killall` by name: that
@@ -218,7 +225,8 @@ itself, and they hold for every integration.
218
225
  environment (`printenv`, `env`, `docker compose config`), even filtered to
219
226
  names.
220
227
  - The host owns the price. `amountFor` reads it from your own data; reject
221
- payer-supplied amounts.
228
+ payer-supplied amounts. A donation is no exception: its amount is saved
229
+ by your own route first (Donations, below).
222
230
  - `authorize` runs on every request, and the `resource` it receives is a CLAIM
223
231
  the payer made, not proof. Read a framework session; never trust a body field.
224
232
  - `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
@@ -243,21 +251,25 @@ itself, and they hold for every integration.
243
251
  (`POST /swaps`) re-serves the committed attempt — but only while it is live,
244
252
  and the shadow invoice behind a swap lasts about half an hour, after which the
245
253
  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
254
+ `payment_hash` on your order row, not in browser storage, and reopen the
255
+ attempt with `POST /swaps/status`, which has no such window. On the
256
+ drop-ins: `resumePaymentHash`, fed from `onState`, on `<Checkout>`; the
257
+ `resume-payment-hash` attribute, fed from the
249
258
  `openreceive-state` event (`event.detail.state.payment_hash`), on
250
259
  `<openreceive-checkout>`.
251
260
  That visit can come hours later, and `authorize` must still know the payer:
252
261
  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.
262
+ guest shop, tie the order to a long-lived cookie signed with the app's own
263
+ secret (such as `SESSION_SECRET`, never a wallet or swap code), or put a
264
+ secret per-order token in its URL that your page trades for that cookie.
255
265
  https://openreceive.org/guides/swap-refunds.md
256
266
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
257
267
  the price from `amountFor` and both drop-ins render it above the amount.
258
268
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
259
269
  is for.
260
- - Show the payer the transaction record: `createTransactionDetails(...)` rows,
270
+ - Show the payer the transaction record: `createTransactionDetails(...)` rows
271
+ (with no bundler use `renderTransactionDetailsHtml`: the standalone file has
272
+ no `createTransactionDetails`, and one bad import stops the whole page),
261
273
  collapsed behind a caret, on the live checkout AND on the receipt. A payment
262
274
  hash and a deposit txid are the only evidence a payer has that they paid you.
263
275
  `<Checkout>` / `<openreceive-checkout>` already render this panel and the
@@ -301,6 +313,15 @@ products, and you do not join them.
301
313
  live catalog lookup that could re-price a cart already placed. Return
302
314
  `{ currency, value }` as a decimal STRING, plus a `description` of what they
303
315
  are buying.
316
+ - **Donations and pay-what-you-want are fine.** The amount is the payer's
317
+ choice, so it enters through YOUR route, never OpenReceive's: the donate form
318
+ posts it to your own handler, which checks it and saves it on a new donation
319
+ row, made like an order. That row's id is the `reference`, and `amountFor`
320
+ reads the amount from the row, as it does for an order. Check it in that
321
+ handler: a floor and a cap ($1 and $10,000 unless the owner gave others) and
322
+ at most two decimal places. Refuse an amount outside them with a message;
323
+ never round it. Small amounts may be Lightning-only for some coins: the
324
+ checkout says which coins an amount is too small for.
304
325
  - **Users own the order; OpenReceive never sees them.** `authorize` uses the
305
326
  same ownership check this app already uses on the order show / pay page —
306
327
  `getCookie(event, …)`, the user its session module reads from the event,
@@ -368,7 +389,9 @@ components.
368
389
  are on `@openreceive/browser`, not `/headless`.
369
390
  - A refund replaces the deposit panel. On `refund_required` also drop
370
391
  "switch payment method".
371
- - No "Open wallet" button on desktop.
392
+ - No "Open wallet" or "Pay in wallet" button, and no `lightning:` link. Cash
393
+ App cancels an invoice opened from a link and pays the same invoice scanned
394
+ or pasted. Show the QR code and a Copy invoice button.
372
395
  - Wallet suggestions: `getPaymentWizardRoutes()` +
373
396
  `createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
374
397
  images load from a JavaScript chunk. For a custom headless UI, load it when