Closed MercuryKojo closed 1 year ago
Thanks a lot for reporting the issue. We did not consider the issue as "Priority" or "Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.
Is it reproducible on the Pimcore demo?
I wasn't able to simulate, can you check if usages
of the given token is still 0?
can you also provide the screenshot of the error message (stack trace or any code/error message)?
Hi @kingjia90 here is the Stacktrace: [2023-03-18T09:57:04.352127+01:00] request.CRITICAL: Uncaught PHP Exception Pimcore\Bundle\EcommerceFrameworkBundle\Exception\VoucherServiceException: "Token has already been used." at /home/.../www/vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/VoucherService/TokenManager/Pattern.php line 140 {"exception":"[object] (Pimcore\Bundle\EcommerceFrameworkBundle\Exception\VoucherServiceException(code: 1): Token has already been used. at /home/.../www/vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/VoucherService/TokenManager/Pattern.php:140)"} []
[2023-03-18T09:57:04.352301+01:00] app.ERROR: Pimcore\Bundle\EcommerceFrameworkBundle\Exception\VoucherServiceException: Token has already been used. in /home/.../www/vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/VoucherService/TokenManager/Pattern.php:140 Stack trace:
Pimcore Demo definitely throws an Error with this steps:
Configure Commercial voucher add commercial car and voucher Checkout until payment and start creditcard payment (but don't complete the payment) Go Back to Cart and Change the amount to 2 (so pimcore will recreate the order) checkout again until Payment select and click on creditcard again and it will throw an error:
Confirming the problem. When one step into the payment, in the backend it would create the order which logs the payment history and there the price is the already discounted as if it applied the voucher and triggers its usage. From user perspective, going back to change the cart should be naturally possible, but i am having some concern about concurrent same one-time vouchers on these pending orders, if we trigger usage only at successfull payments. 🤔 Need digging some more on how to fix this
My thoughts on this: Finishing the original and the recreated order is most likely some unwanted scenario. It is possible though, and to make it traceable and also fixable for customer service we decided to do it that way and keeping both orders.
From that perspective, I think most reasonable fix for that would be to remove the voucher from the original order when recreating the order (and place the information in notes or version notes for traceability)?
@kingjia90 WDYT?
@fashxp had some time to look into it and seems that #121 may fix it
Fixed by #121
Expected behavior
order is recreated and containing the voucher token which is onetime use
Actual behavior
recreate order reapplies the voucher token to the new order without removing it for the source order and throws an error, that the voucher can not be used anymore
Steps to reproduce
add a onetime use voucher to the cart and start a payment return and change cart so the order will be recreated start payment again -> throws exception and the new order has not order items and no voucher