Forums / Bug Reports / [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

[Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

Locked

Started by webchills on 29 Apr 2011, 5:43 AM · Views: 5,372

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
29 Apr 2011, 5:43 AM
#1
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

[Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

Zen-Cart 1.3.9h
Fresh installation
No addons

Issue:
Some Products (depending on price and tax rate) are shown in PayPal Express as:
Tax included in prices: 0 (0)

How to recreate this issue:

Set Configuration > My Store > Display Prices with Tax > true
Set your tax rate to 19%
Set your currency to EUR
This is the configuration for almost all German shops as the German VAT is 19% (or for some products 7%)
Create a product with the following price:
Products Price (Gross): 0.90
Tax Class: 20%
The net price will be: 0.7563

Add this product to your cart and checkout with PayPal Express

The PayPal website will show the content of your cart as:
Tax included in prices: 0 (0)

In the PayPal log you will find:

getLineItemDetails 5
Line-item subtotals do not add up properly. Line-item-details skipped.
0.9 0Array
(
    [AMT] => 0.9
    [ITEMAMT] => 0.9
    [TAXAMT] => 0
    [SHIPPINGAMT] => 0
    [SHIPDISCAMT] => 0
    [HANDLINGAMT] => 0
    [INSURANCEAMT] => 0
    [L_NUMBER0] => 1234567
    [L_NAME0] => Testproduct 
    [L_AMT0] => 0.899997
    [L_QTY0] => 1
) 

Notice the difference between AMT and L_AMT0

Create a product with the following price:
Products Price (Gross): 1.19
Tax Class: 20%
The net price will be: 1.0000

Add this product to your cart and checkout with PayPal Express

The PayPal website will show the content of your cart as it should be

In the log you will see:

[AMT] => 1.19
    [ITEMAMT] => 1.19
    [TAXAMT] => 0
    [SHIPPINGAMT] => 0
    [SHIPDISCAMT] => 0
    [HANDLINGAMT] => 0
    [INSURANCEAMT] => 0
    [L_NUMBER0] => KABHD40PIN
    [L_NAME0] => Testproduct
    [L_AMT0] => 1.19
    [L_QTY0] => 1
[CODE] 
    
According to the PayPal Express API documentation:
Regardless of the specified currency, the format must have decimal point with exactly two digits to the right 

This is not the case in the current code, so we suggest the following change in includes/modules/payment/paypalwpp.php

change around line 1192

from
[CODE]
$optionsLI["L_AMT$k"] = $order->products[$i]['final_price'];
$optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
$optionsLI["L_TAXAMT$k"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);

to

$optionsLI["L_AMT$k"] = round($order->products[$i]['final_price'], 2);
$optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
$optionsLI["L_TAXAMT$k"] = round(zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']), 2);

After this change checkout again the 0.90 Euro product and now the product is shown in PayPal correctly as there is no difference between AMT and L_AMT0 anymore

hugo13 and webchills

29 Apr 2011, 6:32 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

That's a good fix. I saw this happen in some testing I was doing a couple days ago but didn't have time to tackle it yet. Thanks.

I would suggest two variations on your proposed fix though:

  • use zen_round() instead of round()
  • use the number of decimal places defined by the selected currency, instead of hard-coding it to 2. The system changes it to 2 later where needed.

.
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.

29 Apr 2011, 6:19 PM
#3
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

Unfortunately our fix did not fix the issue in all cases.
Try the 0.90 Euro example above, but put 3 units of it in your cart and see what happens at PayPal...

Here is a better fix which works fine for the 3 x 0.90 Euro example above and for other amounts as well:

Change from

// PayPal can't handle partial-quantity values, so fudge it here
      if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
        $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
        $optionsLI["L_AMT$k"] = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
        $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']);
        $optionsLI["L_QTY$k"] = 1;
      } else {
        $optionsLI["L_AMT$k"] = $order->products[$i]['final_price'];
        $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
        $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);
      }

to

// PayPal can't handle partial-quantity values, so fudge it here
      if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
        $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
         // r.l.3
        $optionsLI["L_AMT$k"] = round(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), 2);
        $optionsLI["L_TAXAMT$k"] = round(zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']), 2);
        $optionsLI["L_QTY$k"] = 1;
      } else {
        // !!! r.l.2
        $optionsLI["L_AMT$k"] = round($order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
        $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
        // !!! r.l.1
        $optionsLI["L_TAXAMT$k"] = round(zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
      }
      #die('decplaces: ' . $currencies->currencies[$_SESSION['currency']]['decimal_places']);
29 Apr 2011, 7:17 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

Rounding and then re-rounding over again?

.
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.

29 Apr 2011, 9:28 PM
#5
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

Try it with the 3 x 0.90 product. First fix does not work, second works

1 May 2011, 6:05 AM
#6
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

webchills:

Set your tax rate to 19%
Set your currency to EUR
This is the configuration for almost all German shops as the German VAT is 19% (or for some products 7%)
Create a product with the following price:
Products Price (Gross): 0.90
Tax Class: 20%
You're talking about 3 different tax rates while setting up a single product.
Which is the real one in your example? Is it 19%? 7%? 20%?

.
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.

1 May 2011, 6:20 AM
#7
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

sorry 20% was a typo

Corrected version:
Set Configuration > My Store > Display Prices with Tax > true
Set your tax rate/tax class to 19%
Set your currency to EUR (with decimal places = 2)
This is the configuration for almost all German shops as the German VAT is 19% (or for some products 7%)
Create a product with the following price:
Products Price (Gross): 0.90
Tax Class: 19%
The net price will be: 0.7563

4 May 2011, 3:11 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

webchills:

Try the 0.90 Euro example above, but put 3 units of it in your cart and see what happens at PayPal...
Can't replicate a problem. It comes through as 2.70 every time.

.
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 May 2011, 5:42 AM
#9
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: [Done v1.5.0] PayPal Express: Item details are shown as Tax included in prices: 0 (0)

How to recreate the issue

Set Configuration > My Store > Display Prices with Tax > true
Set your tax rate/tax class to 19%
Set your currency to EUR (with decimal places = 2)
Change the price of Matrox G200 MMS from the demo data to:
Products Price (Gross): 0.90
Tax Class: 19%
The net price will be: 0.7563

Add 1 unit of the Matrox to your cart:

Checkout with PayPal Express

The cart on the left on the PayPal website will not show the item description, but will show it as Tax included in prices: 0 (0) instead:

Now change the quantity to 3 units:

Checkout with PayPal Express
You will get the same wrong result

We have a problem, right?

Apply the following change to includes/modules/payment/paypalwpp.php an change around line 1183 from:

// PayPal can't handle partial-quantity values, so fudge it here
      if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
        $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
        $optionsLI["L_AMT$k"] = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
        $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']);
        $optionsLI["L_QTY$k"] = 1;
      } else {
        $optionsLI["L_AMT$k"] = $order->products[$i]['final_price'];
        $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
        $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);
      }

to

// PayPal can't handle partial-quantity values, so fudge it here
      if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
        $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
        // r.l.3
        $optionsLI["L_AMT$k"] = round(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), 2);
        $optionsLI["L_TAXAMT$k"] = round(zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']), 2);
        $optionsLI["L_QTY$k"] = 1;
      } else {
        // !!! r.l.2
        $optionsLI["L_AMT$k"] = round($order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
        $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
         // !!! r.l.1
        $optionsLI["L_TAXAMT$k"] = round(zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
      }
      #die('decplaces: ' . $currencies->currencies[$_SESSION['currency']]['decimal_places']);
  1. Now checkout the 1 unit of the Matrox again and the result on the PayPal website will be as it should be:

  2. Now checkout the 3 units of the Matrox again and the result on the PayPal website will be fine too: