Skip to main content

Sylius

To accept payments through MONEI in your Sylius 2 store, install and configure the official MONEI payment plugin. It adds a MONEI gateway to Sylius. You create one Sylius payment method for each MONEI payment method that you offer.

Live demo

This page describes plugin version 2.3.0 and later

Version 2.0.0 is a full rewrite. If you installed 1.x, read Upgrade from 1.x before you update.

Requirements​

ComponentSupported versions
PHP8.2 or later
Sylius2.2.13 or later on the 2.2 line, or 2.3.3 or later

These are the versions of plugin 2.3. Plugin 2.0 and 2.1 also run on Sylius 2.2.12 and 2.3.2, but those Sylius versions have known security issues.

You also need:

  • A MONEI account with the payment methods that you want to offer.
  • A public store URL that MONEI can reach from the internet. MONEI sends a callback for each payment to it. See Callbacks.
  • The Symfony Workflow state machine adapter (symfony_workflow) for the sylius_payment and sylius_order graphs. See State machine adapter.

State machine adapter​

The plugin calls MONEI from Symfony Workflow events. With another adapter (winzou), a capture, cancel or refund in the Sylius admin changes Sylius without a call to MONEI. The Sylius 2 default is symfony_workflow.

  • When your configuration maps sylius_payment or sylius_order to another adapter, the container does not build. The error names the graph.
  • When the adapter comes from an environment variable, the plugin cannot check it at build time. Make sure that the variable resolves to symfony_workflow.
# config/packages/sylius_state_machine_abstraction.yaml (only if you changed the default)
sylius_state_machine_abstraction:
graphs_to_adapters_mapping:
sylius_payment: symfony_workflow
sylius_order: symfony_workflow

Before you begin​

To test your integration:

Install​

Step 1: Install the package​

composer update sylius/sylius --with-all-dependencies
composer require monei/sylius-monei-plugin:^2.3

Plugin 2.3 needs Sylius 2.2.13 or later on the 2.2 line, or 2.3.3 or later, which fix the Sylius security advisories of November 2026. The first command updates Sylius to them; skip it if your store already runs them. If your composer.json pins sylius/sylius to an older version, raise that constraint first: --with-all-dependencies does not change it. Without it, Composer cannot install 2.3 on an older Sylius (Sylius-Standard 2.3 still locks 2.3.2).

Keep the ^2.3 constraint. Without it, Composer can select an older version on an older Sylius, and 1.x does not work.

Step 2: Register the bundle​

Symfony Flex usually adds this line. Check config/bundles.php and add it if it is missing:

// config/bundles.php
return [
// ...
Monei\SyliusPlugin\MoneiSyliusPlugin::class => ['all' => true],
];

Step 3: Import the configuration​

# config/packages/monei_sylius.yaml
imports:
- {resource: '@MoneiSyliusPlugin/config/config.yaml'}

The file is empty in 2.0.0. The import lets later versions add configuration without an extra step.

Step 4: Import the routes​

# config/routes/monei_sylius.yaml
monei_sylius:
resource: '@MoneiSyliusPlugin/config/routes.yaml'

Do not add a prefix, and do not put this import under the shop's /{_locale} prefix. The plugin serves the Apple Pay domain association file, and Apple reads it only at the domain root: /.well-known/apple-developer-merchantid-domain-association.

Step 5: Clear the cache​

bin/console cache:clear
bin/console assets:install

assets:install copies the payment method logos. Sylius-Standard runs it after each composer install.

Step 6: Run the database migration​

Run the migration when installing or upgrading to version 2.3.0, including on stores using manual keys.

bin/console doctrine:migrations:migrate

For PostgreSQL, see the plugin migration instructions.

Web server and content security policy​

  • Hardened web server configurations often block paths that start with a dot, for example nginx location ~ /\.. Let /.well-known/ through to public/index.php, or Apple Pay cannot read the domain association file.
  • The embedded components load https://js.monei.com/v3/monei.js. If your store sends a content security policy, allow that origin.
  • To show your theme's web font inside the card fields, serve the font files with Access-Control-Allow-Origin: https://js.monei.com. Without it, the card fields use the fallback fonts of the same font stack.

Connect with MONEI​

  1. In the Sylius admin, go to Configuration → MONEI and click Connect with MONEI.
  2. MONEI opens in a new tab. Sign in and approve the connection.
  3. Return to Sylius, check the result, and select credentials for each payment method.

