Site maintenance: Sun 15 Nov, from 20:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / Built-in Shipping and Payment Modules / Paypal Express checkout and local taxes

Paypal Express checkout and local taxes

Started by 65fastback2_2 on 1 Nov 2012, 1:09 PM · Views: 11,770

Results 1 to 20 of 27
1 Nov 2012, 1:09 PM
#1
65fastback2_2 avatar

65fastback2_2

New Zenner

Join Date:
Mar 2009
Posts:
15
Plugin Contributions:
0

Paypal Express checkout and local taxes

So here is my issue.

I only charge local taxes if the ship location is Kentucky.

If I create an account and use a Texas address then checkout with paypal express, it works perfectly.

If, however, I dont create an account and try to directly use Paypal Express checkout, when it takes me to the paypal screen, it shows taxes even though an address has not been entered for calculating taxes.

Is there a solution for this? I thought about maybe a way to remove the express checkout option and just have create an account or checkout as guest so they have to enter their shipping info before they select paypal as the payment method and then confirm the order where it sends them to paypal. But, I dont know if this is possible or how.

Thanks for the help!

18 Jan 2013, 2:02 AM
#2
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Dr. Byte, I know you have stated in several threads that there's no way in the current version that PayPal can be displaying tax information unless the customer has provided their shipping address in the Zen Cart store first. But I am having the same problem as others after upgrading from 1.3.9h to 1.5.1. When a customer does not log into my store, but uses the Express Checkout button, the PayPal page does indeed display a sales tax amount. I verified that this amount is transmitted to PayPal in the TAXAMT field. I do NOT have any custom add-ons installed. My paypalwpp.php is the vanilla version from the 1.5.1 distribution.

I have had many inquiries from customers about tax charges, and I wondered why. Then I noticed the display of sales tax!

There are many changes in paypalwpp.php between 1.3.9h and 1.5.1 regarding the handling of TAXAMT. So I really think there is a problem somewhere.
If you don't believe me, please visit my store at http://nootropicdesign.com/store and add something to the cart and choose express checkout. You will see tax information displayed at PayPal.

18 Jan 2013, 2:16 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

I have a fresh new installation of Zen Cart on my site, using demo products.
What do I need to do to my site to make it exactly behave as you describe?

ie: tell me every admin setting you've changed, every zone you've created, every plugin you've installed, every module you've enabled, currencies, languages, everything.

If I can't recreate the problem consistently on-demand, I can't fix it. And thus far I haven't got enough information to help you.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jan 2013, 3:56 AM
#4
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Admin settings: no changes related to taxes: DISPLAY_PRICES_WITH_TAX = false
Zones: no new zones created. Configuration->My Store->Zone = Minnesota.
All products characterized with Tax Class = Taxable Goods
Tax Rate for Minnesota defined as 6.875% for Tax Class = Taxable Goods
Currencies: US Dollar is only currency used.
Languages: English is only language defined.
Plugins/Add-ons: the only addon is USPS shipping module RateV3 which is now an add-on for 1.5.1
PayPal settings: all shipping and tax options are disabled
Configuration -> My Store -> Basis of Product Tax = Shipping
Configuration -> My Store -> Basis of Shipping Tax = Shipping
Configuration -> My Store -> Zone = Minnesota
USPS Module -> Tax Basis = Shipping
USPS Module -> Shipping Zone = none

I've used Zen Cart for many years and am very familiar with the PayPal integration API. It just seems that some change in paypalwpp.php has altered the way in which the TAXAMT field is set when the customer has not logged in at all to the store. The default behavior I'm seeing in 1.5.1 is to send a TAXAMT based on the zone defined for the store, even though the customer has not logged in or provided any shipping address info to PayPal.

I am very happy to try different configuration settings or to experiment with any code changes you recommend. I'm an experienced developer, so I'm game.

18 Jan 2013, 4:29 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

Just to clarify, it's not actually mischarging them anything, right? It's merely showing them what taxes would be if their delivery address were inside your taxable zone, and then self-corrects when they provide a non-taxable address, right?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jan 2013, 5:20 AM
#6
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Yes, correct. Once the customer gives their shipping address at PayPal, then the charged amount is completely correct. It's just the initial misrepresentation of the charges that causes customers to ask questions or wander away confused.

18 Jan 2013, 6:23 PM
#7
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Here is some more info. I have found that the source of the TAXAMT value is from the value of the ot_tax order total. I have a 1.3.9h installation that I can test in, as well as my production 1.5.1 installation, and I can see that the set of order totals being returned from the order_total module is different in the two versions. In 1.3.9h, the ot_tax order total is not returned by the call to order_total_modules->process() in paypalwpp.php. But in 1.5.1, the ot_tax order total is present in the set of order totals returned from process().

For clarity, I'm logging the set of order totals after line 1432 of paypalwpp.php:

    $order_totals = $order_total_modules->process();
    for ($ot=0; $ot<sizeof($order_totals); $ot++) {
      $this->zcLog($order_totals[$ot]['code'] . ' = ' . $order_totals[$ot]['value']);
    }

