sylius / refund-plugin
Plugin provides basic refunds functionality for Sylius application.
Installs: 1 296 330
Dependents: 12
Suggesters: 1
Security: 0
Stars: 65
Watchers: 14
Forks: 71
Open Issues: 20
Type:sylius-plugin
Requires
- php: ^8.1
- knplabs/knp-snappy-bundle: ^1.7
- myclabs/php-enum: ^1.7
- php-http/message-factory: ^1.1
- sylius/resource-bundle: ^1.9
- sylius/sylius: ~1.13.0 || ~1.14.0
- symfony/messenger: ^5.4.21 || ^6.4
Requires (Dev)
- behat/behat: ^3.6.1
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/exclude-specifications-extension: ^0.2 || ^0.3
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.2
- phpspec/phpspec: ^7.2
- phpstan/phpstan: ^1.6
- phpstan/phpstan-webmozart-assert: ^1.1
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- sylius-labs/coding-standard: ^4.2
- sylius-labs/suite-tags-extension: ~0.1
- symfony/browser-kit: ^5.4.21 || ^6.4
- symfony/debug-bundle: ^5.4.21 || ^6.4
- symfony/dotenv: ^5.4.21 || ^6.4
- symfony/intl: ^5.4 || ^6.4
- symfony/web-profiler-bundle: ^5.4.21 || ^6.4
- symfony/webpack-encore-bundle: ^1.15
- 2.0.x-dev
- 1.6.x-dev
- v1.6.0
- 1.5.x-dev
- v1.5.0
- 1.4.x-dev
- v1.4.0
- 1.3.x-dev
- v1.3.1
- v1.3.0
- 1.2.x-dev
- v1.2.1
- v1.2.0
- 1.1.x-dev
- v1.1.2
- v1.1.1
- v1.1.0
- 1.0.x-dev
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-RC.11
- v1.0.0-RC.10
- v1.0.0-RC.9
- v1.0.0-RC.8
- v1.0.0-RC.7
- v1.0.0-RC.6
- v1.0.0-RC.5
- v1.0.0-RC.4
- v1.0.0-RC.3
- v1.0.0-RC.2
- v1.0.0-RC.1
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- 0.5.1
- 0.5
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4
- 0.3
- 0.2
- 0.1.2
- 0.1.1
- 0.1
- dev-upmerge/1.6_2.0
This package is auto-updated.
Last update: 2024-12-17 02:33:22 UTC
README
Refund Plugin
This plugin provides basic refunds functionality for Sylius application.
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
Installation
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!
-
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 -
Apply migrations to your database:
bin/console doctrine:migrations:migrate
-
Run
yarn encore dev
oryarn encore production
-
Default configuration assumes enabled PDF file generator. If you don't want to use that feature change your app configuration:
# config/packages/sylius_refund.yaml sylius_refund: pdf_generator: enabled: false
Otherwise, check if you have wkhtmltopdf binary. If not, you can download it here.
In case wkhtmltopdf is not located in
/usr/local/bin/wkhtmltopdf
modify theWKHTMLTOPDF_PATH
environment variable in the.env
file:WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf # Change this! :)
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.
Payment requirements
By default to refund your order, you need to have at least one available payment method configured with offline
gateway.
In case your custom refund logic allows a different type of gateway (for example stripe
), you should modify the specific parameter,
as shown below:
# config/services.yaml parameters: sylius_refund.supported_gateways: - offline - stripe
Online refund logic should be implemented if you need it.
As the first try for the possible customization, you can check out Sylius\RefundPlugin\Event\UnitsRefunded
event.
Post-refunding process
After units are refunded, there are multiple other processes that should be triggered. By default, after units refund, there should be CreditMemo and RefundPayment generated. As they're strictly coupled with each other, RefundPayment is always created after the CreditMemo. Moreover, if RefundPayment fails, related CreditMemo should not be created as well.
Sylius\RefundPlugin\ProcessManager\UnitsRefundedProcessManager
service facilitates the whole process. If you want to add one or more steps to it, you should create
a service implementing Sylius\RefundPlugin\ProcessManager\UnitsRefundedProcessStepInterface
, and register if with proper tag:
App\ProcessManager\CustomAfterRefundProcessManager: tags: - { name: sylius_refund.units_refunded.process_step, priority: 0 }
Tagged services would be executed according to their priority (descending).
Supported branches
1.4
(v1.4.*) - security fixes1.5
(v1.5.*) - bug fixes, improvements1.6
(v1.6.*) - new features2.0
(v2.0.*) - new features, removing deprecations, BC breaks
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
.