white-nl / commerce-mollie-plus

Mollie Klarna integration for Craft Commerce
Other
3 stars 4 forks source link

Unable to pake a payment when discount has applied for the order line item #4

Closed nikolenko-dmitriy closed 2 years ago

nikolenko-dmitriy commented 2 years ago

We have the situation when order cannot be paid because of this error:

Order line 1 is invalid. VAT amount is off. Expected VAT amount t (truncated...)\n

Here is the full response from Mollie 2022-02-03_18-41

This order has only 1 line item with quantity 35 and the applied discount.

After some investigation we found that this happens when because of the discount: 2022-02-03_18-29

A dump of the result of the method getItemListForOrder contains this: 2022-02-03_18-33

As you can see, the discount was added as a separate line item, because it's an order adjuster.

Afterwards we tried to disable the discount: 2022-02-03_18-32 and error from Mollie wasn't triggered anymore.

Also there are no extra items in the result of the method getItemListForOrder when discount is disabled 2022-02-03_18-29_1

It makes me think that in case the discount is applied the vatAmout is calculated by the wrong formula, But I didn't find yet the exact reason.

Also there are some suggestions regarding discounts:

  1. Can we avoid discounts to be added as separate line items for the order in Mollie? Probably it's better to use discountAmount property on the lines array?
  2. Or if we still need a separate order line, maybe we should split up lines with a parameter "type": "physical" and "type": "discount", like in the example in docs
WHITE-developer commented 2 years ago

Hey @nikolenko-dmitriy , Sorry for the late reaction. We just released a new version where the lineItem discount is added as the discountAmount.