I have just discovered a problem with the paypals total amount and opencarts total amount which are diffrent at

checkout. It seems that paypal calculates the amount based on 2 decimals and OC calculates based on 4 decimals.

I have read a few topic about this but there is no solution for this for opencart 1.5.1.3.

can anybody out there please provide a solution to this. Im sure all the poeple using paypal are affected by this but there

is no solution or discussion about this major problem.

thank you in advance

This problem only seems to occur when using a coupon in my shop. I believe it has to do with the rounding of the coupon discount calculation.

In catalog / model / total / coupon.php

Find:

Code: Select all

```
$total_data[] = array(
'code' => 'coupon',
'title' => sprintf($this->language->get('text_coupon'), $this->session->data['coupon']),
'text' => $this->currency->format(-$discount_total),
'value' => -$discount_total,
'sort_order' => $this->config->get('coupon_sort_order')
);
```

Code: Select all

`$discount_total = round($discount_total, $this->currency->getDecimalPlace());`

Regards,

Joel.

Im not sure if the code you gave will solve the issue since I dont have any coupon.

the problem is that when customers add products to cart and checkout with paypal the amount that is in the opencart is diffrent from paypals amount with a few pennies. when I enter prices excluding vat with 4 decimals in admin this happens. this is due to paypals calculation is based on 2 decimal rounding. Its a true headache and hope to find a solution to this.

thank you in advance joel,

System / Localisation / Currencies /

Is your "Decimal Places" set to 2?

Other than that, I don't think there's any way to solve this. If your currency requires 4 decimal places, then it might be something you're stuck with, as like you said, PayPal only uses 2.

Regards,

Joel.

problem is that I have British currency pounds and its actually 2 decimals pounds and pens like 9.99.

to be able to set prices in the admin to achieve prices like 9.99 or 11.99 it would not be possible with 2 decimals. and when I have 4 decimals and I can achieve 9.99 price type then even the cart calculates wrong it is showing total 19.97 then for example i add 3 x9.99 to the cart and 2.99 shipping as below and the OC cart and paypal have diffrent amounts.

Im kind of totally confused how to fix this really. why does it need to be like this and what are all the poeple using paypal and OC have solved this? Any help would be appriciated. thank you

Do you have any custom modifications installed?

You shouldn't have any problems with using 2 decimal points in your store. The default GBP setup has 2 decimal points and prices of x.99 show up no problem.

I also just tried it out on one of my testing installations and have no problem display a price of 99.99 using 2 decimal points.

Joel.

You shouldn't have any problems with using 2 decimal points in your store. The default GBP setup has 2 decimal points and prices of x.99 show up no problem.

I also just tried it out on one of my testing installations and have no problem display a price of 99.99 using 2 decimal points.

Joel.

#### Attachments

occart.jpg (14.22 KiB) Viewed 17464 times

Opencart calculates the product prices based on the values entered into the db and then converts the total to the current currency

But, paypal only knows about the post-converted prices and stupidly does its own math.

So for example if you have 2 currencies on your site and your default is USD and you have these exchange rates:

USD 1.000000

GBP 0.637532

OpenCart does the math based on the default currency:

Product 1: 19.99

Product 2: 27.99

Product 3: 32.49

Subtotal: 80.47

Since GBP is selected, it converts the values after

Product 1: (19.99 * 0.637532) = 12.74

Product 2: (27.99 * 0.637532) = 17.84

Product 3: (32.49 * 0.637532) = 20.71

Subtotal: (80.47 * 0.637532) =

**51.30**

Paypal only knows about the post-convert prices obviously, and they try to do their own math, which is stupid really. They should be informational only but paypal like to be difficult.

So paypal does its own math:

12.74 + 17.84 + 20.71 which equals

**51.29**which is 1 cent less.

OpenCart is doing it right based on a multicurrency store. Paypal is assuming a simpler cart with simple calculations and its 2001 way of thinking is causing the issue. If paypal would just take the itemized values as informational, and allow passing the "Total" as the billable value.. all the paypal issues would be instantly solved.

I guess the only way out of this problem is to send a single amount to paypal and not let it calculate its stupid ways.

Can you guys please provide the code to change this so I can only send 1 single amount to paypal. I have studied the methods but cant figure it out really. got OC 1.5.1.3 with modifies theme.

thank you in advance

Basically, I can run the same post-conversion math that paypal does and compare it to the pre-conversion math that opencart does. If they are off by that last cent, I can fudge the paypal total so that paypal sees the same amount that opencart sees. Seems to be working fine in the other module so we'll see how it goes here.

There's only 1 currency in my database: €. And even in this case there a problems with roundings. (when using PayPal Standard)Opencart calculates the product prices based on the values entered into the db and then converts the total to the current currency

In this topic you''ll find my explanation, for what causes this rounding problem.

http://forum.opencart.com/viewtopic.php?f=20&t=40181

