Jump to content
Sign in to follow this  
BradWaite

PayPal IPN and tax

Recommended Posts

Hi all,

 

I just implemented PayPal IPN v0.951 and am having a few difficulties that I haven't seen addressed in the forums (correct me if I'm wrong).

 

I've set up tax zones correctly so that a customer in Colorado is charged 2.9% state sales tax. So far, everything's great. But when they check out with PayPal IPN, PayPal adds tax to the total from the shopping cart.

 

Is there any way to turn off PayPal's tax? I can't find it in the docs. I don't want to turn it off in osCommerce, since the customer's invoice won't reflect the correct tax.

Share this post


Link to post
Share on other sites

Came up with a solution that involves hacking the IPN code.

 

In catalog/includes/modules/payment/paypalipn.php add the following into the install() function:

 

 

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Add Tax to Amount', 'MODULE_PAYMENT_PAYPALIPN_ADD_TAX_TO_AMOUNT','False', 'Add tax amount to order amount? (will set tax amount to $0 in PayPal)', '6', '5', 'tep_cfg_select_option(array('True', 'False'), ', now())");

 

 

and change the keys() function to:

 

 

function keys() {

return array('MODULE_PAYMENT_PAYPALIPN_STATUS', 'MODULE_PAYMENT_PAYPALIPN_ID', 'MODULE_PAYMENT_PAYPALIPN_NOTIFY_URL', 'MODULE_PAYMENT_PAYPALIPN_CURL', 'MODULE_PAYMENT_PAYPALIPN_ADD_SHIPPING_TO_AMOUNT', 'MODULE_PAYMENT_PAYPALIPN_ADD_TAX_TO_AMOUNT', 'MODULE_PAYMENT_PAYPALIPN_COMPLETED_TXN_STATUS_ID', 'MODULE_PAYMENT_PAYPALIPN_UPDATE_STOCK_BEFORE_PAYMENT');

}

 

 

 

In catalog/checkout_paypalipn.php change everything after the line "$last_order= $insert" to the following:

 

 

 

$paypal_ipn_order_total = $order->info['total'];

 

if (MODULE_PAYMENT_PAYPALIPN_ADD_SHIPPING_TO_AMOUNT=='True') {

$paypal_ipn_shipping_amount = 0.00;

} else {

$paypal_ipn_order_total -= $order->info['shipping_cost'];

$paypal_ipn_shipping_amount = number_format($order->info['shipping_cost'] * $currencies->get_value('USD'), 2);

};

 

if (MODULE_PAYMENT_PAYPALIPN_ADD_TAX_TO_AMOUNT=='True') {

$paypal_ipn_tax_amount = 0.00;

} else {

$paypal_ipn_order_total -= $order->info['tax'];

$paypal_ipn_tax_amount = number_format($order->info['tax'] * $currencies->get_value('USD'), 2);

};

 

$paypal_ipn_order_amount = number_format($paypal_ipn_order_total * $currencies->currencies['USD']['value'], 2);

 

tep_redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&business=".MODULE_PAYMENT_PAYPALIPN_ID."&item_name=".urlencode(STORE_NAME)."&item_number=".$insert_id."&amount=".$paypal_ipn_order_amount."&shipping=".$paypal_ipn_shipping_amount."&tax=".$paypal_ipn_tax_amount."&return=".tep_href_link(FILENAME_CHECKOUT_SUCCESS,'','SSL')."&cancel_return=".tep_href_link(FILENAME_CHECKOUT_PAYMENT,'','SSL')."&first_name=".urlencode($order->customer['firstname'])."&last_name=".urlencode($order->customer['lastname'])."&address1=".urlencode($order->customer['street_address'])."&city=".urlencode($order->customer['city'])."&state=".urlencode($order->customer['state'])."&zip=".urlencode($order->customer['postcode'])."&email=".$order->customer['email_address']."&bn=oscommerce-osmosis-0.951&notify_url=".MODULE_PAYMENT_PAYPALIPN_NOTIFY_URL);

 

 

 

Now turn PayPal IPN off and back on in the admin interface. You'll have an "Add Tax to Amount" option that works just like the "Add Shipping to Amount"..

Share this post


Link to post
Share on other sites

Pablo, et. al., a "tax" field went live Friday. Third party carts can now specify a fixed tax amount by including a FORM field named "tax" in the PayPal button.


Patrick Breitenbach

Share this post


Link to post
Share on other sites

Hi Patrick and Brad

 

Thanks

 

The taxes now work in the new release of the module!

 

best regards


Pablo Pasqualino

Mar del Plata, Argentina

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×