The plugin stores a scoped API key and signing secret for each connected mode. If only Test is available, connect again after MONEI approves your account to get Live credentials.

After the connect, the MONEI page shows each connected mode with its account and the last 4 characters of its key, the last Connect result, and a Disconnect button.

Connection URL requirements

If the page shows Use manual keys, enter the keys manually. This can happen if the store lacks an eligible HTTPS host, its install path has more than two segments, or the URL includes index.php.

Disconnect removes connected credentials for both modes. Methods using them disappear from checkout, and Sylius blocks captures and refunds for those payments. Resolve outstanding payments before disconnecting or switching a method to a different account or mode. You can revoke the keys separately in MONEI Dashboard → Settings → API Access.

Configure​

Create one Sylius payment method for each MONEI payment method that you offer.

  1. In the Sylius admin, go to Configuration → Payment methods.

  2. Click Create and select MONEI.

  3. Fill in the fields:

    FieldDescription
    CredentialsConnected Live account, Connected Test account or Manual API key. The plugin gets the Account ID from the connected mode you select.
    MONEI payment methodCard, Bizum, PayPal, Apple Pay / Google Pay, MB WAY or Multibanco.
    ModeHosted payment page or Onsite (monei.js). MB WAY and Multibanco are hosted only. See Payment flows.
    Authorize only, capture laterThe payment is held, and you capture it from the order page. Card, Apple Pay / Google Pay and PayPal only. See Capture mode.
    Card field layoutPlugin 2.1.0 or later. Separate fields (default: card number, expiry date and CVC) or Single line. Card in onsite mode only. See Embedded components.
    Order ID prefixOptional. Added before the order number that MONEI receives. At most 20 letters, digits, - and _. See Order ID prefix.
  4. Enable the payment method in your channels.

Make sure the payment method is active in MONEI Dashboard → Settings → Payment methods.

Advanced: enter API keys manually​

On the payment method, select Manual API key under Credentials. Get the credentials in MONEI Dashboard → Settings → API Access.

  • API key. Use a pk_test_... key for test payments or a pk_live_... key for live payments. The form checks the key's format.
  • Account ID. Optional. Use the ID for the same account and mode as the key. In onsite mode, this enables inline payment at checkout. From plugin 2.4.0, it also links the payments of logged-in buyers to MONEI customers. Without it, a manual method links no customer.

Existing manual methods keep their credentials on upgrade. Saving a method with connected credentials clears its saved manual key and Account ID.

Order ID prefix​

MONEI refuses a new payment for an order ID that already has a paid or authorized payment. This check never expires. When several stores, or a staging copy of your store, use the same MONEI account, give each one a different prefix. Otherwise order number 000001 of one store blocks order number 000001 of the other.

The MONEI order ID is the prefix and the order number. For MB WAY, Multibanco and PayPal, the plugin also adds the Sylius payment id, so that a buyer can change method after opening a MONEI page. MONEI accepts at most 40 characters: letters, digits and _ @ . / # & + -. A payment for an order number with other characters (for example a space) fails, and the plugin logs the reason.

Supported payment methods​

Payment methodHosted Payment PageEmbedded componentsAuthorize and capture later
Card (Visa, Mastercard, and more)YesYesYes
BizumYesYesNo
PayPalYesYesYes
Apple Pay / Google PayYesYesYes
MB WAYYesNoNo
MultibancoYesNoNo

Apple Pay and Google Pay are one MONEI payment method: one Sylius payment method offers both. The Apple Pay or Google Pay button only appears for a buyer whose device and browser can pay with that wallet. Apple Pay also needs your domain registered. See Apple Pay domain.

( / ) runs on MONEI.

Payment flows​

The buyer selects a MONEI payment method in the checkout and places the order. The plugin then creates a MONEI payment for the Sylius payment. When the buyer pays again, the plugin reuses a pending MONEI payment, or cancels it and creates a new one when the method or the amount changed.

The Mode of each payment method sets how the buyer pays.

Hosted Payment Page​

The plugin sends the buyer to the MONEI . The buyer pays there and comes back to your store. MB WAY and Multibanco use this mode only.

Embedded components (monei.js)​

