Installation

Plugin requirements

  • Supports Sylius 1.14.

  • Depends on the Sylius Refund Plugin.

  • Currently, it does not support the Symfony workflow; continue using the winzou state machine.

Installation steps

1. Require plugin

composer require sylius/adyen-plugin --no-scripts

2. Enable the Bundle

# config/bundles.php

return [
    ...
    Sylius\AdyenPlugin\SyliusAdyenPlugin::class => ['all' => true],
];

3. Import Configuration

Ensure that the Adyen configuration is imported after the Refund configuration.

# config/packages/_sylius.yaml

imports:
    ...
    - { resource: "@SyliusAdyenPlugin/config/config.yaml" }

parameters:
    ...
    sylius_refund.supported_gateways:
        - offline
        - adyen

4. Import routes

# config/routes.yaml

...
sylius_adyen_plugin:
    resource: "@SyliusAdyenPlugin/config/routes.yaml"

5. Enable logging (Monolog)

Add an adyen channel and wire the provided handler. Keep config minimal in the base file and override per environment.

# config/packages/monolog.yaml
monolog:
  channels: ['adyen']
  handlers:
    # Required: forwards Adyen logs to Doctrine-backed storage exposed by the plugin's log UI
    adyen_doctrine:
      type: service
      id: sylius_adyen.logging.monolog.doctrine_handler
      channels: ['adyen']

when@dev:
  monolog:
    handlers:
      adyen_file:
        type: rotating_file
        path: '%kernel.logs_dir%/adyen-dev.log'
        max_files: 14
        level: debug
        channels: ['adyen']

when@prod:
  monolog:
    handlers:
      adyen_file:
        type: rotating_file
        path: '%kernel.logs_dir%/adyen-%kernel.environment%.log'
        max_files: 30
        level: info
        channels: ['adyen']

6. Extend the ProductVariant entity

<?php
// src/Entity/Product/ProductVariant.php

declare(strict_types=1);

namespace App\Entity\Product;

use Doctrine\ORM\Mapping as ORM;
use Sylius\AdyenPlugin\Entity\CommodityCodeAwareInterface;
use Sylius\AdyenPlugin\Entity\CommodityCodeAwareTrait;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Sylius\Component\Product\Model\ProductVariantInterface;

#[ORM\Entity]
#[ORM\Table(name: 'sylius_product_variant')]
class ProductVariant extends BaseProductVariant implements CommodityCodeAwareInterface
{
    use CommodityCodeAwareTrait;
}

Register the ProductVariant entity

# config/packages/sylius.yaml
sylius_product:
    resources:
        ...
        product_variant:
            classes:
                model: App\Entity\Product\ProductVariant

7. Create or update repositories:

<?php
// src/Repository/PaymentMethodRepository.php

declare(strict_types=1);

namespace App\Repository;

use Sylius\AdyenPlugin\Repository\PaymentMethodRepositoryInterface;
use Sylius\AdyenPlugin\Repository\PaymentMethodRepositoryTrait;
use Sylius\Bundle\CoreBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository;

class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface
{
    use PaymentMethodRepositoryTrait;
}
<?php
// src/Repository/RefundPaymentRepository.php

declare(strict_types=1);

namespace App\Repository;

use Sylius\AdyenPlugin\Repository\RefundPaymentRepositoryInterface;
use Sylius\AdyenPlugin\Repository\RefundPaymentRepositoryTrait;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;

class RefundPaymentRepository extends EntityRepository implements RefundPaymentRepositoryInterface
{
    use RefundPaymentRepositoryTrait;
}

Register repositories

# config/packages/sylius.yaml
sylius_payment:
    resources:
        ...
        payment_method:
            classes:
                repository: App\Repository\PaymentMethodRepository
sylius_resource:
    resources:
        ...
        sylius_refund.refund_payment:
            classes:
                repository: App\Repository\RefundPaymentRepository

8. Copy templates

mkdir -p templates/bundles/SyliusAdminBundle/Order/Show \
         templates/bundles/SyliusShopBundle/Checkout/Complete \
         templates/bundles/SyliusShopBundle/Checkout/SelectPayment \
         templates/bundles/SyliusRefundPlugin/Order/Admin

cp vendor/sylius/adyen-plugin/templates/bundles/SyliusAdminBundle/Order/Show/_payment.html.twig \
   templates/bundles/SyliusAdminBundle/Order/Show/

cp vendor/sylius/adyen-plugin/templates/bundles/SyliusAdminBundle/Order/Show/_payments.html.twig \
   templates/bundles/SyliusAdminBundle/Order/Show/

cp vendor/sylius/adyen-plugin/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig \
   templates/bundles/SyliusShopBundle/Checkout/Complete/

cp vendor/sylius/adyen-plugin/templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_payment.html.twig \
   templates/bundles/SyliusShopBundle/Checkout/SelectPayment/
   
cp vendor/sylius/adyen-plugin/templates/bundles/SyliusRefundPlugin/Order/Admin/_refundPayments.html.twig \
   templates/bundles/SyliusRefundPlugin/Order/Admin/_refundPayments.html.twig

9. Import plugin assets

// assets/admin/entrypoint.js

...
import '../../vendor/sylius/adyen-plugin/assets/admin/entrypoint';
// assets/shop/entrypoint.js

...
import '../../vendor/sylius/adyen-plugin/assets/shop/entrypoint';

10. Install assets

bin/console assets:install public

11. Install and build frontend dependencies

yarn install
yarn encore dev  # or yarn encore prod

12. Clear cache

bin/console cache:clear

Last updated

Was this helpful?