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

# OpenReceive agent directions (Sylius)

```sh
# READ THIS FIRST: this file is 20 KB and a summary drops required steps. Download it whole:
curl -fsSL https://openreceive.org/agent-directions/sylius/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/sylius/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.8.

Install and configure the OpenReceive payment plugin in the Sylius 2 shop you
are working in. Preserve its theme, customers, products, orders and prices.
The plugin is a Composer package (`openreceive/sylius-plugin`) that brings the
OpenReceive Symfony bundle and the 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`, Sylius's payment settings, 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 Codes, then tap Copy receive-only code
   > (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 Sylius 2.2 or 2.3 on 64-bit PHP 8.2+ with `gmp`, `sodium`
and `mbstring` (`php -m` must list all three, 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/sylius-plugin
```

Register both bundles in `config/bundles.php`, after Sylius's own:

```php
OpenReceive\Symfony\OpenReceiveBundle::class => ['all' => true],
OpenReceive\SyliusPlugin\OpenReceiveSyliusPlugin::class => ['all' => true],
```

Import the plugin's configuration and routes in two new files:

```yaml
# config/packages/openreceive_sylius.yaml
imports:
    - { resource: "@OpenReceiveSyliusPlugin/config/config.yaml" }
```

```yaml
# config/routes/openreceive_sylius.yaml
openreceive_sylius:
    resource: "@OpenReceiveSyliusPlugin/config/routes.yaml"
```

Then create the two OpenReceive tables and publish the checkout's script and
stylesheet:

```sh
bin/console doctrine:migrations:migrate --no-interaction
bin/console assets:install
```

If the project's own rules (its `AGENTS.md`, contributing guide) forbid
running migrations, ask the owner and wait. Sylius must already have a
payment encryption key (`bin/console sylius:payment:generate-key` makes one
if the shop has none); the plugin keeps the codes encrypted with it.

## 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 in the
payment method's gateway configuration, 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. The first run also
creates the payment method customers pick, "Bitcoin Lightning", enabled on
every channel. Never write a code into `.env`, `.env.local`, the database or
any file in the shop's folder yourself.

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 from their own wallet; afterwards the order's
payment state 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: it opens the payment page", the
methods the checkout offers (Bitcoin, plus USDT, USDC, ETH and SOL when the
swap code is saved), the crontab entry below, 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 reconcile
pass, which needs one crontab entry. Give the user the whole entry in your
last message, with this shop's real folder, and do not add it yourself, or
any containers, services or workers. Under Docker, for the host's crontab:
`* * * * * cd /path/to/shop && docker compose exec -T <php service> bin/console openreceive:reconcile`.
Otherwise, for the web user's crontab:
`* * * * * cd /path/to/shop && bin/console openreceive:reconcile`.

## 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 Sylius's database and its
  codes in the payment method's encrypted configuration. Sylius owns
  customers, orders, prices, shipping and email. Do not add an external
  payment database or custom fulfillment code, and do not edit Sylius's own
  files or the theme.
- The payment method must not use Payum: `openreceive:configure` creates it
  correctly. Do not create it from fixtures or the API.
- 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

- [Sylius Quickstart](https://openreceive.org/guides/quickstart-sylius.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)
- [Currencies](https://openreceive.org/guides/currencies.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-sylius.

## Sylius quickstart

[Sylius](https://sylius.com) is an open-source e-commerce framework on
Symfony. The OpenReceive plugin adds a payment method to it: the customer pays
with Bitcoin over Lightning, straight into your own wallet, on the shop's own
pay page. 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.

Sylius keeps owning customers, orders, prices and shipping. The plugin keeps
its payment attempts in two tables of Sylius's own database. When a payment
settles, it applies Sylius's own `complete` transition to the order's payment,
in the same database transaction that settles the payment, so Sylius moves the
order's payment state to "Paid" and runs its usual listeners.

Requirements: Sylius 2.2 or 2.3 (Sylius 2.3 needs PHP 8.3) on MySQL, MariaDB
or PostgreSQL, with 64-bit PHP 8.2 or later and the `gmp`, `sodium` and
`mbstring` extensions besides what Sylius needs. A cron job runs the plugin's
reconcile pass, as [below](#the-cron-job).

The plugin uses Sylius 2's payment requests, not Payum. It runs on the
[OpenReceive Symfony bundle](https://openreceive.org/guides/quickstart-symfony.md), which serves the
checkout's routes and the settlement engine.

### Install the plugin

```sh
composer require openreceive/sylius-plugin
```

Register both bundles in `config/bundles.php`:

```php
OpenReceive\Symfony\OpenReceiveBundle::class => ['all' => true],
OpenReceive\SyliusPlugin\OpenReceiveSyliusPlugin::class => ['all' => true],
```

Import the plugin's configuration and routes:

```yaml
# config/packages/openreceive_sylius.yaml
imports:
    - { resource: "@OpenReceiveSyliusPlugin/config/config.yaml" }
```

```yaml
# config/routes/openreceive_sylius.yaml
openreceive_sylius:
    resource: "@OpenReceiveSyliusPlugin/config/routes.yaml"
```

Then create the two OpenReceive tables (the plugin's migration runs after
Sylius's own) and publish the checkout's script and stylesheet:

```sh
bin/console doctrine:migrations:migrate
bin/console assets:install
```

### Configure the wallet

In the admin, open **Configuration > Payment methods > Create** and choose
**Bitcoin Lightning (OpenReceive)**. Paste a receive-only NWC code
([get one](https://openreceive.org/get_a_nwc_code_to_receive_payments)),
enable the method on your channels, and save. The form checks the code with
your wallet before saving it: a code that cannot make invoices, or one that
can also spend, is refused.

Sylius encrypts the code in the database with its payment encryption key
(`bin/console sylius:payment:generate-key` makes one if your shop has none),
and the form never shows it again. Leave the field blank to keep the saved
code. The optional swap provider codes go in the same form
([set up a swap provider](https://openreceive.org/set_up_swap_provider)).

The first enabled OpenReceive method, by position, holds the shop's wallet.
Without a code there, `NWC_URI`, `LSC_URI_PRIMARY` and `LSC_URI_BACKUP` from
the environment apply.

### The cron job

Every request the checkout makes runs one reconciliation pass, so a customer
who stays on the page sees the order paid within seconds. A customer who pays
and closes the page is settled by the next pass. Add one to cron, so that
order does not wait for another customer:

```cron
* * * * * cd /path/to/shop && bin/console openreceive:reconcile
```

The optional `bin/console openreceive:notifications` worker settles within a
second of payment. Run one per shop, not one per web server.

### Check it

```sh
bin/console openreceive:doctor
bin/console openreceive:test-invoice <order id>
```

The doctor reports the wallet code as set or unset (it never prints it), the
routes, and the wallet's receive-only check. `test-invoice` makes the
Lightning invoice for an unpaid order through the checkout's own route.

### 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 can be paid once. A second invoice for an order that is already paid
  is refused.
- **Paying.** When the customer places the order, Sylius creates a payment
  request and sends them to its pay route. The plugin answers with the pay
  page: the `<openreceive-checkout>` element for the order, which 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 Sylius's.** The invoice is for the order's open payment
  amount, in the order's currency, converted at the current BTC price. It is
  made only while that payment waits.
- **Who may pay.** The signed-in customer who placed the order, or a browser
  Sylius already showed the order's pay page or thank-you page to. The
  checkout's JSON routes sit behind the shop firewall and refuse cross-site
  requests.
- **Settlement.** The engine's settlement transaction runs on the database
  connection Sylius's entity manager uses. It applies the `sylius_payment`
  `complete` transition and completes the payment requests, and the payment
  row and the order commit together, or roll back together for the next pass.
- **Repair.** A settled payment whose order could not move (a shop rule that
  guards the transition, say) is finished by every `openreceive:reconcile`
  pass, when the customer returns from the pay page, and when the thank-you
  page shows the order. An order someone cancelled is never moved: the
  payment is in the wallet and in `openreceive_payments`, and the log says so.
- **Coming back.** An unpaid order's page has Sylius's **Pay** button, which
  opens the same pay page and the same invoice. The thank-you page shows the
  checkout while the order is unpaid, and a paid notice once it is.

### Refunds and removal

The receive-only wallet cannot send refunds. Send a refund from your own
wallet; Sylius's refund action does not send bitcoin. A customer whose swap
deposit never converted reclaims it from the order's pay page, which resumes
the order's live checkout. If you turn on swaps, you commit to keeping that
path available. See [swap refunds](https://openreceive.org/guides/swap-refunds.md).

Disabling the payment method hides it at checkout. Removing the plugin keeps
the two tables, which are a record of payments received.

The payment method must not use Payum. The admin form sets that for this
gateway; a method created by fixtures or the API needs `usePayum: false`.

### Tested, and not tested

Tested on 2026-11-28 with Sylius 2.3.3 on MariaDB 11.4, the demo fixtures and
the built storefront, and a test wallet on a live relay: in Chromium, a
customer checking out with OpenReceive through Sylius's own checkout steps;
the pay page making the invoice; the payment settling; and the order reading
payment state "paid", with its payment and both payment requests completed.
The plugin's PHPUnit suite (31 tests) runs Sylius's test application on PHP
8.2, 8.3 and 8.4 over the engine's fake wallet.

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`. A
customer 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, and the order read payment state "paid". A second
customer's swap, which the provider reported underpaid, was refunded to a
Solana address from the checkout, and that order stayed "awaiting payment".

Not tested: a real swap provider, the other swap coins and networks,
PostgreSQL, multi-channel shops with different currencies on a live relay, an
asynchronous Messenger transport for payment requests, and updating from an
older release of the plugin.
