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
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
Technical 3 min read 11.06.2024
Abstract 1.12 released in Q4 2022 1.13 on Apr 23rd, 2024 (a year later than we anticipated while releasing 1.12) 3859 commits 23 contributors A stabilized Sylius API powered by API Platform It’s been a long and bumpy road. Having it behind our backs was a highway that led Sylius… Read More
Business Ecosystem News 3 min read 06.06.2024
Welcome to the May summary! As an open-source eCommerce framework, Sylius continues to evolve with significant contributions from our vibrant community and valuable product updates. Apart from describing the technical changes, we will also quickly summarize the Sylius Technical Fundamentals & Sylius Polish Community Meetup and eCommerce Day Kaunas, as… Read More
Comments