This is the full file; follow it from Step 0.

# OpenReceive agent directions (Shopware)

```sh
# READ THIS FIRST: this file is 18 KB and a summary drops required steps. Download it whole:
curl -fsSL https://openreceive.org/agent-directions/shopware/full.md
# 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/shopware/full.md
# Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
```

**Step 0 in brief** (Step 0 below has the details):

- Before installing or editing anything, ask the user for a receive-only NWC code. One question per message.
- Next ask for the LSC code. If the user wants stablecoins, USDT, USDC, ETH, SOL or crypto, do not ask yes/no first.
- The user only pastes codes here: no command, no admin page. If you will not take one in chat, see Step 0.
- Store each code yourself as Step 2 says. Never put a code in a shell command.
- Do not suggest rotating or revoking a code because it was pasted here.
- Setup is done only when the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".

These directions describe OpenReceive 0.6.4.

Install and configure the OpenReceive payment plugin in the Shopware 6 shop
you are working in. Preserve its theme, customers, products, orders and
prices. The plugin is a Composer package (`openreceive/shopware-plugin`) that
brings the OpenReceive PHP engine with it: do not clone the OpenReceive
repository, and do not write payment code of your own.

The one required credential is a receive-only NWC code (Nostr Wallet Connect):
a string from the merchant's wallet that can create invoices and read their
status, and cannot spend. A swap provider (an "LSC" code) optionally lets
customers pay with USDT, USDC, ETH or SOL instead; the provider converts the
payment to BTC over Lightning in the merchant's connected wallet. Available
assets and networks depend on the provider.

Run every `bin/console` and `composer` command below in the shop's folder, the
way this project already runs them: inside its PHP container when a compose
file runs the shop (`docker compose exec -T <php service> bin/console …`), as
the web server's user, never as root.

## Step 0 — ask for the two codes, one question at a time

Before anything else, check one thing: whether OpenReceive is already
installed (`bin/console openreceive:doctor`; without the plugin it answers
that the command is not defined, which means not installed). If it exists, it
prints `NWC_URI: set` or `unset` (likewise `LSC_URI_PRIMARY`), never the
values. A code that is already set is not asked for again; if both are set,
skip to Step 3.

Otherwise your next action is a question to the user. Do not install the
plugin, edit Docker files or search anywhere else before asking it. Do not
read `.env.local`, Shopware's system config, deploy config, container
environments or other projects looking for a code: a new install has neither
code yet.

The user never runs a command. They paste each code into this chat; you
store it. That is the supported path: do not ask them to run the save
command themselves, and do not tell them to revoke or replace a
code because it was pasted here. Ask one question per message.

If you will not take a code pasted in chat, end that same message with this
in place of "Paste the code here": "Save the code alone in
`/tmp/openreceive-nwc`, then reply saved." (`/tmp/openreceive-lsc` for the
swap code). Step 2 then reads that file in place of `/tmp/openreceive-code`
and deletes it. Ask once per code: if the file is missing after their reply,
do not ask again; say which file is missing, and stop. Never print it.

