Basic refunds functionality for Sylius
Branch: master
Clone or download
bartoszpietrzak1994 style #117 Add official Sylius plugin badge (Zales0123)
This PR was merged into the 1.0-dev branch.

Discussion
----------



Commits
-------

880086c Add official Sylius plugin badge
Latest commit 7c7a391 Feb 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add CODEOWNERS Oct 5, 2018
bin Initial commit Jul 2, 2018
docs Mention default_bus configuration in installation process Nov 20, 2018
etc/build Initial commit Jul 2, 2018
features
migrations Fix CreditMemo json migration Feb 7, 2019
spec Fix specs due to symfony/messenger changes Dec 17, 2018
src Fix build Dec 17, 2018
tests
.gitignore
.travis.yml Migrations fixes + supplement Feb 8, 2019
LICENSE Add authors and LICENSE file Aug 22, 2018
README.md
behat.yml.dist Migrations fixes + supplement Feb 8, 2019
composer.json Migrations fixes + supplement Feb 8, 2019
easy-coding-standard.neon
easy-coding-standard.yml CS fixes Jul 6, 2018
node_modules
phpspec.yml.dist Refund entity Jul 6, 2018
phpstan.neon Fix phpstan Oct 12, 2018
phpunit.xml.dist Extract FileManager for better credit memo file management Aug 3, 2018

README.md

Refund Plugin

This plugin provides basic refunds functionality for Sylius application.

Screenshot showing order's refund section

Screenshot showing order's credit memos and refund payments

Business value

In contrast to basic Refund functionality delivered by core Sylius bundles, Refund Plugin offers much wider range of possibilities and business scenarios.

Once an Order is paid, an Administrator is able to access Refunds section of a given Order and perform a Refund of chosen items or shipments. What's more, if a more detailed scenario occurs, an Administrator is able to refund an item partially.

From Administrator's point of view, every Refund request results in creating two entities:

  • Credit Memo - a document representing a list of refunded items (downloadable and sent to Customer via .pdf file)
  • Refund Payment - entity representing payment in favour of the Customer

Pre - requirements

In order to be able to generate PDF files of refunds, wkhtmltopdf must be installed. It is used by KnpSnappyBundle and can be configured according to their docummentation.

Installation

  1. Require plugin with composer:

    composer require sylius/refund-plugin

    Remember to allow community recipes with composer config extra.symfony.allow-contrib true or during plugin installation process

  2. Copy plugin migrations to your migrations directory (e.g. src/Migrations) and apply them to your database:

    cp -R vendor/sylius/refund-plugin/migrations/* src/Migrations
    bin/console doctrine:migrations:migrate
  3. Copy Sylius templates overridden in plugin to your templates directory (e.g templates/bundles/):

    mkdir -p templates/bundles/SyliusAdminBundle/
    cp -R vendor/sylius/refund-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
  4. (optional) If you don't use symfony/messenger component yet, it is required to configure one of the message buses as a default bus:

    framework:
        messenger:
            default_bus: sylius_refund_plugin.command_bus

Beware!

This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the legacy installation instruction. However, we strongly encourage you to use Symfony Flex, it's much quicker! :)

Extension points

Refund Plugin is strongly based on both commands and events. Let's take RefundUnitsAction as an example. The whole process consists of following steps:

  • Getting data from request
  • Create a Command and fill it with data
  • Dispatch Command
  • Handle Command
  • Fire Event
  • Catch Event in Listener class

Using command pattern and events make each step independent which means that providing custom implementation of given part of refunding process doesn't affect any other step.

Apart from Events and Commands Refund Plugin is also based on mechanisms derived from core Sylius bundles such as:

Configuration of all elements mentioned above can be found and customized in config.yml file.

Security issues

If you think that you have found a security issue, please do not use the issue tracker and do not post it publicly. Instead, all security issues must be sent to security@sylius.com.