With Onsite (monei.js), the buyer pays in your store. After the order is placed, the plugin shows a payment page in your store with the monei.js component of the method: card fields with a cardholder name, the Bizum or PayPal button, or the Apple Pay and Google Pay button. From plugin 2.1.0, the card fields look like your theme's own inputs: they take the label, box, size, colours, font and focus style of the cardholder name field. By default, the card number, expiry date and CVC are separate fields; set Card field layout to Single line for one field. 3D Secure and the Bizum approval run in the monei.js modal. Then the buyer goes back to the same return page as in the hosted flow.

Connected credentials include an Account ID. With manual credentials, enter the Account ID to show the component on the checkout's last step (Complete), under the order summary, as in the MONEI WooCommerce plugin. The card fields go above Place order; the Bizum, PayPal or wallet button takes the place of Place order. The buyer pays there, and the next page only shows "Processing payment…" until 3D Secure or the thank-you page. The payment token stays in the buyer's browser. Without an account ID, or when the component cannot load, the buyer pays on the payment page after the order, as before. MONEI shows the inline Bizum button only to buyers it locates in Spain; other buyers pay Bizum on the payment page.

Payment status​

The plugin reads the status from the MONEI API on the return page, on each callback and before each admin action. It does not trust the callback body. A pending MONEI payment keeps the Sylius payment new, so the buyer can pay again.

MONEI statusSylius payment
Succeededcompleted
Authorizedauthorized
Pendingnew (no change)
Failed, Expiredfailed
Canceledcancelled
Refundedrefunded
Partially refundedcompleted (Sylius has no partial state)

  • Amount check. Before it completes or authorizes a payment, the plugin compares the MONEI amount and currency with the Sylius payment. On a difference, it changes nothing and logs a critical message.
  • Expiry. A MONEI payment expires one hour before Sylius may cancel the unpaid order (sylius_order.expiration.order, default 5 days), and after 7 days at most.
  • Order cancel. Before Sylius cancels an order, the plugin checks its MONEI payments. It refuses the cancel when MONEI took the money, cancels a pending MONEI payment, and releases an authorized hold.
  • Synchronous commands. The plugin's payment request commands always run in the web request, also when your store sends the payment_request transport to an async queue. The pay step needs the buyer's IP address and browser, and must get the MONEI payment page URL at once. You do not have to configure this.

Callbacks​

The plugin sets a callback URL on every MONEI payment, so you do not need a webhook in the MONEI Dashboard. MONEI posts each payment result to the Sylius payment notify route:

https://<your store>/payment-methods/<payment method code>?payment=<Sylius payment id>
  • The URL must answer without a redirect. MONEI counts a 3xx answer as a failed delivery. Check your HTTPS redirect, www redirect and proxy rules for this path.
  • Sylius builds the URL from the current request. Behind a reverse proxy or load balancer that ends TLS, configure Symfony's trusted proxies. Otherwise the URL starts with http://, your HTTPS redirect answers MONEI with a 3xx, and the delivery fails.
  • The plugin verifies callback signatures with the signing secret for the connected mode. Manual methods use the API key.
Do not add a MONEI Dashboard webhook for Sylius

Its events carry no Sylius payment id, and the plugin refuses them. The plugin uses only the callback URL that it sets on each payment.

Capture mode​

Without Authorize only, capture later, the buyer is charged when they pay.

With Authorize only, capture later, MONEI the payment: the amount is held, and the Sylius payment is authorized. This applies to card, Apple Pay / Google Pay and PayPal. Bizum, MB WAY and Multibanco always charge at once.

  • Capture: on the admin order page, click Complete on the payment. The plugin the full amount at MONEI. When MONEI refuses, the payment stays authorized and the admin shows MONEI's reason.
  • Release: cancel the order. The plugin cancels the hold at MONEI.
  • MONEI releases an uncaptured hold after some days. See Capture before the authorization expires.

The plugin has no partial capture: a capture is always for the full amount.

Refunds​

  • Without the Refund Plugin: click Refund on a completed payment, on the admin order page. The plugin refunds the rest of the payment at MONEI (the amount minus what MONEI already refunded).
  • With sylius/refund-plugin 2.2 or later: the Refund Plugin replaces the core Refund button. Make full and partial refunds from its refund page, and select the MONEI payment method that paid the order as the refund method. The plugin adds the monei gateway to the Refund Plugin's supported gateways.

The plugin calls MONEI first. When MONEI refuses, Sylius records nothing and the admin shows MONEI's reason.

