Jump to content

PayPal: Unexpected Payment Error (Error Code: 10426) Rounding Issues


flid2

Recommended Posts

I have a shop set up in Canada with tax set at 5%.  When using PayPal to check out, it gives an error Error Code: 10426.

 

I spoke to PayPal and figured out that the problem is that PayPal will only deal with 2 decimal places.  If I have something for sale for $1.00 and charge tax of 5%, the total will be $1.05 and will work.  If I charge $0.99 and charge tax of 5%, the total will be $1.0395 and won't work because there are too many decimal places.  

 

How can I fix this so that I don't have to worry about all my prices working out to only 2 decimal places?

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

  • 3 months later...

I'm in the same situation. I believe Prestashop is suck. Any thing don't work. Install and reinstall. Open cart is a much better ecommerce piece of software. Is a week now I'm trying to resolve this Paypal issue. Nothing can help me to resolve. This will be the last chance to ask for help then I will move to Open cart. (Open cart use only your email account for paypal)

Link to comment
Share on other sites

This is caused by none 2digit decimal amount.

 

If Paypal Payment Standard, Edit

/modules/paypalusa/views/templates/hook/standard.tpl

 

change

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

 

to

<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}" />

 

Same goes to Express and Professional, I guess.

Link to comment
Share on other sites

  • 3 weeks later...

I have a shop set up in Canada with tax set at 5%.  When using PayPal to check out, it gives an error Error Code: 10426.

 

I spoke to PayPal and figured out that the problem is that PayPal will only deal with 2 decimal places.  If I have something for sale for $1.00 and charge tax of 5%, the total will be $1.05 and will work.  If I charge $0.99 and charge tax of 5%, the total will be $1.0395 and won't work because there are too many decimal places.  

 

How can I fix this so that I don't have to worry about all my prices working out to only 2 decimal places?

 

 

We had a similiar situation.

 

We used two currency in the same site, the problem was that money exchange MXN > USD was 15.39902.

 

We fixed this change this value currency to 15.40

Link to comment
Share on other sites

"This is caused by none 2digit decimal amount.

 

If Paypal Payment Standard, Edit

/modules/paypalusa/views/templates/hook/standard.tpl

 

change

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

 

to

<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}" />

 

Same goes to Express and Professional, I guess."

 

Ash-f was right about changing the code for standard, it works, I just tried it BUT IT DOES NOT WORK FOR EXPRESS. If any of you knows how to modify the code for express paypal checkout I'd greatly appreciate it

Link to comment
Share on other sites


I know how to fix Paypal Express but I didn't know somebody is still interested.

 

modify this file

/modules/paypalusa/controllers/front/expresscheckout.php

 

wrap any variable that is cast as float with number_format()

 

example

 

change

(float)$product['price_wt']

 

to

number_format((float)$product['price_wt'],2)

  • Like 1
Link to comment
Share on other sites

Ash-f these are all the lines I have that contain "float"

 <input id="paypal-express-checkout-btn" type="image" name="submit" src="{$module_dir}img/boton_terminar_compra.png" alt="" style="vertical-align: middle; margin-right: 10px;float: left;" />
                    <p style="line-height: 50px; float: left;">{l s='Da clic para confirmar tu compra con PayPal' mod='paypalusa'}</p>
 
 
<input id="paypal-express-checkout-btn-product" type="image" name="submit" src="{if isset($paypal_usa_express_checkout_no_token) && $paypal_usa_express_checkout_no_token}{$module_dir}/img/accpmark_tarjdeb_mx.png{else}{$module_dir}/img/express_checkout_mx.png{/if}" alt="" style="float: left;"/>
 
 
 $('#paypal-express-checkout-btn-product').css('float', 'left');
 
 $('#paypal-express-checkout-btn-product').css('float', 'right');
 
All I gave you above is extracted lines that contain the float part.....don't see anywhere the variable "price" nor "amount" mentioned.
 
Can you help?
 
Thanks a lot!
Link to comment
Share on other sites

96

'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode((float)$product['price_wt']).

 

115

'&PAYMENTREQUEST_0_ITEMAMT='.(float)$total;

 

279

if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, (float)$result['PAYMENTINFO_0_AMT'], $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))

Link to comment
Share on other sites

modify those lines like below

 

96

'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode(number_format((float)$product['price_wt'],2)).

 

115

'&PAYMENTREQUEST_0_ITEMAMT='.number_format((float)$total,2);

 

279

if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, number_format((float)$result['PAYMENTINFO_0_AMT'],2), $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))

  • Like 1
Link to comment
Share on other sites

change

'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode((float)$product['price_wt']).

 

to

'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode(number_format((float)$product['price_wt'],2)).

 

 

change

'&PAYMENTREQUEST_0_ITEMAMT='.(float)$total;

 

to

'&PAYMENTREQUEST_0_ITEMAMT='.number_format((float)$total,2);

 

 

change

if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, (float)$result['PAYMENTINFO_0_AMT'], $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))

 

to

if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, number_format((float)$result['PAYMENTINFO_0_AMT'],2), $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))


 

 


Sometimes line number does not match because of line-break format.

So I recommend to use search & replace function of text editors.

 


Link to comment
Share on other sites

I have made the neccessary changes as advised here. but still facing the same problem. 

 

Here are the screeshots of the problems...

 

paypalerror.JPG

 

 

 

 

 

And this is the error proceeding page

 

 

procedding-paypal.JPG

 

And Looking forawrd to exect solution as i absolutely new to the implementation.

 

Thanks for your support and co-operation in advance.

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...
  • 3 months later...

This is caused by none 2digit decimal amount.

 

If Paypal Payment Standard, Edit

/modules/paypalusa/views/templates/hook/standard.tpl

 

change

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

 

to

<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}" />

 

Same goes to Express and Professional, I guess.

 

Hi there, I'm experiencing the same problem. Would you be so kind and could you please guide me step by step how I can get there to change the code - I'm new to it? I use PrestaShop1.6.1.1 and the PayPal module I use is: PayPal Payments and Gateways  Paypalv3.11.4 by PrestaShop. I would be extremely grateful.

 

Thanks

 

Lukasz 

Link to comment
Share on other sites

  • 1 month later...

 

change
'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode((float)$product['price_wt']).
 
to
'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode(number_format((float)$product['price_wt'],2)).
 
 
change
'&PAYMENTREQUEST_0_ITEMAMT='.(float)$total;
 
to
'&PAYMENTREQUEST_0_ITEMAMT='.number_format((float)$total,2);
 
 
change
if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, (float)$result['PAYMENTINFO_0_AMT'], $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))
 
to
if ($this->paypal_usa->validateOrder((int)$this->context->cart->id, (int)$order_status, number_format((float)$result['PAYMENTINFO_0_AMT'],2), $this->paypal_usa->displayName, $message, array(), null, false, $customer->secure_key))
 
 
Sometimes line number does not match because of line-break format.
So I recommend to use search & replace function of text editors.
 

 

 

This worked for me on PS 1.6.1.10.

 

Thank you very much!!! I'm finally able to use PayPal Express since I launched my site 3 years ago.. Issues like this shouldn't exist but thankfully it was an easy fix and there are people like you in the community.

Link to comment
Share on other sites

  • 8 months 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...