OC version 1.5.4.1

Is this topic also doomed to run into nothing, just like all other discussions regarding the paypal rounding problems?

How long do we need to wait for something finally realizes that we need a fix for this?

Topic 1

http://forum.opencart.com/viewtopic.php ... ng#p207148

Topic 2

http://forum.opencart.com/viewtopic.php?f=113&t=40181

Topic 3

http://forum.opencart.com/viewtopic.php?f=115&t=37837

How long do we need to wait for something finally realizes that we need a fix for this?

Topic 1

http://forum.opencart.com/viewtopic.php ... ng#p207148

Topic 2

http://forum.opencart.com/viewtopic.php?f=113&t=40181

Topic 3

http://forum.opencart.com/viewtopic.php?f=115&t=37837

I'm in the same boat.

Client called today, and told me that the system is adding up totals incorrectly. She's not happy, and I'm getting flak for recommending an e-commerce system that doesn't work.

Yes, it's just out by 1c; but that's a big deal where accounting is involved. It adds up, and makes it impossible to reconcile orders against client payments. Every other e-commerce system I work with handles it fine, and at the moment I'm extremely *NOT* a happy bunny. Looks like I'm going to have to recode the this system to work consistently.

Regards,

Peter Connolly

Last edited by markman-b on Mon Feb 20, 2012 11:59 pm, edited 2 times in total.

OC version 1.5.4.1

Q has worked hard to fix this issue in his paypal pro hosted extension and I can confirm that it works great. I dont know if he has implemented it in the paypal standard but he has solved this issue.

Please confirm Q if you have implemented this fix elsewhere too?

thank you

http://forum.opencart.com/viewtopic.php ... 30#p254430

Thanx for link. But be aware that the differences (caused by a different calculation method between Open Cart and PayPal), not always are restricted to 1 cent. The difference is related to the number of products in the shopping cart. The more products, the higher the difference.

The differences in order totals are causing some other negative side effects. The amounts on the OC invoices, which are being sent to customers, differ from amounts they have paid, etc.

What is wise? To contact other webshop developers, to find out how they deal with this issue?

The differences in order totals are causing some other negative side effects. The amounts on the OC invoices, which are being sent to customers, differ from amounts they have paid, etc.

What is wise? To contact other webshop developers, to find out how they deal with this issue?

OC version 1.5.4.1

Maybe Q wasn't clear enough when he explained "pre-conversion" here http://forum.opencart.com/viewtopic.php ... 38#p254430

What he actually meant is "pre-rounding" math. OpenCart uses more decimal places when calculating percentage, and then rounds to 2 decimal places (or whatever is set in decimal places for your chosen currency - 2 is default for US dollar), so the difference is restricted to 2nd decimal place and can never exceed more then (+/-)1 on that place.

On the other side, PP requires 2 decimal places values.

Example

9.984 is rounded down to 9.98

If you add it twice using 3 decimal places (how OC does it internally)

9.984

9.984 +

---------

19.968 (19.97 when OC rounds it to 2 decimals)

Now, values PP receives are rounded to 2 decimals, thus

9.98

9.98 +

-------

19.96 (here it is, PP value is down by 1, cutomer receives .01 discount)

Example 2

9.987 is rounded up to 9.99

If you add it twice using 3 decimal places (how OC does it internally)

9.987

9.987 +

---------

19.974 (19.97 when OC rounds it to 2 decimals)

Values PP receives are rounded to 2 decimals, thus

9.99

9.99 +

-------

19.98 (PP value is up by 1, cutomer pays .01 more)

There is no bug at all, this is how math calculation works everywhere

What he actually meant is "pre-rounding" math. OpenCart uses more decimal places when calculating percentage, and then rounds to 2 decimal places (or whatever is set in decimal places for your chosen currency - 2 is default for US dollar), so the difference is restricted to 2nd decimal place and can never exceed more then (+/-)1 on that place.

On the other side, PP requires 2 decimal places values.

Example

9.984 is rounded down to 9.98

If you add it twice using 3 decimal places (how OC does it internally)

9.984

9.984 +

---------

19.968 (19.97 when OC rounds it to 2 decimals)

Now, values PP receives are rounded to 2 decimals, thus

9.98

9.98 +

-------

19.96 (here it is, PP value is down by 1, cutomer receives .01 discount)

Example 2

9.987 is rounded up to 9.99

If you add it twice using 3 decimal places (how OC does it internally)

9.987

9.987 +

---------

19.974 (19.97 when OC rounds it to 2 decimals)

Values PP receives are rounded to 2 decimals, thus

9.99

9.99 +

-------

19.98 (PP value is up by 1, cutomer pays .01 more)

There is no bug at all, this is how math calculation works everywhere

Last edited by dizarter on Thu Feb 23, 2012 12:55 am, edited 4 times in total.

Who is online

Users browsing this forum: No registered users and 5 guests