The admin API follows the same rules: /api/v2/admin/payments/{id}/complete, /api/v2/admin/payments/{id}/refund and /api/v2/admin/orders/{tokenValue}/cancel. A MONEI refusal answers 409 with the reason.

Apple Pay domain​

When you save an enabled Apple Pay / Google Pay payment method, the plugin registers your domains with MONEI for Apple Pay:

  • the hostname of each channel of the payment method;
  • the host of the admin request, for a channel without a hostname.

When MONEI refuses a domain, the admin shows a warning and the save still completes. Apple Pay does not show on that domain until it is registered. Save the payment method again to retry.

When you add a channel to the payment method or change a channel hostname, save the payment method again to register the new domain. Apple Pay needs HTTPS and the route import. Google Pay needs no domain registration.

MONEI customers​

From plugin 2.4.0, the plugin links the payments of each logged-in buyer to a MONEI customer: one customer per Sylius customer, MONEI account and mode (test or live). All MONEI methods link, hosted and onsite, when the payment method has an Account ID. Connected methods always have one. For a manual method, enter the Account ID of the account that issued the key. Guest orders are not linked.

The MONEI customer gets the buyer's email, name and phone (the billing phone when the buyer has none). A customer deleted in the MONEI Dashboard does not block the next payment: the plugin creates the payment without the customer, and links a new customer on a later payment.

When you delete the account of a buyer in the Sylius admin (Customers, open the customer, then Delete in its actions menu) or with the admin API, or when your code removes a Sylius customer, the plugin deletes the buyer's MONEI customers after Sylius saves the delete. It deletes the customer in each MONEI account and mode where it exists.

  • One try per delete. When MONEI or your database fails during that delete, the plugin logs an error with the MONEI customer ID, account ID and mode. Delete that customer in the MONEI Dashboard.
  • Keys must still be configured. The plugin deletes a MONEI customer with a key of its account and mode, from the Connect connection or any MONEI payment method. When no method or connection has a key for that account and mode any more, the plugin logs an error and keeps the link.
  • Account ID of manual keys. The plugin checks only the format of a manual Account ID. An ID of another account than the key's makes duplicate customers that the plugin cannot delete.
  • Run the migration. Version 2.4.0 adds the monei_customer table. See Upgrade to version 2.4.0.

Limits​

  • Currencies with 2 decimals only. Sylius stores every amount with 2 decimals. A payment in a currency with 0 or 3 decimals fails before any call to MONEI.
  • Actions in the MONEI Dashboard are not recorded in Sylius. MONEI sends no callback for refunds, captures, voids or expiry. The return page and the plugin's admin actions still read the current MONEI status.
  • A refund in the MONEI Dashboard blocks the next Refund Plugin refund. With sylius/refund-plugin, the plugin refuses a MONEI refund when MONEI refunded more than Sylius recorded. Record the Dashboard refund first, with an offline refund method, then make the next refund.
  • Captures and refunds use the payment method’s current credentials. Keep the method configured with the account and mode that created the payment if you still need to capture or refund it.
  • Changing Authorize only on a payment method with open payments. A buyer who pays again after the change gets a new payment of the new type. When the old payment is already with the (for example a card payment in 3D Secure, or an open PayPal approval), MONEI cannot cancel it. The buyer then sees that a payment is in progress until the old payment ends or expires.
  • Duplicate refunds. MONEI ignores a second refund of the same payment and the same amount sent within 3 seconds. The plugin then refuses the refund and shows a message, so Sylius does not record a refund that MONEI did not make. Check the payment in the MONEI Dashboard before you try again.
  • A payment that is already with the payment processor cannot be cancelled. This applies, for example, to an open Multibanco reference, an open MB WAY request or an open PayPal approval. Such a payment stays payable until it expires:
    • After a method change. A buyer opens a Multibanco, MB WAY or PayPal page and then pays with another method. The buyer can still pay the old payment. If the buyer pays it, the plugin logs a critical message: refund that payment in the MONEI Dashboard. The same applies when the buyer changes to a payment method of another gateway, because no MONEI code runs on that change.
    • After an order cancel. The order cancel goes on and the admin shows a warning. If the buyer pays the payment later, the plugin logs a critical message: refund it in the MONEI Dashboard.
  • Payment deadline. A pay attempt in the last hour before the order's payment deadline gets a MONEI expiry up to 1 hour after that deadline, because the plugin gives each MONEI payment at least one hour. A payment that succeeds on an order that Sylius already cancelled changes nothing in Sylius, and the plugin logs a critical message. Refund it in the MONEI Dashboard.
  • A hold voided in the MONEI Dashboard blocks the order. MONEI then refuses every new payment for that order ID, so the buyer cannot pay that order again. Create a new order.
  • A refused order cancel does not record the payment. When the admin cancels an order and MONEI says that it is paid, the cancel is refused, but the payment stays unpaid in Sylius until the callback or the next sylius:cancel-unpaid-orders run records it.
  • Orders with more than one MONEI payment. When an order cancel releases the hold of one payment and is then refused for a second payment, Sylius rolls back, but the first hold is gone at MONEI. Sylius orders normally have one payment.
  • Refund Plugin steps after MONEI. With sylius/refund-plugin, MONEI refunds first. If a later step fails (credit memo, email, database), MONEI returned the money but Sylius has no record. The next MONEI refund of that order is refused. Record the missing refund with an offline refund method.
  • No protection against parallel actions in the admin API and the unpaid-orders command. The admin pages, the pay step, the return page and the callback wait for each other on the same payment. The admin API and sylius:cancel-unpaid-orders do not.