1. **First message — the NWC code, and nothing else.**

   > To receive payments I need a receive-only wallet code. In Rizful: open
   > the menu, tap NWC, choose Receive-only NWC code, and tap Copy
   > (https://openreceive.org/get_a_nwc_code_to_receive_payments). If you would
   > rather run your own wallet, Alby Hub works too: Connections → Add
   > Connection → Read Only. Paste the code here and I will store it.

2. **When they paste it.** If it does not start with `nostr+walletconnect://`,
   ask them to copy the receive-only code again. Otherwise do not repeat it:
   reply only that you have it, then ask the next question. You store it in
   Step 2.
3. **Second message — swaps.** If the user asked for stablecoins, USDT, USDC,
   ETH, SOL or coins other than Bitcoin (as in "Bitcoin and stablecoin
   payments"), this message IS the walkthrough below: do not skip it, and do
   not ask yes or no first. Otherwise ask whether customers should also be
   able to pay with USDT, USDC, ETH or SOL, then give the walkthrough. The
   walkthrough:

   > Go to https://lightning-swap.com, sign in for API keys, create a key, and
   > copy the whole URI (https://openreceive.org/set_up_swap_provider). Paste
   > it here and I will store it — or say "Bitcoin only" and I will continue
   > without it.

   Mention FixedFloat only if they already use it.
4. **When they paste it.** If it does not start with
   `lightning+swapconnect://`, ask them to copy it again. Swaps are now on,
   so keep the route back (the swap non-negotiable below).

Do not report setup as complete until the NWC code is saved, and the LSC code
is saved or the user said "Bitcoin only". Never invent a placeholder code.

## Step 1 — install the plugin

The plugin needs Shopware 6.6 (6.6.5 or later) or 6.7 with the Storefront, on
64-bit PHP 8.2+ with `gmp` and `sodium` (`php -m` must list both, where the
shop runs). Without one of them, say which PHP extension is missing and stop:
installing PHP extensions is the merchant's decision.

```sh
composer require openreceive/shopware-plugin
bin/console plugin:refresh
bin/console plugin:install --activate OpenReceivePayment
bin/console cache:clear
```

Installing creates the payment method "Bitcoin Lightning" (switched off) and
the plugin's two tables. If the project's own rules (its `AGENTS.md`,
contributing guide) forbid installing plugins from the console, ask the owner
and wait.

## Step 2 — store the codes

Store each code yourself, one per command, and never as a shell argument:

1. Write the code with your file-editing tool, not a shell command (no
   `echo`, `printf` or heredoc), to a new file outside the shop's folder,
   such as `/tmp/openreceive-code`.
2. Run `bin/console openreceive:configure --nwc-uri=- < /tmp/openreceive-code`.
   In Docker: `docker compose exec -T <php service> bin/console openreceive:configure --nwc-uri=- < /tmp/openreceive-code`.
   For the swap code, use `--lsc-uri-primary=-`.
3. Delete the file (`rm /tmp/openreceive-code`), whether the command passed
   or not.

The command asks the wallet first and saves the code, encrypted under a key
derived from the shop's `APP_SECRET`, only when the wallet answers as
receive-only; a failure saves nothing. If it reports spend methods such as
`pay_invoice`, ask the user for a receive-only code again. Saving the wallet
code switches the payment method on and offers it in the shop's sales
channels. Never write a code into `.env`, `.env.local`, the database or any
file in the shop's folder yourself, and never change `APP_SECRET`.

Then run `bin/console openreceive:doctor`. It names any failed check; fix it
before going on.

## Step 3 — hand over, then stop

You cannot pay an invoice: the code is receive-only. Do not pay, settle or
mark an order paid, and do not look for a way to (a wallet control port, a
test endpoint, another wallet). If the user wants a real settlement test, they
place an order and pay it on its pay page from their own wallet; afterwards
the order's payment reads "Paid".

Setup ends here. Once doctor is clean, your last message starts "Setup is
finished" and has at most six short lines: "Open <shop url>, add a product
and choose Bitcoin Lightning at checkout: placing the order opens the payment
page", the methods the checkout offers (Bitcoin, plus USDT, USDC, ETH and SOL
when the swap code is saved), one line that Shopware's scheduled tasks must
run, and one line of what to look at. Do not mention a minimum or say a coin
will not work: a provider minimum depends on the order total. Do not list what
you changed or what doctor checked. Send nothing after it.

A customer who pays and closes the page is settled by the plugin's scheduled
task, which needs Shopware's own scheduled tasks and message worker. Do not
add crontab entries, containers, services or workers yourself: name what must
run in your last message.

## Non-negotiables

- Never print, log or commit a code, never put one in a shell argument, and
  never write one into source files, `.env` files, the database or browser
  code. Doctor's set/unset is all you report.
- Do not suggest rotating, revoking or replacing a code because it was pasted
  into this chat; that is the supported path.
- Work only in this shop. Never read or run anything from another project or
  directory on this machine (its `node_modules`, tools or source), for any
  reason. A browser, Playwright, hand-made calls to the checkout's routes,
  database queries and reading the plugin's source are not part of setup:
  when doctor fails, report its output.
- Receive-only NWC is required. Never get past the preflight with a code that
  can spend.
- The plugin owns only its two payment tables in Shopware's database and its
  encrypted settings. Shopware owns customers, orders, prices, shipping and
  email. Do not add an external payment database or custom fulfillment code,
  and do not edit Shopware's own files or the theme.
- IF SWAPS ARE ON, KEEP THE ROUTE BACK. A deposit that arrives short or late
  becomes refundable, and the customer claims it later from the order's pay
  page. Keep the plugin installed while swap payments may still need a
  refund. https://openreceive.org/guides/swap-refunds.md
- A receive-only wallet cannot send refunds. Refund a settled payment manually
  from the wallet.

## Further reading

- [Shopware Quickstart](https://openreceive.org/guides/quickstart-shopware.md)
- [Automated Swaps](https://openreceive.org/guides/automated-swaps.md)
- [Swap Refunds](https://openreceive.org/guides/swap-refunds.md)
- [Lightning Swap Connect URI](https://openreceive.org/guides/lightning-swap-connect.md)
- [Security](https://openreceive.org/guides/security.md)
- [Price Feeds](https://openreceive.org/guides/price-feeds.md)

---

## The quickstart, in full

Inlined verbatim so this file needs no network access. Steps 0–3 above are the setup and this is their reference: where the two differ, the steps win, and its admin screens are only for a shop with no shell.
The page it comes from is https://openreceive.org/guides/quickstart-shopware.

## Shopware quickstart

The OpenReceive plugin adds a payment method to [Shopware 6](https://www.shopware.com):
the customer places the order in Shopware's own checkout and pays on the
order's pay page, straight into your own wallet. With a swap provider, the
same page also takes USDT, USDC, SOL and ETH, which the provider converts to
BTC over Lightning into the same wallet. The order's payment moves to "Paid"
when the Lightning invoice settles.

Shopware keeps owning customers, orders, prices and fulfillment. The plugin
keeps its payment attempts in two tables of Shopware's own database. When a
payment settles, it applies Shopware's own `paid` transition to the order
transaction, in the same database transaction that settles the payment, so
Shopware's flows on "payment paid" (its mails) run as for any other method.

Requirements: Shopware 6.6 (6.6.5 or later) or 6.7 with the Storefront, on
64-bit PHP 8.2 or later with `gmp` and `sodium` besides what Shopware needs,
and Shopware's scheduled tasks running (`scheduled-task:run` and
`messenger:consume`, or the admin worker) for the settlement backstop.

### Install the plugin

In a Composer-managed shop:

```sh
composer require openreceive/shopware-plugin
bin/console plugin:refresh
bin/console plugin:install --activate OpenReceivePayment
bin/console cache:clear
```

A plugin uploaded as a ZIP to `custom/plugins/OpenReceivePayment` ships no
`vendor/`: Shopware runs `composer require openreceive/shopware-plugin`
itself when it installs it, so the engine resolves against the versions your
shop already locks. Installing makes the payment method "Bitcoin Lightning"
(switched off) and the engine's two tables.

### Configure the wallet

From the console, with the code read from a file so it never appears in a
shell argument:

```sh
bin/console openreceive:configure --nwc-uri=- < /path/to/code-file
bin/console openreceive:configure --lsc-uri-primary=- < /path/to/swap-code-file   # optional
```

Or in the admin: **Extensions > My extensions > Bitcoin Lightning
(OpenReceive) > Configure**, paste a receive-only NWC code
([get one](https://openreceive.org/get_a_nwc_code_to_receive_payments)) under
**All Sales Channels**, and save. Either way the plugin checks the code with
your wallet first: a code that cannot make invoices, or one that can also
spend, is refused and nothing is saved. The code is stored encrypted under a
key derived from the shop's `APP_SECRET`; keep that secret stable, or save the
code again after changing it.

Saving a code switches the payment method on. `openreceive:configure` also
offers it in every storefront and headless sales channel that does not offer
it yet (`--no-sales-channels` skips that); from the admin, add it under
**Sales Channels > Payment and shipping**. The optional swap provider code
goes in the same place
([set up a swap provider](https://openreceive.org/set_up_swap_provider)).

### The scheduled task

Every request the checkout makes runs one reconciliation pass, so a customer
who stays on the page sees the order paid within seconds. The plugin's
scheduled task `openreceive.reconcile` runs every minute and settles payments
whose customer left the pay page, so make sure Shopware's scheduled tasks run.
`bin/console openreceive:reconcile` runs the same pass by hand.

### Check it

```sh
bin/console openreceive:doctor
```

The doctor reports each code as set or unset (never the value), whether the
stored code can be read under the current `APP_SECRET`, the wallet's
receive-only check, and any paid order Shopware could not move.

### How a payment works

- **The reference is the order's id.** It exists before checkout, survives
  every retry and every change of payment method, and is never reused, so an
  order is paid once. A second invoice for a paid order is refused.
- **Paying.** The plugin's payment handler sends the customer from checkout
  to the order's pay page, `/openreceive/pay/<deep-link code>`, which shows the
  `<openreceive-checkout>` element. It makes the Lightning invoice (or a
  swap), shows it, and watches it settle. The page shows no order total
  beside the checkout: the checkout shows the one amount to send.
- **The price is Shopware's.** The invoice is for the order transaction's
  total, in the order's currency, converted at the current BTC price, and
  only while that transaction waits for its payment and the order is not
  cancelled.
- **Who may pay.** The signed-in customer who placed the order, or a browser
  the pay page was opened in with the order's deep-link code. The checkout's
  JSON routes accept JSON only and refuse cross-site requests.
- **Settlement.** The engine's settlement transaction runs on Shopware's own
  DBAL connection; Shopware's DAL writes join it, so the payment row and the
  order transaction commit together, or roll back together for the next
  pass. The payment hash is kept in the transaction's custom fields.
- **Repair and cancelled orders.** A settled payment whose transaction could
  not move then is finished by the scheduled task, `openreceive:reconcile`,
  the pay page and Shopware's finalize step. An order someone cancelled is
  never moved: the payment is in the wallet and in `openreceive_payments`, the
  log says so, and the doctor lists the order.
- **Coming back.** The transaction stays open until the invoice settles, so
  Shopware's own "complete payment" button on the customer's order page leads
  back to the same pay page and the same invoice.

### Refunds and removal

The receive-only wallet cannot send refunds. Send a refund from your own
wallet, then record it in Shopware. A customer whose swap deposit never
converted reclaims it from the order's pay page, while the order is unpaid. If
you turn on swaps, you commit to keeping that path available. See
[swap refunds](https://openreceive.org/guides/swap-refunds.md).

Deactivating the plugin hides the payment method. Uninstalling it keeps the
two tables, which are a record of payments received.

### Tested, and not tested

Tested on 2026-11-28 with Shopware 6.7.16.2 and 6.6.10.32 on MariaDB 11.4 in
Docker, the plugin placed in `custom/plugins` as a ZIP upload places it, and
a test wallet on a live relay: the code saved with `openreceive:configure` and
a bad code refused by the admin API; in Chromium, a guest checking out with
the method, paying on the pay page and reaching Shopware's finish page, after
which the order transaction read "paid"; a guest who left the pay page unpaid,
whose order the scheduled task marked paid; and an order the merchant
cancelled before payment, which stayed cancelled and was listed by the
doctor. The plugin's PHPUnit suite runs on SQLite and on MySQL 8.4.

Swaps were tested the same way against a test swap provider, a fake of the
provider's API that moves no funds, saved with `openreceive:configure` and
checked by the doctor. A guest picked USDT on Solana on the pay page and the
deposit screen showed one amount, the USDT to send. The provider completed the
swap, the swap's Lightning invoice settled, the guest reached Shopware's finish
page, and the order transaction read "paid". A second guest's swap, which the
provider reported underpaid, was refunded to a Solana address from the
checkout, and that transaction stayed "open".

Not tested: a real swap provider, the other swap coins and networks, the
admin settings page by hand (its saves go through the same admin API the run
used), multi-domain sales channels, and updating from an older release of the
plugin.
