mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
100 stars 53 forks source link

[ISSUE] Order amount does not match when applying discount from coupon codes to shipping costs #643

Closed your-favorite-pm closed 1 year ago

your-favorite-pm commented 1 year ago

Describe the bug When a users adds a coupon code to cart, which also applies a discount to shipping costs, he gets thrown back to cart view with an exception: [2023-05-12T10:17:22+0000] Error executing API call (422: Unprocessable Entity): The amount of the order does not match the total amount from the order lines. Expected order amount to be €250.86 but got €247.36. Field: amount. Documentation: Handling errors — API documentation — Mollie

Used versions

To Reproduce Pre-conditions: Active cart price rule with specificed coupon code which gives a discount (e.g. 10% discount) and applies also to shipping amount (= toggle: Apply to Shipping Amount = yes) Steps to reproduce the behavior:

  1. As a user go to your store front, put any products to your cart
  2. Proceed to cart view / checkout
  3. Apply your coupon code
  4. Try to checkout and place your order

Expected behavior Order is placed, user is on order success page

Actual behavior Order is not placed, user is redirected back to cart, exception is thrown and displayed [2023-05-12T10:17:22+0000] Error executing API call (422: Unprocessable Entity): The amount of the order does not match the total amount from the order lines. Expected order amount to be €250.86 but got €247.36. Field: amount. Documentation: Handling errors — API documentation — Mollie

Screenshots Image 2023-05-23 at 2 21 14 PM

Additional context Issue is related to improper applying discount from coupon code to shipping costs, when using Mollie payment. Mollie module is not checking if any discount has been applied to shipping costs in Magento, so the calculations does not match each others: \Mollie\Payment\Service\Order\Lines\Order::getShippingOrderLine

If the exact same cart price rule (Pre-conditions above) does not apply discount to shipping costs there is no exception and user can place its order (= toggle: Apply to Shipping Amount = no)

Frank-Magmodules commented 1 year ago

Hello there, @your-favorite-pm! It appears that I'm unable to replicate this problem in our test environments. Could you kindly reach out to us directly so that we can investigate it together? It's possible that there might be other plugins interfering with this calculation, as it seems to be functioning correctly on a default Magento setup. Thank you!

Frank-Magmodules commented 1 year ago

Hello there @your-favorite-pm! We've been in touch via email, but I wanted to confirm here as well that we've just released plugin version 2.27.0, which addresses the issue you reported. Thank you once again for reaching out to us directly and for your patience. I will close this issue for now since it has been resolved, but please feel free to reopen it if you encounter any further problems related to this matter.