Search by

openreceive / sylius-plugin

openreceive

Accept Bitcoin Lightning payments in Sylius with your own wallet and existing database. Optional USDT, USDC, SOL and ETH swaps settle as BTC over Lightning.

Package info

github.com/OpenReceive/openreceive-sylius

Homepage

Issues

Documentation

Type:sylius-plugin

pkg:composer/openreceive/sylius-plugin

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v0.6.6 2026-11-29 18:55 UTC

This package is auto-updated.

Last update: 2026-11-29 19:12:17 UTC


README

Add a Bitcoin Lightning payment method to your Sylius 2 shop and receive payments directly into a wallet you control. The customer pays on the shop's own pay page, and the order's payment completes when the Lightning invoice settles. There is no payment processor account and no second database: OpenReceive keeps its payment attempts in Sylius's own database, and Sylius keeps its orders, customers, prices and fulfillment.

This plugin is the Sylius side of the integration. It runs on the OpenReceive Symfony bundle (the checkout's routes, the settlement engine, the console commands) and adds the Sylius payment method, the pay page, and the bridge that moves a paid order through Sylius's own state machine.

Docs and setup: openreceive.org/integrations/sylius

OpenReceive supports optional swaps from USDT, USDC, SOL, and ETH through a configured swap provider. The provider converts the payment to BTC over Lightning, which settles into the merchant's connected wallet. Available assets and networks depend on the provider; swaps are optional.

Requirements

  • Sylius 2.2 or 2.3 (Sylius 2.3 needs PHP 8.3), on MySQL, MariaDB or PostgreSQL.
  • PHP 8.2 or later with ext-gmp, sodium and mbstring, besides what Sylius needs.
  • A receive-only NWC code from your wallet (get one).

Install

composer require openreceive/sylius-plugin

Register both bundles in config/bundles.php:

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

Import the plugin's configuration and routes:

# config/packages/openreceive_sylius.yaml
imports:
    - { resource: "@OpenReceiveSyliusPlugin/config/config.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:

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

In the admin, open Configuration > Payment methods > Create and choose Bitcoin Lightning (OpenReceive). Paste the receive-only NWC code, 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.

Or from the console, with the code read from stdin (never as an argument):

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

It runs the same receive-only check before saving, and makes the payment method if there is none (code openreceive, "Bitcoin Lightning", enabled on every channel) or updates the first OpenReceive method by position. It prints only whether each code is set.

Last, add the settlement backstop to cron, so a payment whose customer closed the page still completes its order:

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

bin/console openreceive:doctor reports the wallet code as set or unset (it never prints it), the routes, and the wallet's receive-only check.

How it 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 (capture) and sends them to its pay route. The plugin moves the request to processing and answers with the pay page: the <openreceive-checkout> element for the order, which makes the Lightning invoice (or a swap) through POST /openreceive/checkouts, 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, by this method.
  • 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 page grants the order's token in the session). The checkout's JSON routes sit behind the shop firewall and refuse cross-site requests.
  • Settlement. When the invoice settles in the wallet, the engine's settlement transaction (on the database connection Sylius's entity manager uses) applies Sylius's own sylius_payment complete transition to the order's payment and completes its payment requests. Sylius's listeners move the order's payment state to paid. The payment row and the order commit together, or roll back together for the next pass. The payment hash is kept in the payment's details.
  • Settlement discovery. Every request the checkout makes runs one reconciliation pass, so a customer who stays on the page sees the order paid within seconds. openreceive:reconcile from cron covers customers who leave, and the optional openreceive:notifications worker settles within a second of payment.
  • 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 the merchant's decision and 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 (/order/{token}) 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.
  • Codes. The NWC code and the optional swap provider codes (lsc_uri_primary, lsc_uri_backup) live in the payment method's encrypted gateway configuration. The first enabled OpenReceive method (by position) with a code is the shop's wallet; without one, NWC_URI and LSC_URI_* from the environment apply. Codes never reach the browser.

Commands

Command What it does
openreceive:configure Saves a code read from stdin (--nwc-uri=-, --lsc-uri-primary=-, --lsc-uri-backup=-; --remove-lsc, --name) into the payment method, encrypted, making the method if there is none
openreceive:reconcile One reconciliation pass, then completes orders whose payment settled. Run it from cron
openreceive:notifications Optional worker: NWC-02 notifications plus a periodic pass
openreceive:doctor The wallet code (set/unset only), which payment method holds it, routes, and the wallet's receive-only check
openreceive:test-invoice <order id> Makes the Lightning invoice for an unpaid order through the checkout's own route

Limits

  • One wallet per shop: every OpenReceive payment method pays into the first one's wallet.
  • Refunds are made from your wallet; Sylius's refund action does not send bitcoin.
  • A swap that arrives short or late is refunded from the order's pay page, which resumes the order's live checkout. See Swap refunds before you set a swap provider code.
  • 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.

Tests

composer install
vendor/bin/phpunit

The suite boots Sylius's test application (sylius/test-application) with the bundle and this plugin on SQLite, over the engine's fake wallet and a static price, and walks Sylius's own pay routes. Set OPENRECEIVE_TEST_SYLIUS_DATABASE_URL to run it on MySQL or PostgreSQL.

tests/E2E/run.sh runs the whole shop in Docker (MariaDB, the demo fixtures, the built frontend) and pays an order in Chromium against a test wallet.

License

MIT