Author Topic: paypal express error, amount not equal  (Read 11856 times)

kolynet

  • Guest
paypal express error, amount not equal
« on: October 07, 2016, 01:00:50 PM »
dear developers,

github .com/abantecart/abantecart-src/issues/685

i have this issue. only when i add multiple items in euro for example and the cart vs paypal differ by 0,01.
sometimes it works sometimes its not ,depending on the rounding.
is there any manual workaround?

thank you !

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #1 on: October 07, 2016, 02:36:17 PM »
Which Paypal extension are you using?

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #2 on: October 07, 2016, 04:08:38 PM »
latest 1.2.8 stock paypel express extension.

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #3 on: October 08, 2016, 02:44:06 AM »
If you charge shipping, Paypal charges VAT to sub-total and shipping separately and then adds the 2  together. This causes rounding errors like you experience.  If you google this problem, lots of examples.

Do you have to have Paypal calculate VAT?  VAT/Tax can be setup in A-cart for both sub-total and shipping and then only the total is passed to Paypal. Personally, I don't let Paypal calculate anything.


kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #4 on: October 08, 2016, 04:42:20 AM »
I have free shipping on everything, and no TAX on the store.

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #5 on: October 08, 2016, 05:04:38 AM »
Okay, maybe try putting the tax in the store and take it off Paypal. That way a total is passed to Paypal and your not relying on Paypal for any calculations.

It seems though that the Euro rounding error is not limited to my previous post with sub-total and tax. 

The only other thing I can think of is currency conversion on Paypal side.  I don't know how they do that. As far as I know, Paypal is USD based and has to do conversions.  That could explain the randomness of the error.

If it was me, I would try taxing at store level and passing a total to Paypal. There is also a report for tax in Abantecart to help keep track of tax collected.

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #6 on: October 08, 2016, 05:47:08 AM »
thanks for ur help, however i dont think it has to do anything with the taxation. i have AbanteCart with 0 tax. so no tax zone. paypal dont put any added tax to the totals. I think its some rounding related thing, where it round up by 1 cents sometimes. maybe can you help me via skype? i pm'd you :)

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #7 on: October 08, 2016, 05:51:14 AM »
P.S: the big isssue:

SUB-TOTAL: $23.65
10% coupon: $2.37 (here come the problem, its actually counted with ($2.365 in the backend)
==============
TOTAL: $21.29.. (this is clearly $21.28) thats why it throw the error. Same happen in all currencies I guess.

I just simply cant find that function which calculateds the full total (like this: sub-total - discounts). If i find it, i can probably fix.

thanks.

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #8 on: October 08, 2016, 06:29:26 AM »
Take a look at core/lib/cart.php but I don't think that's it.  Took a look at the DB and it looks like it's there. Take a look at xxx_orders for a start(screen shot attached)

Some of the values are carried out beyond 2 places and I bet that's where the error occurs.  AND it will do it in any currency.  There's no reason I can see to carry a price out to 4+ decimal places. Maybe one of the dev team can chime in and give us some insight as to why the decimal places are more than 2.  Maybe in some currencies there are more than 2 places.

BTW, it's a simple fix.  Just change the values in the db.  I've come across this elsewhere.
« Last Edit: October 08, 2016, 06:37:56 AM by digitalt »

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #9 on: October 08, 2016, 06:50:00 AM »
ahha, yeah i found it to be 4 decimal in my db.. will change and see if it helps! thanks

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #10 on: October 08, 2016, 06:57:52 AM »
That's only one place I looked at quickly.  You need to check product prices and any other table that deals with currency and adjust them accordingly too. Otherwise, you will still get an error at some point.

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #11 on: October 08, 2016, 07:22:03 AM »
i modified my database, however the discount is still calculated by 3 decimal for some reason. somehow I should force it to use 2 decimal always.

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #12 on: October 08, 2016, 07:36:10 AM »
product price full: $23.65, when i apply 10% coupon, it shows $2.37. It would work if it calculated with 2.37, but however in the background it counts with -2.365, tahts why paypal throw error. i need to found the variable where it count the full total in the PHP. I guess.

Offline digitalt

  • Full Member
  • ***
  • Posts: 116
  • Karma: +20/-0
    • View Profile
Re: paypal express error, amount not equal
« Reply #13 on: October 08, 2016, 07:45:22 AM »
Check core/lib/cart.php  You have to look at ALL tables that deal with currency.  Did you change the decimal places in xxx_coupon.
« Last Edit: October 08, 2016, 07:48:34 AM by digitalt »

kolynet

  • Guest
Re: paypal express error, amount not equal
« Reply #14 on: October 08, 2016, 07:46:56 AM »
i have this:

      //Need to round price after discounts and specials
      //round main price to currency decimal_place setting (most common 2, but still...)
      $currency = $this->registry->get('currency')->getCurrency();
      $decimal_place = (int)$currency['decimal_place'];
      $decimal_place = !$decimal_place ? 2 : $decimal_place;
      $price = round($price, $decimal_place);

however it does nothing if I remove the rounding of the price calc.

 

Powered by SMFPacks Social Login Mod