@openreceive/react 0.4.14 → 0.4.17
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.
- package/README.md +11 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +12 -6
- package/package.json +3 -4
- package/skills/debug-openreceive-payment/SKILL.md +0 -97
- package/skills/integrate-openreceive/SKILL.md +0 -139
- package/skills/integrate-openreceive/references/btcpay.md +0 -224
- package/skills/integrate-openreceive/references/django.md +0 -745
- package/skills/integrate-openreceive/references/fastapi.md +0 -619
- package/skills/integrate-openreceive/references/fastify.md +0 -615
- package/skills/integrate-openreceive/references/laravel.md +0 -749
- package/skills/integrate-openreceive/references/next.md +0 -660
- package/skills/integrate-openreceive/references/node.md +0 -588
- package/skills/integrate-openreceive/references/php.md +0 -682
- package/skills/integrate-openreceive/references/rails.md +0 -698
- package/skills/integrate-openreceive/references/woocommerce.md +0 -193
|
@@ -1,682 +0,0 @@
|
|
|
1
|
-
# OpenReceive agent directions (PHP)
|
|
2
|
-
|
|
3
|
-
These directions describe OpenReceive 0.4.14.
|
|
4
|
-
|
|
5
|
-
Add OpenReceive to a PHP application — the app you are already working in. You
|
|
6
|
-
do not need a copy of the OpenReceive source: the engine is on Packagist
|
|
7
|
-
(`openreceive/openreceive`), the checkout UI is a tarball on every GitHub
|
|
8
|
-
release, and the quickstart is appended to this file in full, so you can do the
|
|
9
|
-
whole integration without fetching anything. Prefer the published package and
|
|
10
|
-
the PSR-15 handler it ships — do not reimplement wallet RPC, settlement, or
|
|
11
|
-
pricing.
|
|
12
|
-
|
|
13
|
-
Do not clone the OpenReceive repository into this app, and do not copy a demo's
|
|
14
|
-
models (`shop_orders`, a signed-cookie visitor, a SQLite catalog) over tables
|
|
15
|
-
that already exist. Find this application's order, product, and user models —
|
|
16
|
-
whatever they are actually named — and map the three hooks onto those.
|
|
17
|
-
|
|
18
|
-
Keep this application's router, its session/authentication and its database.
|
|
19
|
-
The engine is framework-free: it wants a PDO handle, one object with three
|
|
20
|
-
methods, and a place in your front controller (or middleware stack) to dispatch
|
|
21
|
-
`/openreceive/*` to its PSR-15 handler. If this app runs Laravel, use the
|
|
22
|
-
`openreceive/laravel` adapter and its own directions instead of this page.
|
|
23
|
-
Reuse the app's existing session or cookie in `authorize` and the PDO it
|
|
24
|
-
already opens in `PdoConnection`.
|
|
25
|
-
|
|
26
|
-
## What OpenReceive is
|
|
27
|
-
|
|
28
|
-
A payment library that runs inside YOUR server. It mounts HTTP routes in the
|
|
29
|
-
application you are editing, issues Lightning invoices against a wallet the
|
|
30
|
-
merchant already controls, and calls back into your code when one settles. There
|
|
31
|
-
is no OpenReceive account and no API key, and OpenReceive never holds the funds —
|
|
32
|
-
the sats land in the wallet the merchant connected.
|
|
33
|
-
|
|
34
|
-
The one required credential is a receive-only NWC code (Nostr Wallet Connect):
|
|
35
|
-
a string from the merchant's wallet that can create invoices and read their
|
|
36
|
-
status, and cannot spend. A swap provider (an "LSC" code) optionally lets the
|
|
37
|
-
payer send USDT, USDC, ETH or SOL instead, converted into that same
|
|
38
|
-
Lightning payment. Step 0 collects those credentials from the user; you write three hooks — `authorize`,
|
|
39
|
-
`amountFor`, `onPaid` on one `OpenReceive\Host`;
|
|
40
|
-
OpenReceive supplies invoices, polling, settlement and the checkout UI. It never
|
|
41
|
-
owns orders, users, prices, or fulfillment.
|
|
42
|
-
|
|
43
|
-
## Step 0 — ask for the two codes, one question at a time
|
|
44
|
-
|
|
45
|
-
Before anything else, look at one file: the project's `.env`, if it exists.
|
|
46
|
-
Read it only far enough to see whether `NWC_URI` and `LSC_URI_PRIMARY` are
|
|
47
|
-
there and non-empty, and never print the values. A code that is already
|
|
48
|
-
set is not asked for again; if both are set, skip to step 5
|
|
49
|
-
(making the server load the file), then the quickstart.
|
|
50
|
-
|
|
51
|
-
Otherwise your next action is a question to the user. Do not run `composer require`,
|
|
52
|
-
edit the app, write `.env.example`, or search anywhere else before asking
|
|
53
|
-
it. Do not read deploy config (compose files, `SetEnv`/`fastcgi_param` blocks, platform secrets), Docker containers, or process environments, and never run
|
|
54
|
-
`printenv`. A new shop has neither code yet: hunting for one burns the turn and
|
|
55
|
-
can leak other secrets into the transcript.
|
|
56
|
-
|
|
57
|
-
Two server-only URIs are needed before the quickstart:
|
|
58
|
-
|
|
59
|
-
- `NWC_URI` — a receive-only Nostr Wallet Connect code,
|
|
60
|
-
`nostr+walletconnect://…`. Required for Bitcoin.
|
|
61
|
-
- `LSC_URI_PRIMARY` — a Lightning Swap Connect URI,
|
|
62
|
-
`lightning+swapconnect://…`. Required for USDT, USDC, ETH and SOL. Skip it
|
|
63
|
-
only when the user says they want Bitcoin alone.
|
|
64
|
-
|
|
65
|
-
The user never edits an environment file. They paste each code into the chat;
|
|
66
|
-
you store it. Ask one question per message.
|
|
67
|
-
|
|
68
|
-
1. **First message — the NWC code, and nothing else.** Ask for it and walk them
|
|
69
|
-
through getting it:
|
|
70
|
-
|
|
71
|
-
> To receive payments I need a receive-only wallet code. In Rizful: open
|
|
72
|
-
> the menu, tap NWC, choose Receive-only NWC code, and tap Copy
|
|
73
|
-
> (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
|
|
74
|
-
> rather run your own wallet, Alby Hub works too: Connections → Add
|
|
75
|
-
> Connection → Read Only. Paste the code here and I will store it.
|
|
76
|
-
|
|
77
|
-
Do not mention `.env`, exports, or "tell me when it's set".
|
|
78
|
-
2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
|
|
79
|
-
ask them to copy the receive-only code again. Otherwise write
|
|
80
|
-
`NWC_URI=<paste>` into the project's `.env`, creating the file if needed.
|
|
81
|
-
Make sure `.gitignore` covers `.env` (and `.dockerignore`, if the app has
|
|
82
|
-
one). Never echo the value, commit it, or put it in client code. Reply only
|
|
83
|
-
that it is saved, then ask the next question.
|
|
84
|
-
3. **Second message — swaps.** If the user already asked for stablecoins or
|
|
85
|
-
altcoins, skip the yes/no and go straight to the walkthrough. Otherwise ask
|
|
86
|
-
whether payers should also be able to pay with USDT, USDC, ETH or SOL. The
|
|
87
|
-
walkthrough:
|
|
88
|
-
|
|
89
|
-
> Go to https://lightning-swap.com, sign in for API keys, create a key, and
|
|
90
|
-
> copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
|
|
91
|
-
> it here and I will store it — or say "Bitcoin only" and I will continue
|
|
92
|
-
> without it.
|
|
93
|
-
|
|
94
|
-
Mention FixedFloat only if they already use it.
|
|
95
|
-
4. **When they paste it.** If it does not start with
|
|
96
|
-
`lightning+swapconnect://`, ask them to copy it again. Otherwise add
|
|
97
|
-
`LSC_URI_PRIMARY=<paste>` to the same `.env`, without echoing it. Swaps
|
|
98
|
-
are now on, so build the refund route back (the swap non-negotiable below) as
|
|
99
|
-
part of this integration. If they chose Bitcoin only, leave
|
|
100
|
-
`LSC_URI_PRIMARY` unset and skip that route.
|
|
101
|
-
5. **Make the server load the file — yourself.** Nothing in PHP
|
|
102
|
-
reads `.env` on its own. Add `vlucas/phpdotenv` and load the file in the
|
|
103
|
-
front controller before `Service::fromEnvironment()`. When the app is started
|
|
104
|
-
with Docker Compose, give the service `env_file: .env`. Restart PHP-FPM or
|
|
105
|
-
the server after writing the file.
|
|
106
|
-
|
|
107
|
-
Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
|
|
108
|
-
saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
|
|
109
|
-
runs the receive-only preflight: if it reports spend methods such as
|
|
110
|
-
`pay_invoice`, remove `NWC_URI` from `.env` and ask for a receive-only code
|
|
111
|
-
again. Never set the spend-capable override to get past it.
|
|
112
|
-
|
|
113
|
-
Then check the PHP runtime: `php -m` must list `gmp`, `sodium`, `mbstring`,
|
|
114
|
-
`json`, `pdo` and one PDO driver. `ext-gmp` is REQUIRED — the NWC transport
|
|
115
|
-
signs every request with it — and `php:*-cli`/`-fpm` images do not ship it
|
|
116
|
-
(`docker-php-ext-install gmp`). PHP must be ≥ 8.2 and 64-bit.
|
|
117
|
-
|
|
118
|
-
### Upgrading an existing install
|
|
119
|
-
|
|
120
|
-
This is not the opening move of a new integration. When OpenReceive is ALREADY
|
|
121
|
-
installed here, `OpenReceive\Server\Doctor::report()` (a plain host runs it
|
|
122
|
-
from the quickstart's `bin/doctor` script) reports every credential as
|
|
123
|
-
set/unset (never the value), the host class and any placeholder hooks, the
|
|
124
|
-
mount, and the wallet preflight. Check the installed `openreceive/openreceive`
|
|
125
|
-
(`composer show openreceive/openreceive`) and the unpacked checkout's
|
|
126
|
-
`MANIFEST.json` against the release named at the top of this file. The two
|
|
127
|
-
must match: the browser build and the engine are one release. Upgrade first —
|
|
128
|
-
and if this app runs in containers, rebuild the images: `vendor/` is baked into
|
|
129
|
-
the image, so an in-place `composer update` is undone by the next
|
|
130
|
-
`compose up`.
|
|
131
|
-
|
|
132
|
-
Only then start the quickstart.
|
|
133
|
-
|
|
134
|
-
## Non-negotiables
|
|
135
|
-
|
|
136
|
-
The quickstart below has the code. These are the rules it cannot state for
|
|
137
|
-
itself, and they hold for every integration.
|
|
138
|
-
|
|
139
|
-
- OpenReceive never owns orders, users, prices, or fulfillment. The section
|
|
140
|
-
below is how those tables sit next to the engine — not a second order model,
|
|
141
|
-
and not a join to `openreceive_payments`.
|
|
142
|
-
- Keep `NWC_URI` / `LSC_URI_*` server-only. Never put them in browser code,
|
|
143
|
-
logs, or assets — and never in a `config.php` that ships in the repository.
|
|
144
|
-
- The host owns the price. `amountFor` reads it from your own data; reject
|
|
145
|
-
payer-supplied amounts.
|
|
146
|
-
- `authorize` runs on every request, and the `resource` it receives is a CLAIM
|
|
147
|
-
the payer made, not proof. Read this app's session or signed cookie from the
|
|
148
|
-
PSR-7 request; never trust a body field. The `Hosts\AllowAllAuthorize` trait
|
|
149
|
-
is a placeholder that allows everything (the engine warns at boot while a
|
|
150
|
-
host uses it) — replace it with this app's real ownership check, same as
|
|
151
|
-
`onPaid`'s `Hosts\LoggingOnPaid`.
|
|
152
|
-
- `onPaid` must be idempotent. Its database fulfillment commits once per `reference` — your order id, one
|
|
153
|
-
per thing you fulfill, created before checkout, kept across retries, never
|
|
154
|
-
reused. A fresh id per page load lets one order be paid twice.
|
|
155
|
-
- Receive-only NWC is required; a spend-capable code fails closed at boot unless
|
|
156
|
-
explicitly overridden.
|
|
157
|
-
- There is NO merchant-initiated refund of a settled Lightning payment, because
|
|
158
|
-
the wallet cannot spend. Swap refunds — a payer reclaiming a deposit that
|
|
159
|
-
never converted — are the only refund OpenReceive performs, and only from the
|
|
160
|
-
`refund_required` provider state. Do not build, promise, or imply a Lightning
|
|
161
|
-
refund path.
|
|
162
|
-
- IF YOU TURN SWAPS ON, BUILD THE ROUTE BACK. A deposit that arrives short or
|
|
163
|
-
late becomes `refund_required`, and the payer claims it on a SECOND VISIT,
|
|
164
|
-
after leaving your page to fetch an address from another wallet. Three things
|
|
165
|
-
must exist or that money is unreachable through your UI: a per-order URL your
|
|
166
|
-
server serves (`/checkout/:reference` — `resumable` on the element), your own
|
|
167
|
-
order-summary route to restore the order from, and the ATTEMPT.
|
|
168
|
-
`/checkouts/prepare` returns no attempts, so a checkout rebuilt from the
|
|
169
|
-
reference alone opens on the method grid. Re-picking the same coin
|
|
170
|
-
(`POST /swaps`) re-serves the committed attempt — but only while it is live,
|
|
171
|
-
and the shadow invoice behind a swap lasts about half an hour, after which the
|
|
172
|
-
same click mints a NEW deposit address and the refund is off-screen. Keep the
|
|
173
|
-
`payment_hash` and reopen the attempt with `POST /swaps/status`, which has no
|
|
174
|
-
such window. On the element: the `resume-payment-hash` attribute, fed from
|
|
175
|
-
the `openreceive-state` event (`event.detail.state.payment_hash`).
|
|
176
|
-
https://openreceive.org/guides/swap-refunds.md
|
|
177
|
-
- Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
|
|
178
|
-
the price from `amountFor` and the drop-in renders it above the amount.
|
|
179
|
-
Without it the checkout is a QR and "$1.00" with no sign of what the dollar
|
|
180
|
-
is for.
|
|
181
|
-
- Show the payer the transaction record: `createTransactionDetails(...)` rows,
|
|
182
|
-
collapsed behind a caret, on the live checkout AND on the receipt. A payment
|
|
183
|
-
hash and a deposit txid are the only evidence a payer has that they paid you.
|
|
184
|
-
`<openreceive-checkout>` already renders this panel and the `description` —
|
|
185
|
-
these two rules cost you code only on a custom UI or your own receipt page,
|
|
186
|
-
never a reason to replace the drop-in. (It returns no rows while the rail is
|
|
187
|
-
`checkout_lock` — before the payer has chosen anything there is no
|
|
188
|
-
transaction — so render the caret only when the rows are non-empty.)
|
|
189
|
-
- HTTP JSON is snake_case; the PHP API uses camelCase methods over snake_case
|
|
190
|
-
array keys, and the browser packages' TypeScript APIs are camelCase.
|
|
191
|
-
- Money is integers or decimal strings — never binary floats. `amountFor`
|
|
192
|
-
returns `'value' => '12.00'`, a string; never `12.00`.
|
|
193
|
-
- PHP starts every request from nothing. The engine is built for that — the
|
|
194
|
-
settlement gate is a row in `openreceive_meta`, not process memory — so do
|
|
195
|
-
not add a cache, a static, or an APCu entry to "remember" the wallet or a
|
|
196
|
-
reconcile timer between requests.
|
|
197
|
-
|
|
198
|
-
## Your tables, not ours
|
|
199
|
-
|
|
200
|
-
`PaymentsSchema::statements($dialect)` renders `openreceive_payments` and
|
|
201
|
-
`openreceive_meta` for THIS application's database; run it through the app's
|
|
202
|
-
own migration tool. That is the whole persistence OpenReceive needs. It does
|
|
203
|
-
not replace your orders, users, or products, and you do not join them.
|
|
204
|
-
|
|
205
|
-
- **Find this app's models first.** They may be named `Order`, `Invoice`,
|
|
206
|
-
`Booking`, `Product`, `Variant`, `User`, `Account` — anything. Wire the hooks
|
|
207
|
-
to those. Do not generate a parallel `ShopOrder` / `ShopProduct` / `ShopUser`
|
|
208
|
-
stack.
|
|
209
|
-
- **The payable row's id is the `reference`.** Create it before checkout, keep
|
|
210
|
-
it across retries, never reuse it. Pass that id to `<openreceive-checkout>`.
|
|
211
|
-
A fresh id per page load lets one order be paid twice.
|
|
212
|
-
- **Products (or the catalog) are the price authority.** Order creation reads
|
|
213
|
-
live prices into the order (snapshot line items if this app has them).
|
|
214
|
-
`amountFor` reads only that order — never a payer-supplied amount, never a
|
|
215
|
-
live catalog lookup that could re-price a cart already placed. Return
|
|
216
|
-
`['currency' => …, 'value' => …]` as a decimal STRING, plus a `description`
|
|
217
|
-
of what they are buying.
|
|
218
|
-
- **Users own the order; OpenReceive never sees them.** `authorize` uses the
|
|
219
|
-
same ownership check this app already uses on the order show / pay page —
|
|
220
|
-
`$_SESSION['user_id']`, a signed cookie, a session library, whatever it is —
|
|
221
|
-
read from `$context->request` (the PSR-7 server request).
|
|
222
|
-
`$context->reference()` is a claim the payer sent, not proof.
|
|
223
|
-
- **The order is unpaid or paid.** Do not copy `pending` / `expired` / `failed`
|
|
224
|
-
/ `attention` onto it. Those are attempt statuses on `openreceive_payments`. An
|
|
225
|
-
expired invoice does not cancel the order; a later checkout may mint another
|
|
226
|
-
attempt. The engine refuses a new checkout under a reference that already
|
|
227
|
-
settled (409).
|
|
228
|
-
- **Pass this app's PDO.** `new SqlPaymentRepository(new PdoConnection($pdo))`
|
|
229
|
-
over the connection the app already opens; do not implement
|
|
230
|
-
`PaymentRepository` unless no PDO can reach this database. `reference` is not
|
|
231
|
-
unique (many attempts per order). Fulfillment is a guarded transition on YOUR
|
|
232
|
-
order row inside `onPaid` — `UPDATE … WHERE state = 'awaiting_payment'` (or
|
|
233
|
-
this app's equivalent) through `$settlement->connection->execute()`, on that
|
|
234
|
-
same settlement transaction, not a second `PDO`. Database writes only in the
|
|
235
|
-
hook; emails, jobs and webhooks after commit — implement `Hosts\AfterPaid`
|
|
236
|
-
for those. Placeholders are positional `?` on every dialect.
|
|
237
|
-
|
|
238
|
-
## If you build your own checkout UI
|
|
239
|
-
|
|
240
|
-
The drop-in (`<openreceive-checkout>`, from the release's standalone tarball or
|
|
241
|
-
`@openreceive/elements`) already obeys all of this. This list is the short form
|
|
242
|
-
of https://openreceive.org/guides/checkout-ux.md, for a UI built on
|
|
243
|
-
`@openreceive/browser/headless`. Read that before writing components.
|
|
244
|
-
|
|
245
|
-
- Check Bitcoin → Switch payment method → Bitcoin: the grid must hide the
|
|
246
|
-
Lightning invoice, then restore the same bolt11 without another mint.
|
|
247
|
-
- `createCheckoutController` is the engine. Do not hand-roll a poll loop.
|
|
248
|
-
- `createCheckoutStatusModel` for the status line. Do not draw a
|
|
249
|
-
Cart → Pay → Done stepper. Read the model's `phase`, not the snapshot's.
|
|
250
|
-
- `resolveWizardSelection` decides whether to ask "which network?". A
|
|
251
|
-
one-network asset starts the swap from the tile. Key `selectedAssetByGroup`
|
|
252
|
-
by group (`USDT`), valued by `pay_in_asset` (`USDT_TRON`).
|
|
253
|
-
- `createMethodGridDisplay` for tiles, including `limitMessage` so an
|
|
254
|
-
unavailable method says the minimum in the payer's currency.
|
|
255
|
-
- `createSwapDisplayModel` → `display.copyRows` for deposits: address, memo,
|
|
256
|
-
and the bare amount each get a copy row. Render `swap.networkWarning*` as
|
|
257
|
-
the model gives it.
|
|
258
|
-
- `swap.deposit_amount` is the only amount a payer is told to send. Never put
|
|
259
|
-
a fiat valuation of it (`swap.fee.pay_in_fiat`) next to a stablecoin amount:
|
|
260
|
-
"$50.03" under "50.05 USDC" reads as a typo, and the payer asks which one to
|
|
261
|
-
send. The one fiat figure on a USDT/USDC deposit panel is the cart total
|
|
262
|
-
(`payout_fiat`); express "you send" and the fee in the token. Use
|
|
263
|
-
`createSwapFeeBreakdown(fee, swap)` — with the swap, not the fee alone — and
|
|
264
|
-
it applies this for you; SOL and ETH keep a fiat breakdown.
|
|
265
|
-
- `createCheckoutSession` owns mint and swap start. To start swaps, pass its
|
|
266
|
-
`swap` option (`selection`, `prefix`, `fetch`) together. Without it
|
|
267
|
-
`startSwap` reports through `onError`.
|
|
268
|
-
- `createQrSvg` is async. Use `createQrSvgController` so you do not render
|
|
269
|
-
`[object Promise]`.
|
|
270
|
-
- `checkoutLabels` for every payer-facing string. Only write copy it lacks.
|
|
271
|
-
- `stageSwapRefund` then `confirmSwapRefund` — only the second submits.
|
|
272
|
-
Validate with `getSwapRefundFormError`. Treat `409` as a normal outcome.
|
|
273
|
-
- Pass `{ resumable: true }` to `createSwapDisplayModel` when the payer has
|
|
274
|
-
a URL they can come back to, and render `display.refundReturnLabel`.
|
|
275
|
-
Resume helpers (`createGuestCheckoutResume`, `createGuestOrderFetcher`)
|
|
276
|
-
are on `@openreceive/browser`, not `/headless`.
|
|
277
|
-
- A refund replaces the deposit panel. On `refund_required` also drop
|
|
278
|
-
"switch payment method".
|
|
279
|
-
- No "Open wallet" button on desktop.
|
|
280
|
-
- Wallet suggestions: `getPaymentWizardRoutes()` +
|
|
281
|
-
`createWizardRouteDisplays`. Lightning only. Logos are data URIs; tutorial
|
|
282
|
-
images load from a JavaScript chunk. For a custom headless UI, load it when
|
|
283
|
-
a tutorial opens and look up the returned table by the tutorial's `path`:
|
|
284
|
-
|
|
285
|
-
```js
|
|
286
|
-
import { loadPayTutorialImages } from "@openreceive/browser/headless";
|
|
287
|
-
|
|
288
|
-
const images = await loadPayTutorialImages();
|
|
289
|
-
const src = images[tutorial.path]; // data URI for the selected tutorial
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Render `src` as the image source and update your UI after loading. Existing
|
|
293
|
-
display objects do not update: their `tutorial.image` stays `undefined` if
|
|
294
|
-
created before loading. Alternatively, await the loader, recreate the displays
|
|
295
|
-
with `createWizardRouteDisplays`, and render the new `tutorial.image`.
|
|
296
|
-
Show the caption while loading or if loading fails; never use an empty image
|
|
297
|
-
source. Deploy all JavaScript chunks and allow `data:` in CSP `img-src`.
|
|
298
|
-
For missing images, check CSP errors, failed chunks, and stale displays.
|
|
299
|
-
Registry paths are lookup keys; there is no asset option or image route.
|
|
300
|
-
|
|
301
|
-
## More documentation
|
|
302
|
-
|
|
303
|
-
Fetch one when the moment comes. Each is raw markdown, so a plain GET is
|
|
304
|
-
enough; drop the `.md` for the same page a person would read.
|
|
305
|
-
|
|
306
|
-
- https://openreceive.org/guides/authorization.md — before you write `authorize`
|
|
307
|
-
- https://openreceive.org/guides/environment-variables.md — every variable, and what is deliberately not one
|
|
308
|
-
- https://openreceive.org/guides/storage.md — the payment tables and the attempt state machine
|
|
309
|
-
- https://openreceive.org/guides/frontend-checkout.md — the drop-in's attributes and slots, and the standalone build
|
|
310
|
-
- https://openreceive.org/guides/checkout-ux.md — read before building any custom UI
|
|
311
|
-
- https://openreceive.org/guides/headless-checkout.md — the controller, the display models, refunds
|
|
312
|
-
- https://openreceive.org/guides/provider-registry.md — where the wallet logos and pay
|
|
313
|
-
tutorials come from: inside the JavaScript, nothing to serve. This is the page
|
|
314
|
-
that owns the image rule, not the summary in checkout-ux.md
|
|
315
|
-
- https://openreceive.org/guides/automated-swaps.md — only if `LSC_URI_PRIMARY` is set
|
|
316
|
-
- https://openreceive.org/guides/swap-refunds.md — the refund flow, and the route back to it. Read it before you turn swaps on
|
|
317
|
-
- https://openreceive.org/guides/lightning-swap-connect.md — what an `LSC_URI_*` code actually is
|
|
318
|
-
- https://openreceive.org/guides/price-feeds.md — where the fiat→sats rate comes from, and how to replace it
|
|
319
|
-
- https://openreceive.org/guides/host-testing.md — testing your three hooks without a live wallet or provider (`OpenReceive\Testing`)
|
|
320
|
-
- https://openreceive.org/guides/rate-limiting.md — before a public shop goes live
|
|
321
|
-
- https://openreceive.org/guides/security.md and https://openreceive.org/guides/deploying.md — before this goes anywhere real
|
|
322
|
-
- https://openreceive.org/guides/api-reference.md — every route, option and error code; the PHP section names every class above
|
|
323
|
-
- https://openreceive.org/guides/custom-checkout-route.md — advanced: replacing the shipped handler's routes with your own
|
|
324
|
-
- https://openreceive.org/guides/react-material-ui-recipe.md — a worked custom UI on a component library
|
|
325
|
-
- https://openreceive.org/guides.md — the index, if what you need is not above
|
|
326
|
-
|
|
327
|
-
Questions, or a problem with the library itself:
|
|
328
|
-
https://openreceive.org/contact
|
|
329
|
-
|
|
330
|
-
- https://openreceive.org/guides/payment-safety-upgrade.md — coordinated upgrades and reviewed repair of existing attempts
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
## The quickstart, in full
|
|
335
|
-
|
|
336
|
-
Inlined verbatim so this file needs no network access — follow it once Step 0
|
|
337
|
-
passes. The page it comes from is https://openreceive.org/guides/quickstart-php.
|
|
338
|
-
|
|
339
|
-
## PHP quickstart (plain PHP)
|
|
340
|
-
|
|
341
|
-
This page is for plain PHP, with no framework: a front controller, a PDO handle
|
|
342
|
-
and three methods. Laravel has its own quickstart (`openreceive/laravel`, the
|
|
343
|
-
thin adapter over this engine).
|
|
344
|
-
|
|
345
|
-
Requires PHP ≥ 8.2 (64-bit) with `ext-gmp`, `ext-sodium`, `ext-mbstring`,
|
|
346
|
-
`ext-json`, `ext-pdo` and one PDO driver (`pdo_pgsql`, `pdo_sqlite` or
|
|
347
|
-
`pdo_mysql`). `ext-gmp` is **required**, not optional. The NWC transport signs
|
|
348
|
-
every wallet request with it.
|
|
349
|
-
|
|
350
|
-
### 1. Install
|
|
351
|
-
|
|
352
|
-
```sh
|
|
353
|
-
composer require openreceive/openreceive nyholm/psr7 nyholm/psr7-server
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
`openreceive/openreceive` is the whole engine. It includes the receive-only
|
|
357
|
-
wallet client, exact money, settlement, the `openreceive_payments` repository
|
|
358
|
-
over PDO, swaps, rates and a PSR-15 handler. It depends only on the PSR
|
|
359
|
-
interfaces, so bring the PSR-7/PSR-17 implementation your app already has.
|
|
360
|
-
`nyholm/psr7` + `nyholm/psr7-server` is the smallest pair, and this page uses
|
|
361
|
-
it.
|
|
362
|
-
|
|
363
|
-
The **checkout UI is not in the Composer package.** Packagist installs from git
|
|
364
|
-
and cannot run a JS build. So the browser side ships separately, as
|
|
365
|
-
`standalone-checkout-<version>.tar.gz` on every
|
|
366
|
-
[GitHub release](https://github.com/openreceive/openreceive/releases). It holds
|
|
367
|
-
one self-contained ES module, its stylesheet, a source map and a
|
|
368
|
-
`MANIFEST.json`. Unpack it somewhere your web server serves static files
|
|
369
|
-
(step 5). If your app has a JS bundler, you can `npm install @openreceive/elements`
|
|
370
|
-
instead. The tarball is the same build.
|
|
371
|
-
|
|
372
|
-
### 2. Migrate the payment tables
|
|
373
|
-
|
|
374
|
-
The engine owns two tables in **your** database and renders their DDL for each
|
|
375
|
-
SQL dialect. Run that DDL through whatever your app uses for schema changes:
|
|
376
|
-
Phinx, Doctrine Migrations, a plain SQL file, or a `bin/migrate` script.
|
|
377
|
-
|
|
378
|
-
```php
|
|
379
|
-
use OpenReceive\Storage\PaymentsSchema;
|
|
380
|
-
|
|
381
|
-
// $dialect is 'pgsql', 'mysql' or 'sqlite' (PDO::ATTR_DRIVER_NAME gives it to you).
|
|
382
|
-
foreach (PaymentsSchema::statements($dialect) as $sql) {
|
|
383
|
-
$pdo->exec($sql);
|
|
384
|
-
}
|
|
385
|
-
// down(): PaymentsSchema::dropStatements()
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
If your script has no migration tool, `PaymentsSchema::migrate(new PdoConnection($pdo))`
|
|
389
|
-
does the same in one call. It creates two tables. Leave both to the library:
|
|
390
|
-
|
|
391
|
-
- `openreceive_payments`: one row per payment attempt.
|
|
392
|
-
- `openreceive_meta`: the reconcile gate and the schema version.
|
|
393
|
-
|
|
394
|
-
Details: [Payment storage](https://openreceive.org/guides/storage.md).
|
|
395
|
-
|
|
396
|
-
### 3. Add wallet credentials
|
|
397
|
-
|
|
398
|
-
Create a server-only `.env`, or export the variables from your process manager.
|
|
399
|
-
The engine reads `getenv()` and `$_ENV`.
|
|
400
|
-
|
|
401
|
-
```dotenv
|
|
402
|
-
NWC_URI=
|
|
403
|
-
LSC_URI_PRIMARY=
|
|
404
|
-
LSC_URI_BACKUP=
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
1. Get a receive-only NWC code from a compatible wallet
|
|
408
|
-
([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
|
|
409
|
-
Put it in `NWC_URI`.
|
|
410
|
-
2. Optional: set up a [swap provider](https://openreceive.org/set_up_swap_provider).
|
|
411
|
-
Put its connection string in `LSC_URI_PRIMARY`, and a second one in
|
|
412
|
-
`LSC_URI_BACKUP` if you have one.
|
|
413
|
-
|
|
414
|
-
Never put these values in browser code. Your app refuses to start if the NWC
|
|
415
|
-
code also advertises spend methods such as `pay_invoice`. Create a
|
|
416
|
-
receive-only code instead ([Security](https://openreceive.org/guides/security.md)).
|
|
417
|
-
|
|
418
|
-
Nothing in PHP loads a `.env` file on its own. Something has to put the values
|
|
419
|
-
in the process environment first: `vlucas/phpdotenv`, your web server's
|
|
420
|
-
`SetEnv`/`fastcgi_param`, or the container runtime
|
|
421
|
-
([Environment variables](https://openreceive.org/guides/environment-variables.md)).
|
|
422
|
-
|
|
423
|
-
### 4. Wire OpenReceive
|
|
424
|
-
|
|
425
|
-
Three methods on one object are the entire bridge between the engine and your
|
|
426
|
-
data. The engine never sees an order, a user or a price except through them.
|
|
427
|
-
`Engine` combines the wallet, the repository over your PDO, and that object
|
|
428
|
-
into a PSR-15 handler. Your front controller sends requests under one path
|
|
429
|
-
prefix to that handler:
|
|
430
|
-
|
|
431
|
-
```php
|
|
432
|
-
<?php
|
|
433
|
-
// public/index.php — or wherever your front controller lives
|
|
434
|
-
declare(strict_types=1);
|
|
435
|
-
|
|
436
|
-
use Nyholm\Psr7\Factory\Psr17Factory;
|
|
437
|
-
use Nyholm\Psr7Server\ServerRequestCreator;
|
|
438
|
-
use OpenReceive\Host;
|
|
439
|
-
use OpenReceive\PaymentSettlement;
|
|
440
|
-
use OpenReceive\Server\AuthorizeContext;
|
|
441
|
-
use OpenReceive\Server\Engine;
|
|
442
|
-
use OpenReceive\Server\Service;
|
|
443
|
-
use OpenReceive\Storage\PdoConnection;
|
|
444
|
-
use OpenReceive\Storage\SqlPaymentRepository;
|
|
445
|
-
|
|
446
|
-
require __DIR__ . '/../vendor/autoload.php';
|
|
447
|
-
|
|
448
|
-
$pdo = new PDO(getenv('DATABASE_DSN')); // the PDO your app already opens
|
|
449
|
-
$orders = new App\Orders($pdo); // YOUR order model — any name works
|
|
450
|
-
|
|
451
|
-
$host = new class($orders) implements Host {
|
|
452
|
-
public function __construct(private readonly App\Orders $orders) {}
|
|
453
|
-
|
|
454
|
-
// Your own access check: may this caller do this action to this reference?
|
|
455
|
-
// `$context->reference()` is your order id, sent back by the payer's
|
|
456
|
-
// browser — a claim, not proof — already validated as a non-empty string.
|
|
457
|
-
// `$context->request` is the PSR-7 ServerRequest: read your session or
|
|
458
|
-
// cookie from it. `$context->action` names the route (checkout.create, …).
|
|
459
|
-
public function authorize(AuthorizeContext $context): bool
|
|
460
|
-
{
|
|
461
|
-
$order = $this->orders->find($context->reference());
|
|
462
|
-
return $order !== null && $order->userId === App\Session::userId($context->request);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// The price for a reference from YOUR data. `value` is a decimal STRING,
|
|
466
|
-
// never a float and never a request parameter; `description` is what the
|
|
467
|
-
// payer is buying, rendered above the amount. null = nothing to pay (404).
|
|
468
|
-
public function amountFor(string $reference): ?array
|
|
469
|
-
{
|
|
470
|
-
$order = $this->orders->find($reference);
|
|
471
|
-
return $order === null ? null : [
|
|
472
|
-
'currency' => 'USD',
|
|
473
|
-
'value' => $order->total, // "12.00"
|
|
474
|
-
'description' => "{$order->lineCount} items",
|
|
475
|
-
];
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// INSIDE the settlement transaction, once per reference. Write through
|
|
479
|
-
// `$settlement->connection` — that transaction — so your order flips in the
|
|
480
|
-
// same commit as the payment record. The WHERE clause is the lock: a second
|
|
481
|
-
// fulfillment path of yours updates zero rows. Database writes only here;
|
|
482
|
-
// emails and webhooks go after commit (implement Hosts\AfterPaid for that).
|
|
483
|
-
public function onPaid(PaymentSettlement $settlement): void
|
|
484
|
-
{
|
|
485
|
-
$settlement->connection->execute(
|
|
486
|
-
"UPDATE orders SET state = 'paid', paid_at = ? WHERE id = ? AND state = 'awaiting_payment'",
|
|
487
|
-
[$settlement->paidAt, $settlement->reference],
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
$engine = new Engine(
|
|
493
|
-
$host,
|
|
494
|
-
new SqlPaymentRepository(new PdoConnection($pdo)),
|
|
495
|
-
Service::fromEnvironment(), // NWC_URI (+ LSC_URI_*) from the environment; preflight runs here
|
|
496
|
-
prefix: '/openreceive',
|
|
497
|
-
);
|
|
498
|
-
|
|
499
|
-
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
500
|
-
if (str_starts_with($path, '/openreceive')) {
|
|
501
|
-
$factory = new Psr17Factory();
|
|
502
|
-
$request = (new ServerRequestCreator($factory, $factory, $factory, $factory))->fromGlobals();
|
|
503
|
-
$response = $engine->psr15Handler()->handle($request);
|
|
504
|
-
http_response_code($response->getStatusCode());
|
|
505
|
-
foreach ($response->getHeaders() as $name => $values) {
|
|
506
|
-
foreach ($values as $value) header("{$name}: {$value}", false);
|
|
507
|
-
}
|
|
508
|
-
echo $response->getBody();
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
// … your own routes
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
`Service::fromEnvironment()` builds the wallet client from `NWC_URI` and runs
|
|
515
|
-
the receive-only preflight. A missing, invalid or spend-capable code throws
|
|
516
|
-
before any route is served. PHP starts every request from nothing, so that
|
|
517
|
-
check runs on every request that reaches the engine.
|
|
518
|
-
|
|
519
|
-
The settlement gate the engine relies on lives in `openreceive_meta`, not in
|
|
520
|
-
memory. That is why a fleet of PHP-FPM workers shares one wallet-scan budget,
|
|
521
|
-
with no worker process of its own. Later OpenReceive requests also settle
|
|
522
|
-
pending invoices, so a payer who closes the tab is still covered. `authorize`
|
|
523
|
-
runs on every request.
|
|
524
|
-
→ [Engine](https://openreceive.org/guides/api-reference.md#openreceiveserverengine) ·
|
|
525
|
-
[Host](https://openreceive.org/guides/api-reference.md#openreceivehost) ·
|
|
526
|
-
[the authorize context](https://openreceive.org/guides/api-reference.md#the-authorize-context-php)
|
|
527
|
-
|
|
528
|
-
**Cross-site requests.** Plain PHP has no CSRF layer, just like Express, and the
|
|
529
|
-
engine does not need one. Every mounted route refuses a request whose
|
|
530
|
-
`Sec-Fetch-Site` header says `cross-site`. So a form or script on another
|
|
531
|
-
origin cannot create invoices using a payer's cookie. That makes
|
|
532
|
-
`<meta name="csrf-token">` optional. If you set it, the checkout sends the value
|
|
533
|
-
back as `X-CSRF-Token` (or the header named by `csrf-header`) for your own layer
|
|
534
|
-
to check.
|
|
535
|
-
|
|
536
|
-
The engine's check does NOT cover two cases:
|
|
537
|
-
|
|
538
|
-
- A browser too old to send `Sec-Fetch-Site`. The header is absent, and an
|
|
539
|
-
absent header passes.
|
|
540
|
-
- Anything that is not a browser at all. A script holding a stolen cookie is a
|
|
541
|
-
session problem, not a forgery problem.
|
|
542
|
-
|
|
543
|
-
`authorize` is still the boundary that decides whether *this caller* may act on
|
|
544
|
-
*this order* ([Security](https://openreceive.org/guides/security.md)).
|
|
545
|
-
|
|
546
|
-
For public web shops, turn on the per-IP invoice cap with `rateLimiting: true`
|
|
547
|
-
on `Engine`. Leave it off (the default) when many payers share one IP. Behind a
|
|
548
|
-
proxy, pass `clientIp: fn ($request) => …` so the cap counts the payer, not the
|
|
549
|
-
proxy. → [Rate limiting](https://openreceive.org/guides/rate-limiting.md)
|
|
550
|
-
|
|
551
|
-
Your app also needs an ordinary order-creation route. It validates the cart,
|
|
552
|
-
prices with exact decimal math, and returns the order id. The page then passes
|
|
553
|
-
that id as the `reference`. OpenReceive never prices from payer input.
|
|
554
|
-
|
|
555
|
-
The `reference` is a string you choose, and it is the fulfillment identity. Use
|
|
556
|
-
your order id:
|
|
557
|
-
|
|
558
|
-
- one per thing you fulfill,
|
|
559
|
-
- created before checkout,
|
|
560
|
-
- kept across retries,
|
|
561
|
-
- never reused.
|
|
562
|
-
|
|
563
|
-
`onPaid` commits fulfillment once per reference, and a new checkout under a
|
|
564
|
-
reference that already settled is refused with 409. A fresh id per page load
|
|
565
|
-
would let one order be paid twice.
|
|
566
|
-
|
|
567
|
-
Naming: PHP APIs use camelCase methods and snake_case array keys
|
|
568
|
-
(`amount_msats`, `payment_hash`). The keys match the wire format. The mounted
|
|
569
|
-
HTTP routes and the browser snapshots are snake_case throughout.
|
|
570
|
-
|
|
571
|
-
### 5. Render checkout
|
|
572
|
-
|
|
573
|
-
Serve the compiled `styles.css` without Tailwind processing. Either import it
|
|
574
|
-
from JavaScript (with a CSS-capable bundler) or use a plain
|
|
575
|
-
`<link rel="stylesheet">`. Do not `@import` it into your Tailwind entry. Its
|
|
576
|
-
rules have zero specificity, so your own styles can override checkout styles.
|
|
577
|
-
Scoping does not prevent that.
|
|
578
|
-
|
|
579
|
-
Unpack the release's `standalone-checkout-<version>.tar.gz` into a directory
|
|
580
|
-
your web server serves. This page uses `public/openreceive/`. Then add two tags
|
|
581
|
-
and the element:
|
|
582
|
-
|
|
583
|
-
```html
|
|
584
|
-
<link rel="stylesheet" href="/openreceive/openreceive-checkout.css" />
|
|
585
|
-
<script type="module" src="/openreceive/openreceive-checkout.js"></script>
|
|
586
|
-
|
|
587
|
-
<openreceive-checkout
|
|
588
|
-
reference="<?= htmlspecialchars($order->id) ?>"
|
|
589
|
-
prefix="/openreceive"
|
|
590
|
-
></openreceive-checkout>
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
The module registers `<openreceive-checkout>` as it loads. The element creates
|
|
594
|
-
the checkout for `reference`, then renders, polls and settles itself. The
|
|
595
|
-
stylesheet is scoped to what OpenReceive renders. The checkout follows the
|
|
596
|
-
payer's theme. On a page that always uses one theme, lock it with
|
|
597
|
-
`theme="dark"`. React, Vue, Svelte, and Angular apps use the matching wrapper
|
|
598
|
-
package instead, with the same attributes
|
|
599
|
-
([Frontend checkout](https://openreceive.org/guides/frontend-checkout.md)). A custom UI builds on
|
|
600
|
-
`@openreceive/browser/headless` ([Headless checkout](https://openreceive.org/guides/headless-checkout.md)).
|
|
601
|
-
|
|
602
|
-
Everything the checkout draws ships inside the JavaScript: the payment-method
|
|
603
|
-
icons, the wallet logos and the pay tutorials. There is no image file to copy
|
|
604
|
-
or serve and no asset option to set. Deploy your normal JavaScript and CSS
|
|
605
|
-
build output, including any generated JavaScript chunks. Bundlers with code
|
|
606
|
-
splitting can load tutorial screenshots only when a tutorial is first opened.
|
|
607
|
-
Single-file builds, including the standalone checkout, include them upfront. If
|
|
608
|
-
your Content-Security-Policy has a strict `img-src`, allow `data:`
|
|
609
|
-
([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
|
|
610
|
-
|
|
611
|
-
`MANIFEST.json` in the tarball carries the version and a SHA-256 per file. You
|
|
612
|
-
can use it to check a copied tree against the release it came from. Keep the
|
|
613
|
-
tarball version in step with the Composer package.
|
|
614
|
-
|
|
615
|
-
Buy a Button
|
|
616
|
-
(`examples/buttons/server/php-plain`)
|
|
617
|
-
is a runnable illustration of this boundary. It is not a template to copy
|
|
618
|
-
models from. It has products, visitors, and orders, and the three hooks are the
|
|
619
|
-
only bridge. Map that shape onto the models in THIS app.
|
|
620
|
-
|
|
621
|
-
### 6. Verify
|
|
622
|
-
|
|
623
|
-
```php
|
|
624
|
-
foreach (\OpenReceive\Server\Doctor::report(
|
|
625
|
-
\OpenReceive\Server\Service::processEnvironment(),
|
|
626
|
-
$host,
|
|
627
|
-
static fn () => \OpenReceive\Server\Service::fromEnvironment(),
|
|
628
|
-
'/openreceive',
|
|
629
|
-
) as $line) echo $line, PHP_EOL;
|
|
630
|
-
```
|
|
631
|
-
|
|
632
|
-
`Doctor::report()` prints:
|
|
633
|
-
|
|
634
|
-
- every credential as set or unset, never its value;
|
|
635
|
-
- the host class, and which of the three methods are still the scaffolded
|
|
636
|
-
placeholders (`Hosts\AllowAllAuthorize`, `Hosts\LoggingOnPaid`). The engine
|
|
637
|
-
also warns at boot while either is in use;
|
|
638
|
-
- where the handler is mounted;
|
|
639
|
-
- the receive-only wallet preflight.
|
|
640
|
-
|
|
641
|
-
`$engine->doctor()` is the same report for an engine you already built. Put it
|
|
642
|
-
behind a `bin/doctor` script. The demo's is twelve lines.
|
|
643
|
-
→ [Doctor](https://openreceive.org/guides/api-reference.md#openreceiveserverdoctor)
|
|
644
|
-
|
|
645
|
-
Then open the checkout in a browser. Confirm the payment-method icons and
|
|
646
|
-
wallet logos render, and open a wallet's pay tutorial to check its screenshots.
|
|
647
|
-
If an image is missing, check the console for CSP violations and the Network
|
|
648
|
-
panel for failed JavaScript chunks. Allow `data:` in `img-src` and deploy the
|
|
649
|
-
complete build output. Do not add image routes, copy package source images, or
|
|
650
|
-
use registry `icon_path` / tutorial `path` keys as browser URLs.
|
|
651
|
-
|
|
652
|
-
### Reconciliation
|
|
653
|
-
|
|
654
|
-
Settlement runs on the request path. Every payment route first runs one bounded
|
|
655
|
-
reconcile pass through the durable `openreceive_meta` gate. The gate allows at
|
|
656
|
-
most one real wallet scan every 3 seconds, shared by every PHP process. You do
|
|
657
|
-
not need a cron job. Tune or disable it with `Engine`'s
|
|
658
|
-
`opportunisticReconcile` (`false`, or `['min_interval_seconds' => …]`).
|
|
659
|
-
|
|
660
|
-
Optionally, run one worker so settlement does not wait for the next page load:
|
|
661
|
-
|
|
662
|
-
```php
|
|
663
|
-
$engine->notificationsWorker()->run(); // blocks: an NWC-02 listener plus a periodic pass
|
|
664
|
-
```
|
|
665
|
-
|
|
666
|
-
Run it as its own long-lived process (`php bin/notifications`). To run a pass
|
|
667
|
-
yourself, use the one-shot `$engine->reconcile()`.
|
|
668
|
-
→ [Engine notificationsWorker](https://openreceive.org/guides/api-reference.md#engine-notificationsworker)
|
|
669
|
-
|
|
670
|
-
### Swap secrets
|
|
671
|
-
|
|
672
|
-
Setting `LSC_URI_PRIMARY` (and `LSC_URI_BACKUP`) auto-builds the matching swap
|
|
673
|
-
providers. Nothing in your code changes. One `openreceive_payments` row holds
|
|
674
|
-
at most one provider order, in its server-only `swap_data`. The repository
|
|
675
|
-
never selects it into public arrays. Do not log it or return it from your own
|
|
676
|
-
API.
|
|
677
|
-
|
|
678
|
-
**Setting either connection string commits you to refunds.** A deposit that
|
|
679
|
-
arrives short or late is claimed on a second visit. That needs a per-order URL
|
|
680
|
-
your app serves, and the attempt's `payment_hash` kept.
|
|
681
|
-
[Swap refunds](https://openreceive.org/guides/swap-refunds.md) covers all of it. Read it before you set
|
|
682
|
-
`LSC_URI_PRIMARY`.
|