Upgrade to version 2.4.0​

Run composer require monei/sylius-monei-plugin:^2.4, then apply the migration and clear the cache. The migration adds the table that links Sylius customers to MONEI customers. Run it also when you use manual keys.

Upgrade to version 2.3.0​

If you already use version 2.x, run composer require monei/sylius-monei-plugin:^2.3 and apply the migration. You can keep using manual keys or connect your store and select connected credentials for each payment method.

Upgrade from 1.x​

Version 1.x did not load in Sylius. It failed before any call to MONEI, so it took no payment. There is no data to migrate.

  1. Make sure that your store runs Sylius 2.2.13 or later on the 2.2 line, or 2.3.3 or later: composer update sylius/sylius --with-all-dependencies. Version 2 does not support Sylius 2.1.
  2. Make sure that sylius_payment and sylius_order use the symfony_workflow state machine adapter. See State machine adapter.
  3. Delete the 1.x route import, usually config/routes/monei.yaml (it imports @MoneiSyliusPlugin/config/routes.xml under /monei). Do this before you update: version 2.0.0 has no routes.xml, and composer require clears the cache.
  4. Update the package: composer require monei/sylius-monei-plugin:^2.3.
  5. Add the configuration import and the route import.
  6. If you have a payment method with the MONEI gateway from 1.x, delete it.
  7. Run the migration.
  8. Create one payment method for each MONEI payment method. See Configure.

What changed:

  • The gateway config keys sandbox and integration_type are removed. The API key prefix selects test or live mode. The 1.x account_id is not used; plugin 2.2 has a new optional Account ID setting for inline payment. The mode (hosted or onsite) is set per payment method.
  • Translations are English and Spanish. 1.x also had Catalan and French.
  • The plugin uses the Sylius Payment Requests API, not Payum.

Troubleshoot​

cache:clear fails after the update​

  • An error about routes.xml means that the 1.x route import is still there. Delete it, usually config/routes/monei.yaml. See Upgrade from 1.x.
  • An error that names sylius_payment or sylius_order means that the graph uses another state machine adapter. See State machine adapter.

A payment method does not appear at checkout​

A payment stays unpaid after the buyer paid​

  • Check that the callback URL is reachable from the internet and answers without a redirect.
  • Behind a proxy that ends TLS, configure Symfony's trusted proxies.
  • A Multibanco payment stays unpaid until the buyer pays the reference.

Read the plugin logs​

The plugin logs on the Monolog channel monei. Send its critical messages to an alert: each one is a payment that needs a manual action in the MONEI Dashboard.

Before you go live​

  • On each live payment method, select Connected Live account or enter a live key manually.
  • Make sure that you have at least one active payment method, and that its Sylius payment method is enabled in your channels.
  • Make sure that the callback URL of your live store answers over HTTPS without a redirect.
  • Give each store that shares your MONEI account a different order ID prefix.
  • For Apple Pay, set the live hostname on your channels and save the Apple Pay / Google Pay payment method again. See Apple Pay domain.
  • Send the critical messages of the monei log channel to an alert.