Introduction
The module’s integration allows you to
-
generate vouchers,
-
send them to your loyal customers and
-
let them buy products and services with a discount.
Development
Core
Entity Definitions
The definitions in this module have id discriminators in the range 310-320. |
The VoucherEntityDefinition extends the DiscountEntityDefinition. The DiscountEntityDefinition, on the other hand, extends the AbstractEntityDefinition, the AbstractActivatableEntityDefinition, the AbstractExpensableEntityDefinition, the AbstractCatalogableEntityDefinition and AbstractPurchasableEntityDefinition. See the diagram below:

Via the respective getter-setter pairs, the following information can be retrieved/stored in the database:
Property | Description |
---|---|
freeShipping |
a straight-forward boolean value, identifying if free shipping is included in the voucher or not |
priority |
information about the priority of the voucher |
site |
which site the voucher is applicable for |
The VoucherInvalidationEntityDefinition extends the AbstractEntityDefinition, the AbstractPurchasableEntityDefinition and the AbstractUserableEntityDefinition:

Via the respective getter-setter pairs, the following information can be retrieved/stored in the database:
Property | Description |
---|---|
status |
the status of the current voucher |
voucher |
the voucher this voucher invalidation is |
Spring Data JPA Repositories
The VoucherRepository is the
corresponding Spring Data JPA repository for
the VoucherEntityDefinition.
The extended interfaces are ActivatableRepository and
BaseEntityRepository. See the diagram
below:

The VoucherInvalidationRepository is the
corresponding Spring Data JPA repository for
the VoucherInvalidationEntityDefinition.
The extended interface is
BaseEntityRepository.

Business Services
The VoucherService provides logic for performing various operations with vouchers.
The defined methods allow:
Description | Method |
---|---|
to apply a voucher with the given code for the given cart entity |
applyVoucher() |
to check if the given voucher code is valid |
checkVoucherCode() |
to check if the given voucher could be applied to the given order |
isApplicable() |
Facade
MapperFactoryConfigurers
The VoucherCartMapperFactoryConfigurer
implements the MapperFactoryConfigurer
interface, converting the CartEntityDefinition
into CartVoucherDtoDefinition
.

The conversion is customized.
More about the mapping configurations you may read in the respective Orika guide.
Dto definitions
The CartVoucherDtoDefinition is the
corresponding Dto for the CartEntityDefinition
.
The extended interfaces are 2 - CartDtoDefinition and CartVoucherDtoDefinition. Please. follow the links for better understanding of the inheritance dependencies.

Facades
Some helper methods, related to vouchers, are
defined within the VoucherFacade. Among the functionalities included here, are:
-
to redeem a voucher with the given code against the current user cart
-
to redeem a voucher with the given code against the given cart,
-
to return a list of applied voucher codes for the current cart’s user
-
to return a list of applied voucher invalidations for the order with the given code.
Storefront
The VoucherController handles an HTTP request, expecting a parameter promoCode
to be passed.
For further details on mapping, check the corresponding mapping actuator accessible at /platform/mappings
.