Jump to content

PayPal USA 1.3.8 Decimal Issue


tdr170

Recommended Posts

As you can see from the code below I am getting 4 decimal places showing in the item amount which leads to PayPal error.

 

Price shows correct in back office, blockcart and shopping cart.

 

 

The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

 

 

This is the code from Chrome inspector as you can see the item amount shows 4 decimal places while the total does not.

I don't really think this is a PayPal issue as I tried with 1.3.3 and 1.3.8 with same result.

Anyone else seen or heard of this issue.

 

(removed sensitive info)

 

<p class="payment_module"> 

<input type="hidden" name="cmd" value="_cart"> 
<input type="hidden" name="upload" value="1"> 
<input type="hidden" name="charset" value="utf8"> 
 
<input type="hidden" name="currency_code" value="USD"> 
<input type="hidden" name="custom" value="854;1"> 
<input type="hidden" name="amount" value="488.95"> 
 
<input type="hidden" name="address_override" value="1"> 
<input type="hidden" name="item_name_1" value="Velox V10 "Pro" 2014"> 
 
<input type="hidden" name="amount_1" value="450.0045"> 
 
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="item_name_2" value="Shipping"> 
<input type="hidden" name="amount_2" value="11.95"> 
<input type="hidden" name="quantity_2" value="1"> 
<input type="hidden" name="tax_cart" value="27">
Edited by tdr170 (see edit history)
  • Like 1
Link to comment
Share on other sites

Found the issue it is the classes/cart.php file changed to version from 1.6.0.9 and the amount is correct however now the order goes through to PayPal, log in, make payment but when you return to site items are still in cart.

The order does show in my PayPal account but not in the back office, so I can not use 1.6 as none of the Payment modules work what the Hell.

Link to comment
Share on other sites

  • 2 weeks later...

No solution to order not showing at this point I think I will have to start all over if I want a 1.6 site, you would think that Presta would respond as I see so many with this issue.
I only hope that I can at least get the customer accounts using the database to show so all the customers want have to recreate their accounts, THIS SUCKS.

Edited by tdr170 (see edit history)
Link to comment
Share on other sites

An order not being created means the Paypal IPN is not either not being received, or is being received but is failing to be processed. 

 

The first thing you need to do is determine if the IPN is even being received.  For this, I always suggest looking at the access logs.

Link to comment
Share on other sites

  • 2 weeks later...

We are having the same issue

any item with currency conversion or sale price rule gets more than 2 digits in the decimals

For example, if an Item is $1 USD and the exchange rate to CAD is 1.2234 and we set the decimal rounding to 2

The cart will show 1.22, but the line item in the paypal form is <input type="hidden" name="amount_1" value="1.2234" /> which paypal rejects as invalid Error: The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

 

This is on paypal Express Checkout.

Link to comment
Share on other sites

We are having the same issue

any item with currency conversion or sale price rule gets more than 2 digits in the decimals

For example, if an Item is $1 USD and the exchange rate to CAD is 1.2234 and we set the decimal rounding to 2

The cart will show 1.22, but the line item in the paypal form is <input type="hidden" name="amount_1" value="1.2234" /> which paypal rejects as invalid Error: The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

 

This is on paypal Express Checkout.

what version of Paypal USA are you using? 

Link to comment
Share on other sites

The other way to fix this is to edit the database tables for ps_products and ps_products_shop, once you click on the table look at the list and you will see that just about all tables with something to do with prices are set like this 20,6 I changed all these to 20,2 and the decimal issue seems to have gone.

Can someone else can check this on their site.

Link to comment
Share on other sites

Hi, I had the same problem. I used prestashop 1.5.5 and paypal usa 1.3.3 . The only way I could fix was changing the template standard.tpl paypal module (/modules/paypalusa/views/templates/hook/standard.tpl).

My shop has three currencies: Colombian pesos (default or main), dollars and euros. Paypal only throws the error when I pay in dollars or euros.

 

Before I change the template, remove the option of decimals by currency (location / currency).

In the template standard.tpl I add the modifier ceil all float values ​​:

{$paypal_usa_product.price|floatval|ceil}

This is an example of the complete line

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$paypal_usa_product.price|floatval}" />

I'm still testing this, I hope that someone can help you .

Regards

Link to comment
Share on other sites

I am having the same problem and this is the second time this USA /Canada PayPal module has not worked properly and caused me to have abandoned carts. I am going with authorized.net and not using this crappy PayPal module ever again. 

Link to comment
Share on other sites

We had the same problem with the paypal usa module in our site. Here's how I corrected the problem:

 

I added a function at the bottom of classes/cart.php right before the closing curly brace ( } ).

    public function roundAmount($a){
        return Tools::ps_round($a, _PS_PRICE_COMPUTE_PRECISION_);
    }
}

Then in the paypalusa/views/templates/hook/standard.tpl file, change the "value" on the HTML like so:

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$cart->roundAmount($paypal_usa_product.price)}" />
<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+2|escape:'htmlall':'UTF-8'}" value="{$cart->roundAmount($paypal_usa_total_shipping)}" />

This is only a temporary fix and will probably get over-written if you upgrade prestashop or paypal usa, but at least it's working again.

Edited by bitwiz (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

In standard.tpl, about line 45, just use Smarty to format the float to two decimal places. Tested and worked flawlessly with USD, GBP and EUR, both to and from paypal.com (including purchase).
Remember to re-compile or else you won't see the effect.
 
Change this:

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$paypal_usa_product.price|floatval}" />

To this:

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$paypal_usa_product.price|floatval|number_format:2}" />
Edited by finlanderid (see edit history)
  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

finlanderid, You ROCK !!!
I was going nuts trying figure this out!
Googling the issue didn't help because I HAD it set in the backend for 2 decimal places.
I hope this gets fixed in the code and they give you a freee coffee for figuring it out :)
Thanks again!

Kathleen

(I'm adding your solution to my post so others can see it easily as a solution!)

 

 

In standard.tpl, about line 45, just use Smarty to format the float to two decimal places. Tested and worked flawlessly with USD, GBP and EUR, both to and from paypal.com (including purchase).
Remember to re-compile or else you won't see the effect.
 
Change this:

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$paypal_usa_product.price|floatval}" />

To this:

<input type="hidden" name="amount_{$smarty.foreach.paypal_usa_products.index+1|escape:'htmlall':'UTF-8'}" value="{$paypal_usa_product.price|floatval|number_format:2}" />
  • Like 2
Link to comment
Share on other sites

Thanks. Glad you were able to make it work.

 

Yes, it was very difficult to try to fix in the php, because of a bunch of other "moving parts" re: currencies and rounding that can't be tampered with, and the setting in the BO simply does not impact that part of the PayPal module (when front-end changes to a non-store-default currency). 

 

The Smarty solution is not ideal but works OK. I have not tried yet, but if someone really needed to, you could even try using the PS constant (for decimal places) instead of the number 2. That would make it more dynamic and proper.

Edited by finlanderid (see edit history)
Link to comment
Share on other sites

  • 1 month 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...