in 1.3.9h there is no ot_tax total, but in 1.5.1 there is. When the anonymous customer is viewing the shopping cart on my site (before clicking the PayPal Express button), there is NO tax displayed. But when we hand off to the paypal module, there is an ot_tax order total with a calculated tax value.

My tax class, tax rate, and zone definition are identical between the 1.3.9h and 1.5.1 installations. The ot_tax order total module is installed identically between both versions. The actual tax handling in orders works fine in 1.5.1 once we know where the customer is. Tax is correctly assessed for my Minnesota customers, and not otherwise.

18 Jan 2013, 7:23 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

It's not a PayPal thing.

It's caused by this default which was added to prevent errors from being triggered when customers without an account attempt to go through checkout:
line 287 of orders.php class:```
// set default tax calculation for not-logged-in visitors
$taxCountryId = $taxZoneId = -1;

Changing it from -1 to 0 would prevent the system from using the STORE_ZONE and STORE_COUNTRY as defaults, and instead give nothing back.
But I've no idea what other very bad side effects that could cause as well, everywhere in your store.
USE AT YOUR OWN RISK

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jan 2013, 7:53 PM
#9
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Yes, I found the same thing. I was just running tests with my fix to order.php. The logic for determining the tax address was refactored in 1.5.0. With the default country and zone explicitly set to -1, this will always show tax for the store's location at PayPal. That is not the correct behavior.

My fix is to set the taxCountryId and taxZoneId from the database query result, regardless if there were any records returned. This is how the 1.3.9h version worked.

So I changed order.php:

$tax_address = $db->Execute($tax_address_query);
if ($tax_address->recordCount() > 0) {
   $taxCountryId = $tax_address->fields['entry_country_id'];
   $taxZoneId = $tax_address->fields['entry_zone_id'];
}

to this:

$tax_address = $db->Execute($tax_address_query);
$taxCountryId = $tax_address->fields['entry_country_id'];
$taxZoneId = $tax_address->fields['entry_zone_id'];

This results in the correct behavior for not-logged-in users using the Express button. I tested all the other checkout paths as well.

18 Jan 2013, 7:56 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

The change you just posted will throw errors if nothing comes back from the query if strict error reporting is on, and will set those values to 0. So basically your code is just setting the country and zone to 0, which basically just bypasses normal use period.

Has your fix accounted for the reason why the -1 was used in the refactoring in the first place? Do you know why that was done specifically? If not, are you 100% certain that changing that is absolutely correct for everyone everywhere in the world?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jan 2013, 8:29 PM
#11
nootropic avatar

nootropic

New Zenner

Join Date:
Jan 2013
Posts:
7
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

No, I do not know why order.php was changed to retrieve the tax rates for the store location when a customer is not logged on. It does not seem like the right behavior, and looks like a mistake in the refactoring. It results in a confusing situation when customers use the Express button and go directly to PayPal.

I implemented a fix for myself that is based on the way this logic was coded in 1.3.9h. That is, do not associate any tax rates with an order when I have no idea where the customer is. I tested all the paths for my store, end to end, so I feel confident about my fix to my store.

If there is a design reason for why it was decided in 1.5.0 that the store's location should be the basis for sales tax on orders without a logged in customer, can you please tell us? Is there a specific reason why this change is wrong?

I do not claim that this is a fix for everyone in the world. I thought you'd want people to share their findings when solving problems, but you've been borderline hostile toward me throughout this thread. I don't know why. I probably will not be posting any more to this forum.

18 Jan 2013, 8:58 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

Apologies. I've no intention of coming across as hostile.
My blunt questions were merely intended to invoke thought and to ensure that future readers of this discussion seriously take those same thoughts into consideration before blindly changing code they've not studied. (They've been known to just blindly try any ol' thing they read on the internet, and then come here complaining cuz they broke their store!)

Definitely not intended to be taken personally. On the contrary, your willingness to dig into the code is highly respected and appreciated.

My recollection of the change you're disputing is that it was done for consistency with the way calculations are done elsewhere in the code, and to deal with problems people were reporting at the time. While I've not done exhaustive forum searching to find exactly what forum discussions might have led to the change, I do see that the change was made around August 2011 as part of the v1.5.0 development cycle.

EDIT: Also found a change-control ticket entitled "Fix tax calculations for not-logged-in users, by defaulting to default country/zone just like it does for product listings", which, while a little vague, may explain more of the history.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Mar 2013, 9:29 AM
#13
lucent avatar

lucent

New Zenner

Join Date:
Mar 2013
Posts:
2
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Was a solution ever found for this problem? I understand that the change from 1.3.9h to 1.5.0 was to address different issues. I am using 1.5.1 and have noticed the problem of non-logged in customers using express checkout will have a sales tax quoted to them, along with not applying a discount code initially. After they proceed through the regular site checkout pages the order amount changes to reflect the tax zone and coupon codes applied. Unfortunately this increased price quote has turned many customers away from my site or resulted in confused emails.

25 Mar 2013, 2:36 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

lucent:

I am using 1.5.1 and have noticed the problem of non-logged in customers using express checkout will have a sales tax quoted to them, along with not applying a discount code initially. After they proceed through the regular site checkout pages the order amount changes to reflect the tax zone and coupon codes applied. Unfortunately this increased price quote has turned many customers away from my site or resulted in confused emails.
Have you tried simply disabling the EC Shortcut Button in your ZC admin? In your ZC PayPal Express Checkout settings, there is an "EC Shortcut Button" option. Turn that off and your customers will be logged in before hitting checkout, thus not encountering the symptoms you describe.

I'll add that taxes are only assessed when your store's configuration is set up to assess them. So, if you've configured your store to assess taxes regardless of address then your customers will see taxes that may not apply to them until they supply address information. Out-of-the-box, Zen Cart doesn't show any taxes until an address is supplied, so something in your configuration is overriding that.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Mar 2013, 7:22 AM
#15
lucent avatar

lucent

New Zenner

Join Date:
Mar 2013
Posts:
2
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

DrByte:

Have you tried simply disabling the EC Shortcut Button in your ZC admin? In your ZC PayPal Express Checkout settings, there is an "EC Shortcut Button" option. Turn that off and your customers will be logged in before hitting checkout, thus not encountering the symptoms you describe.

I'll add that taxes are only assessed when your store's configuration is set up to assess them. So, if you've configured your store to assess taxes regardless of address then your customers will see taxes that may not apply to them until they supply address information. Out-of-the-box, Zen Cart doesn't show any taxes until an address is supplied, so something in your configuration is overriding that.

Well the reason I wanted PayPal EC on is to enable customers to checkout without as many steps. Also my store settings are set to calculate tax based on the shipping address, not billing or store address. The only location I have tax set up is for the state of California.

26 Mar 2013, 7:29 AM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Paypal Express checkout and local taxes

lucent:

Well the reason I wanted PayPal EC on is to enable customers to checkout without as many steps. Also my store settings are set to calculate tax based on the shipping address, not billing or store address. The only location I have tax set up is for the state of California.

I just did a fresh install today, and have the default demo data active on it. That includes a Florida state tax zone and tax rate. When I put a product in my shopping cart and click the orange EC button (without logging in), it takes me to PayPal as expected. There all I see is the product price. Nothing else: no taxes, no shipping. Just the main price.
Once I choose an address (whether within PayPal and return that back to my store, or just go back to the store and fiddle with the address), if it's in Florida, I get taxes. If it's outside Florida, I don't get taxes.

Perhaps you have addons that are altering the default tax behavior?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Apr 2013, 8:02 AM
#17
penaffair avatar

penaffair

New Zenner

Join Date:
Nov 2008
Posts:
5
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

I too have the same issue - fresh install of Zencart 1.5.1, no mods, just changed configuration and a test product, using Paypal sandbox.

I believe I have found the issue. I am in Australia, my store location is set to Australia, and I have a tax zone to charge GST for australian zones.

I setup a US sandbox account on Paypal, but when I go to express checkout, without logging in, it shows GST being charged. If I change my store location to United States, and do exactly the same thing, the Paypal checkout does not show any GST being charged.

Is this as expected? I would prefer no tax being shown until an Australian resident tries to pay.

Thanks.

PS - I set the tax calculations is store setup to be "Billing" as I am selling downloadable goods, so shipping isn't relevant.

7 Apr 2013, 8:21 AM
#18
penaffair avatar

penaffair

New Zenner

Join Date:
Nov 2008
Posts:
5
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

PPS - Just to confirm this, I set my store back to Australia, but changed the GST zone to USA. Made my express purchase, no tax showing on Paypal page, but when it goes back to my store, the tax is now there.

So the Paypal tax shown seems to be going only on the store location/Tax zone combination, and only calculating correctly for the customers address after it leaves Paypal again.

25 May 2013, 11:05 PM
#19
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

Was there ever an answer to this? I have the exact same problem.

  1. Customer is not logged in.
  2. add item to cart.
  3. click on payapl express checkout button.
  4. on paypal it adds tax to the product.

how can this be if paypal doesn't know the shipping address?

Thanks.

25 May 2013, 11:21 PM
#20
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Re: Paypal Express checkout and local taxes

So I think I found the bug.

I only have tax setup for California zone

A) to recreate:
Admin>Config>My store>zone is configured to: California.

B) fixing:
Admin>Config>My store>zone is configured to: (any other state besides california).

So I guess if I have my zone under MY store the same as my only tax zone, then it will show tax on paypal even when logged out. When I changed the zone under my store and did the exact same checkout(same item), it did not show tax. What gives? How can we fix because I'm located in California and would not want to define my zone under my store to something else.