Accept Bitcoin & Stablecoin Payments With Sylius
Sylius quickstart
Sylius 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 plugin uses Sylius 2’s payment requests, not Payum. It runs on the OpenReceive Symfony bundle, which serves the checkout’s routes and the settlement engine.
Install the plugin
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
Configure the wallet
In the admin, open Configuration > Payment methods > Create and choose Bitcoin Lightning (OpenReceive). Paste a receive-only NWC code (get one), 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).
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:
* * * * * 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
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_paymentcompletetransition 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:reconcilepass, 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 inopenreceive_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.
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.
Next
- Symfony quickstart — the bundle the plugin runs on
- Swap refunds
- How OpenReceive stores payments
- Payment safety