# 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](/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.

## Next

- [Swap refunds](/guides/swap-refunds.md)
- [How OpenReceive stores payments](/guides/storage.md)
- [Payment safety](/guides/payment-safety-upgrade.md)
