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!

Introduction

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!

Tags:
Share:
More from our blog
Technical 3 min read 04.12.2024
Here’s everything you had to know about the first major release since 2017! Over 7 years after the first major release, on Nov 12, 2024, we have released Sylius 2.0.0. We had a great opportunity to announce it first at SyliusCon in Lyon, but now, as we are back to… Read More
3 min read 22.11.2024
The emotions start to settle after SyliusCon, and it’s time to reflect on this incredible milestone in our journey. Why a milestone? Because SyliusCon exceeded our expectations in every possible way. We broke attendance records and brought together the key figures of our community, numerous partners, freelancers, and simply all… Read More
Cloud 3 min read 17.06.2024
We are thrilled to announce that we just signed a strategic partnership with Platform.sh, and as a result, we are extending our offer with Sylius Cloud powered by Platform.sh. Platform.sh is a modern Platform-as-a-Service (PaaS) solution that allows businesses to leverage the cloud environment without losing access to the code… Read More
Comments