Jump to content

Problem With Payment Module


Recommended Posts

Hello,

 

I hope someone can help with this issue that i have with Klarna payment module(no one else is probly using it currently on prestashop).

 

We have webstores running multiple versions 1.6.1.(1-3), all of them have the same problem.

 

Uncaught TypeError: price.toFixed is not a function
^^
  ->This error occurs on default installation of klarna payment module and while using the klarna checkout. (When customer is pressing - / + or del on product).
  ->The Error causes klarna's checkout frame to not refresh(it should refresh on every modification on the cart).
  ->Plenty of customers continue to the payment after modifying their cart without refreshing page(only solution to  refresh klarna without coding).
  ->This event causes payment errors, i.e when customers actually pay the original cart price instead of the one they  ordered.
 
 
So i tracked the problem to -> tools.js 
 
inside tools.js there is a function -> formatCurrency
 
row 63 has line of price = parseFloat(price.toFixed(10));
 
for some reason klarna's module doesn't want to work with that line of code.
so what i've tried is the two methods below.
Both of them does make the klarna checkout to refresh properly when shopping cart is modified (-/+/del products).
 
-> price = parseFloat(price).toFixed(10);
 
OR
 
-> price = parseFloat(price).toFixed(10);
price = parseInt(price, 10);
 
 
Problem is that i don't know if this has an effect on something else or is it even proper way of solving the error.
 
also after this fix the klarna checkout finds a new error "Uncaught TypeError: Cannot read property 'postMessage' of null" which is in one of the klarna's side js files that are unreachable for me to check.
 
Any thoughts? 
 
Link to comment
Share on other sites

Hi bellini,

 

Yes the problem only occurs with Klarna payment module, because that is the only payment method we currently have (we've had others before without this problem).

 

Other modules wouldn't probly have this problem since this one uses their own checkout part in a iframe.

 

i have a image here to make the problem maybe more clearer. (in the picture i have added the quantity of one product in the shopping cart, so you can clearly see that the amounts doesn't match because the iframe doesn't reload).

7cb67d8d91.png

Link to comment
Share on other sites

/js/tools.js line 63

    price = parseFloat(price.toFixed(10));

which is inside the javascript function formatCurrency.  I believe this is a theme issue and not a payment module issue.  Perhaps bankwire does not have a need to use this function, but for some reason your other payment module is trying to use it.

 

You will need debug the module further and see what would be causing it.

Link to comment
Share on other sites

  • 2 weeks later...
 

okay i've done some more inspection to this, seems like the problem is not in our theme but in the settings.

 

The module is looking for a value from json data that 

  1. free_shipfalse
  2. or
  3. free_ship: true

 

Here is where the problem occurs,

 
if (json.free_ship > 0 && !json.is_virtual_cart)
{
$('.cart_free_shipping').fadeIn();
$('#free_shipping').html(formatCurrency(json.free_ship, currencyFormat, currencySign, currencyBlank));
}
 
We use free shipping in our stores, so free_ship will be true. so the module is just checking if it is > 0 and that if happens.
In that if it is trying to look for #free_shipping html which doesn't exist in our stores. (because #free_shipping doesn't exist the js breaks here on the formatcurrency and won't reload the checkout)
 
So, if i set the shipping cost, this problem doesn't occur and the module works fine.
(this will not do it for us.)
 
Now, i'm wondering if it is okay to add this to the if sentence 
if (json.free_ship > 0 && !json.is_virtual_cart && json.free_ship != true)
 
this would make the module work (reload when shopping cart quantities are changed) with free shipping.
Link to comment
Share on other sites

 

 

okay i've done some more inspection to this, seems like the problem is not in our theme but in the settings.

 

The module is looking for a value from json data that 

  1. free_shipfalse
  2. or
  3. free_ship: true

 

Here is where the problem occurs,

 
if (json.free_ship > 0 && !json.is_virtual_cart)
{
$('.cart_free_shipping').fadeIn();
$('#free_shipping').html(formatCurrency(json.free_ship, currencyFormat, currencySign, currencyBlank));
}
 
We use free shipping in our stores, so free_ship will be true. so the module is just checking if it is > 0 and that if happens.
In that if it is trying to look for #free_shipping html which doesn't exist in our stores. (because #free_shipping doesn't exist the js breaks here on the formatcurrency and won't reload the checkout)
 
So, if i set the shipping cost, this problem doesn't occur and the module works fine.
(this will not do it for us.)
 
Now, i'm wondering if it is okay to add this to the if sentence 
if (json.free_ship > 0 && !json.is_virtual_cart && json.free_ship != true)
 
this would make the module work (reload when shopping cart quantities are changed) with free shipping.

 

 

Actually looked into this again, tried to create that #free_shipping element, that wasn't the problem. The problem was that the module is trying to turn true/false value into "formatcurrency".

Link to comment
Share on other sites

 

Don't know if anyone is reading this topic, but it is kind of solved.

 

My last post pretty much explains the bug that is actually in the klarna payment module.(anyone else having this bug will have to hack past that if sentence or wait for fix)

 

I tested the bug with clean install of prestashop and confirmed that it is bugging with the clean install too.

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...