3 min. read
Categories: News Technical
Refund Plugin

Hello everyone!

Today is the second time I am going to talk about Sylius plugins developed by the Sylius Core Team. Since we have covered the topic of reordering a previously placed order by a customer, let’s assume that the delivered product was damaged or its variant is not the one you have ordered.

Here comes the Refund Plugin!


Before the Refund Plugin was released, Sylius had allowed refunding an order once the customer contacted the administrator personally and had discussed every detail via e-mail or phone. What’s more, refunding whole order’s total was the only possible option. Briefly speaking, it was up to two individuals to begin, endure and complete the whole process with a negligible impact of Sylius itself.

What was wrong with that approach? Firstly, it did not offer a wide range of possibilities and business value. Secondly, Sylius purpose is Catalyze trade with technology – the previous version of refund functionality was hardly assembling any eCommerce domain elements. Hence, the necessity of extending such an essential feature as refunds was placed high in our backlog.

What is the Refund Plugin?

At first, it is another Sylius extension developed by the Sylius Core Team. Let’s see what it has to offer:

  • Refunding an order once it’s paid
  • The possibility of refunding a partial amount of an order item or a shipment
  • Refunding one order several times – once a whole order’s total is refunded the order becomes fully refunded
  • Generating a credit memo for each refund action and sending it as a PDF document to the customer via e-mail
  • Customer downloading the generated credit memos as PDF files
  • Generating a refund payment that represents shop’s will to refund a specific amount of money in favor of the customer

How does it work code-wise?

The core functionality is based on both commands and events. The business logic process, from receiving a request by a controller to displaying a successful notification, is following:

  • The controller dispatches the RefundUnits command containing payload taken from the HTTP request;
  • The command reaches the RefundUnitsCommandHandler. It is validated and then processed;
  • Each item mentioned in command’s payload is refunded separately, and the UnitRefunded event is dispatched after every successful refund;
  • Once the RefundUnits command is successfully processed the UnitsRefuned event is dispatched;
  • The UnitsRefunded event is processed by two process managers – CreditMemoProcessManager and RefundPaymentProcessManager. The first one creates a document called Credit Memo and the other one is responsible for generating a Refund Payment.

Apart from the refund feature, the plugin involves a lot of both custom and Resource-related logic. As usual, since the Refund, Credit Memo and Refund Payment entities are Sylius resources, the basic CRUD actions and grid are defined in the config.yml file. On the other hand, features such as downloading a credit memo or marking a refund payment as completed have their own related single action controllers.

How to get it?

Like any other Sylius plugin developed by the Sylius Core Team, the Refund Plugin is an open-source project available via Github, which means that cloning or forking the repository can be done anywhere, anytime, by everyone. We are elated to deliver another customizable feature to our community. Feel free to keep us up to date with your user/developer experience – our sole focus is to create software which is as developer friendly as possible and thus we are looking forward to receiving your feedback.

Happy refunding!

More from our blog
Business News Technical 3 min read 28.09.2020
Get ready for global sales & operations with the most advanced payment solution from the famous fintech giant, now available in Sylius out of the box. Read More
Business News 3 min read 14.09.2020
We proudly present to you the latest version of the Sylius eCommerce Platform – 1.8, which comes with a brand new, unified API powered by API Platform, Loyalty points system for Sylius Plus, and as you can probably see, a brand new sylius.com website! Numbers This new release is a… Read More
Business Ecosystem News 3 min read 13.08.2020
Read why the French market leader trusted Sylius in a strategic re-platforming process to get a competitive eCommerce advantage. Read More