Post by kyrre » Thu Aug 01, 2013 5:12 pm

Hi all

I am situated in Norway, and the Klarna core module is not working properly.

I have made a test order and the prices sent to Klarna are incorrect. If the price in the shop is NOK 299, it's sent as NOK 2.99 to Klarna. Obviosly this causes a lot of job for me because I have to manuelly edit the invoice before it's sent to the customer.

Please see the attachments. Don't mind the language - just look at the prices :)

Is there a solution to this?

Attachments

klarna-order-incorrect.JPG

This is from Klarna admin. - klarna-order-incorrect.JPG (30.97 KiB) Viewed 1536 times

klarna-oc-admin-order-correct.JPG

This is from OC admin. - klarna-oc-admin-order-correct.JPG (49.45 KiB) Viewed 1536 times


Kind regards
Kyrre
http://www.ledstrips.no


New member

Posts

Joined
Mon Jul 16, 2012 10:20 pm

Post by RonnyOlsen » Thu Aug 08, 2013 3:40 pm

I've already given you a temporary solution to this issue Kyrre, but I figured that other might experience this as well. This solution is more permanent as well, so you should change to this one ;) I'l give a short explanation of the issue in itself here for others to see, and a solution to the problem :)

The main reason that this happens is because of the way the Klarna module treats the value before its sent to Klarna. When a price is sent to Klarna it should be sent as price * 100. In other word 100 EUR is sent as the value 10000. This is because Klarna wants an integer and not floating point numbers. And to be able to keep the decimals the number is as mentioned multiplied by 100.

When the Klarna module prepare the price to be sent to Klarna it fails on one major point. It does not take into calculation the numbers of decimals set up in the currency object. For some reason it assumes that you have your prices with 2 decimals an basically removes the decimal point. Basically 100.00 turn into 10000 while 100 just becomes 100.

\catalog\controller\payment\klarna_invoice.php
Line 288
Change from:

Code: Select all

'price' => (int)str_replace('.', '', $this->currency->format($product['price'], $country_to_currency[$order_info['payment_iso_code_3']], '', false)),
To

Code: Select all

'price'    => (int)str_replace('.', '', $this->currency->format($product['price'], $country_to_currency[$order_info['payment_iso_code_3']], '', false)) * (100/(pow(10,$this->currency->getDecimalPlace($country_to_currency[$order_info['payment_iso_code_3']])))),
Line 309
Change from

Code: Select all

'price' => (int)str_replace('.', '', $this->currency->format($total['value'], $country_to_currency[$order_info['payment_iso_code_3']], '', false)),
To

Code: Select all

'price'    => (int)str_replace('.', '', $this->currency->format($total['value'], $country_to_currency[$order_info['payment_iso_code_3']], '', false)) * (100/(pow(10,$this->currency->getDecimalPlace($country_to_currency[$order_info['payment_iso_code_3']])))),

\catalog\controller\payment\klarna_account.php
Line 412
Same as above on line 208
Line 433
Same as above on line 309

What this fix does is basically to take into account the numbers of decimals and act thereafter.

Hope this works out for all of you who experience this issue until its fixed in the module.

Newbie

Posts

Joined
Thu Aug 01, 2013 9:25 pm
Who is online

Users browsing this forum: No registered users and 47 guests