Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5453 by techgeekh
18 Jan 2018, 10:14
Hello, I am currently trying to implement a gift voucher feature where every user will have a virtual wallet attached to their account.

I am trying to get an idea if there is a better way or a built in way to do this.

Note : We are using React.js on the frontend and using aimeos as a backend via the REST API.

My way of thinking is to create for example 4 products with a custom type "Voucher"
- 100 £ Voucher
- 50 £ Voucher
- 25 £ Voucher
- 10 £ Voucher

At first when the user purchases the gift voucher let's say for example a "100 £" voucher, during the purchase process, the user will not get asked to enter a shipping address and will not have the ability to pay for the voucher with their account balance.

For this I was thinking of implementing a separate process to pay for vouchers and not use the default cart behaviour process, so that the user can choose the voucher and directly pay for it.

After the payment process is complete, the user will get an email that contains the voucher code, he can then either apply the voucher to their account or send it to a friend.

For this I was thinking of creating a separate table in the database to store a randomly generated voucher code that we are going to generate on the backend and the voucher value and a boolean so that the code can only be used one time only.

After the voucher code is applied on an account, the account balance will change accordingly to the voucher value.

To hold the account balance I was thinking of creating another table in the database that is linked to the user id.

When the user tries to purchase products from the site, and if the account balance is greater or equal to the cart total, the user can use their account balance as a payment method and pay for their cart.

For this I was thinking of creating a custom payment service named for Example "Account Balance" so that when we create an order we set the payment method to that service.
#5465 by aimeos
19 Jan 2018, 11:32
We would suggest that solution:
- Create a new product type "voucher"
- Implement a decorator for the basket controller like the existing ones that handles the new voucher products (
- Generate the voucher codes in that decorator and add them as order product attributes
- Often, customers will have mixed baskets with voucher+articles so they should be able to buy them together
- Extend the payment related e-mail to show the voucher codes if the order has been payed (same as downloads)
- Add a new table e.g. "users_balance" that will contain the amounts that have been bought and redeemed (like a bank account with contains each "transaction"), the reason and the voucher code
- Implement some code so users can add vouchers resp. their amounts to their account balance. There you can check if a voucher has already been redeemed
- Implement a new payment service provider (e.g. AccountBalance) that calculates the latest balance
- Customers should be able to pay partly with their balance if the have not enough. This requires Aimeos 2018.01 because there it's possible to have multiple payments per order
- Create a pull request with your changes to get them into the Aimeos Core :-)