Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

PayPal Standard v1.0 wrong tax calculation


Recommended Posts

I added raiwas @@raiwa paypal invoice fix for PayPal standard.




somehow the tax calculation doesn't seem to be right on the PayPal payment site.

I ship domestic and international. International customers don't have to pay VAT here in my country so my shop and the

PayPal module show everything correctly during the checkout and payment process.

The problem starts when a domestic customer pays with PayPal.


Here is the Layout in my Shop (checkout_confirmation.php page)


Item 1 -> 1620 Yen

Item 2 -> 1080 Yen


Sub-Total: 2700 Yen

+ Shipping 810 Yen


Total: 3510 Yen

(incl. 8% VAT, 260 Yen)


As you can see all prices are incl. 8% VAT the items, the shipping cost and at the end inside the brackets you see how much VAT is included in the total amount.

Now PayPal shows me this Layout:


Item 1 -> 1500 Yen

Item 2 -> 1000 Yen


Sub-Total: 2500 Yen

Tax: 260 Yen

Shipping: 810 Yen


Total: 3570 Yen


PayPal shows the item prices without VAT (which i don't mind) but later after the subtotal he adds 260 Yen VAT and additional shipping of 810 Yen (which includes 8% VAT again)

So PP charges the VAT for the shipping cost twice that's why the 60 Yen price difference.

He pulls the VAT of the total amount and the shipping cost.

How to prevent this? I could turn of tax for the shipping cost in my shop but then the shop calculation would not be right.


This following code is raiwas invoice fix (btw. thanks for that @@raiwa! :thumbsup: )


$parameters = array('cmd' => '_cart',
					 'upload' => '1',
					 'handling_cart' => $this->format_raw($order->info['shipping_cost']),
					 'shopping_url' => STORE_URL.'/'.FILENAME_STORE,
					 'tax_cart' => $this->format_raw($order->info['tax']),
					 'currency_code' => $currency,
					 'invoice' => substr($cart_PayPal_Standard_ID, strpos($cart_PayPal_Standard_ID, '-')+1),
					 'custom' => $customer_id,
					 'no_note' => '1',
					 'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false),
					 'return' => tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'),
					 'cancel_return' => tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'),
					 'bn' => 'osCommerce22_Default_ST',
					 'paymentaction' => ((MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD == 'Sale') ? 'sale' : 'authorization'));

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
	 $j = $i + 1;
	 $attributes_description = '';
	 if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
		 for ($j2=0, $n2=sizeof($order->products[$i]['attributes']); $j2<$n2; $j2++) {	
		 $attributes_description = $attributes_description . " (" . $order->products[$i]['attributes'][$j2]['option'] . ': ' . $order->products[$i]['attributes'][$j2]['value'] . ")";	
	 $parameters['item_name_'.$j] = $order->products[$i]['name'] . $attributes_description;		
	 $parameters['amount_'.$j] = $this->format_raw($order->products[$i]['final_price']);
	 $parameters['quantity_'.$j] = $order->products[$i]['qty'];


and how can i change the Layout in the PayPal site? I would like to have the Tax part shown AFTER the shipping cost.











Something like that.


Kind regards


Link to comment
Share on other sites

Just to test everything again i reverted the PP module to as it was with no order details. And i realized that the tax calculation there is also not correct.

Same order as above shows:


both items 2440 Yen

(quantity 1 ?! lol 2 items though...)


Sub-total 2440 Yen

Tax 260 Yen

Shipping 810 Yen


Total 3510 Yen


The Total amount is correct and the shipping cost too but the item prices should be 2500 Yen (excl. VAT) and not 2440 Yen!

The PP module subtracts the VAT from an item price that is already excl. VAT. :blink:

Kinda messed up module isn't it? No one else having trouble with PP standard and taxes?

Edited by Tsimi
Link to comment
Share on other sites

Hi Lambros,


Paypal Standard and OSC dont play that well together when you start sending through itemised payments - The tax is displayed in the wrong place, the rounding of 3 decimals causes problems as well.


The only way around this really is to send a single value to paypal and use the store invoice advise the customer how much tax etc he has paid.


see my post here: http://www.oscommerce.com/forums/topic/396039-paypal-osc-rounding-totals/


Question for @@Harald Ponce de Leon - does the new PP Standard module address any of these issues?



Edited by Mort-lemur

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

PayPal Payments Standard v3.0 does not send the items to PayPal, only the order total values. This will be looked into in the coming weeks.


The other updated PayPal modules do send line items and includes additional order total values (eg discounts). This is only sent if the line item totals equals the order total value, otherwise only the order total values are sent. This happens in rare occasions when third party order total modules manipulate the order tax value.

:heart:, osCommerce

Link to comment
Share on other sites

Hi Heather :)


Thanks for your answer.


I tried any scenario possible.


Since I don't charge VAT for international customers everything shows just fine from the start till the end in my store and PayPal.

(For international customers i don't charge VAT for item nor for shipping.)


BUT for domestic customers it calculates the VAT for the shipping cost twice (2x) I am trying and trying for at least 5 hours straight now with no avail.


Even if i send only 1 value as you recommended to PayPal it calculates the prices wrong. If I do that PayPal deducts VAT from an item that already doesn't have VAT so in my case (-8% x2 = 16%).

Unless i remove these two following code pieces from the paypal_standart.php file.


change this


'tax_cart' => $this->format_raw($order->info['tax']),


to this


'tax' => '',


and this code


'amount' => $this->format_raw($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']),


change to this


'amount' => $this->format_raw($order->info['total'] - $order->info['shipping_cost']),


If i do that the VAT will not show at the PP site and the item prices are calculated correctly.


Still I would like to have a "detailed over view" of the order at the PP site. It just looks stupid when there is my shops name and the subtotal amount of the items and below is written Quantity x1 and Unit price xxxx Yen. I attached some images to show how it looks.


My shop domestic order




Domestic order with PayPal details (with wrong total amount!)




Domestic order with PayPal (with fix above)




And here the international orders (My shop, PP with details and PP single value)








I am really surprised that there is almost no one else that has these tax issues with PP standard. PP is THE most used payment module! Do you guys/girls don't charge taxes? You know what happened to Greece right?

Even if most guys ship only domestic you have to charge VAT so whats the deal here? Is it a shipping module issue? If so why does my shop have no problems with it?

Edited by Tsimi
Link to comment
Share on other sites

@@Harald Ponce de Leon


Is it not possible to tell the PP Standard module


if zone_country_id = '107' {


this code


} else {


this code




? would such a if else function work? Or does the PP module ignore such php code during process?

I tried some combinations but no avail so far.

Edited by Tsimi
Link to comment
Share on other sites

i think i just had a break through! (w00t)


I am using PayPal Standard v3.0 with raiwas PayPal invoice fix add-on.


And i added the following code


if ($order->billing['country']['id'] == '107') {


raiwas invoice fix CODE


( $parameters['amount_'.$j] = $this->format_raw($order->products[$i]['final_price']*1.08); to show the price of each item including 8% VAT)

(and i removed the tax part so PP doesn't calculate the wrong tax amount.)


} else {


raiwas invoice fix CODE untouched




the downside is that for domestic customers the tax amount doesn't show inside the PP details.

The next step would be to figure out a way to add some text below the total amount like (incl. 8% VAT xxx Yen)

for xxx i would use $this->format_raw($order->info['tax']).


Puuhh, I hope what i just wrote made some sense. :wacko: :rolleyes:

Edited by Tsimi
Link to comment
Share on other sites

I just worked with Lambros together to get line items into PayPal Payments Standard v3.1. The Add-On package will be released together with osCommerce Online Merchant v2.3.4.


For those that can't wait, please download the following file and replace the v3.0 version in includes/modules/payment/paypal_standard.php:



:heart:, osCommerce

Link to comment
Share on other sites

I had to laugh when I saw this post.


Almost exactly the situation i described in:-




I wonder how many people will never hear of this and live with shops that do not work correctly?


It is a real shame hese fixes that are regarded as in development until the next release are not all highlighted in an easily accessible place.


Still a decision has been made and we wil have to live with it.





Edited by geoffreywalton

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile


Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.


For links mentioned in old answers that are no longer here follow this link Useful Threads.


If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites



You are absolutely right!

The main issue was not with the Standard module as Harald created it.

With the normal PayPal Standard v3.0 or v1.0 you have only one sub-total amount and shipping cost and total amount.

Which would be enough of course but i wanted to have detailed Info regarding the order inside the PP standard payment page.

So I installed raiwas invoice fix which has the issue calculating tax twice on the shipping cost.


Yesterday Harald and me (well i didn't do much, just ask Harald alot questions) tried to find a way to show an itemized invoice with the correct tax amount as you would see in the shop. It is more a visual thing not really THAT important to have on the PP site. The order in the shop and order history show the taxes.

And as you already mentioned the customer will not see any details on his credit card bill anyway except for the shop name and total amount.

Edited by Tsimi
Link to comment
Share on other sites

NOTE: Does the made fix also handles multiple tax calculations.In some occasions products have different tax.


Good question....should be OK i think...not really sure...needs testing...

Link to comment
Share on other sites

These are the totals shown at PayPal in v3.1 of the module, depending on the configuration of


Show Prices With Tax Enabled:





Show Prices With Tax Disabled:






When show prices with tax is enabled, the product price shown at PayPal includes the tax. If the tax total was also passed the order total calculations would be incorrect as Item Totals + Tax + Shipping would not equal the Total value (the tax is already included in the products price so it ends up being added twice). The tax can be removed from the products price but it will cause the customer confusion who sees another price and also adds further complexity in calculating the order total values.


When show prices with tax is disabled, the product price shown at PayPal excludes the tax. The calculation of Item Totals + Tax + Shipping would then equal the Total amount. Also in this case only the total tax value is passed to PayPal as there might be a store order total module that manipulates the tax in some manner.


PayPal only cares about Item Total, Tax (based on item total, not shipping), and Shipping equalling the Total value that is passed to them. Regardless of the Show Prices With Tax setting, the shipping value passed to PayPal always includes any configured taxes - this can't be included in the Tax value as that is only based on the items.


As you can see, calculating the totals is complex and we have to cater to extra order total modules that could be installed that manipulate the order totals somehow (low order fee, discounts, ...).


As a fallback so that an order can occur, if the PayPal calculated order total value does not equal the store order total value then only the store order total value is passed to PayPal without the line items (products). This is not a problem for the store owner as they can always reference the order in their Administration Tool (which you do anyway, right?).


The next update to the PayPal Payments Standard module will include support for Instant Update which allows PayPal to retrieve defined shipping rates and taxes to the selected PayPal shipping address. This will be worked on in June.

:heart:, osCommerce

Link to comment
Share on other sites

Henry, you're more than welcome to try a fraudulent order on our demo site. Here is how the tax is currently setup:


Product Tax: 7% to Florida in USA

Shipping Tax: 20% to California in USA

Free Shipping: Orders over $499 in USA


Our demo site is at:




Please refer to the payment module code shown next to the payment options to perform your test on.

Edited by Harald Ponce de Leon

:heart:, osCommerce

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...