Developer forum

Forum » Integration » Klarna - Bad value: order_tax_amount differs from the calculated value

Klarna - Bad value: order_tax_amount differs from the calculated value

Martin Moen
Reply

We are using the Klarna v3 payment provider, but there is a problem related to discounts.

This is returned from Klarna:
Bad value: order_tax_amount differs from the calculated value

We have decompiled the dll and found the issue:

while (((IEnumerator) enumerator).MoveNext())
          {
            OrderLine current = enumerator.Current;
            if (current.HasType((OrderLineType) 0) || current.HasType((OrderLineType) 5) || current.HasType((OrderLineType) 2))
            {
              cartItemList.Add(new KlarnaCheckout.CartItem()
              {
                Number = current.get_Product().get_Number(),
                Title = current.get_Product().get_Name(),
                Quantity = current.get_AllowOverridePrices() ? 1 : (int) current.get_Quantity(),
                PriceWithVAT = current.get_AllowOverridePrices() ? current.get_Price().get_PriceWithVAT() : current.get_UnitPrice().get_PriceWithVAT(),
                TaxRate = current.get_Price().get_VATPercent(),
                TotalAmount = current.get_Price().get_Price(),
                TotalTaxAmount = current.get_Price().get_VAT()
              });
            }
            else
            {
              bool flag = current.HasType((OrderLineType) 1) || current.HasType((OrderLineType) 3);
              cartItemList.Add(new KlarnaCheckout.CartItem()
              {
                ItemType = flag ? "discount" : "physical",
                Number = flag ? current.get_DiscountId() : current.get_Id(),
                Title = current.get_ProductName(),
                Quantity = 1,
                PriceWithVAT = current.get_Price().get_PriceWithVAT(),
                TaxRate = 0.0,
                TotalAmount = current.get_Price().get_Price(),
                TotalTaxAmount = 0.0
              });
            }
          }

As you can see, the tax is hardcoded...
Can anyone in DW please provide a new dll where this is fixed? Support is informed, but we really need the fix ASAP!

1.png

Replies

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply

Hi Martin,

but the taxes should be hardcoded in that case because it is discount orderlines or fixed price orderlines - the product ones are added the tax to the request. Could you please clarify a bit more, may be with order information or with some log from klarna admin portal - what the taxes we are missing.

BR, Viktor.

 
Martin Moen
Reply
More info and log from Klarna in support case Number:CAS-20089-V8K8C7
 
Martin Moen
Reply

The issue is fixed now, we made a temporary fix ourselves, while we wait for the official bug fix from DW (bug number 6505).

All we needed to do in order to make it work, was to replace the hardcoded 0's in tax for discount lines (848 and 849) in the Dynamicweb.Ecommerce.CheckoutHandlers.KlarnaCheckout_v3.dll:

 

You must be logged in to post in the forum