Author Topic: Mod to allow for "any" country... and sending PayPal LESS info  (Read 3570 times)

MischaH

  • Beginner
  • *
  • Posts: 19
In Åland Islands, an autonomous region of Finland, we are outside of the EU tax region, so things get a bit tricky. (I bet there are other autonomous regions, Greenland, etc, so others could need this info...)

Creating a new Country, made it impossible to pay via PayPal, since they receive country info from the script, and Åland Islands is not a country "proper".

So - i modded the PayPal script from VirtueMart 1.0.x - and voila! - payment worked fine.

AND: Why should the script send all kinds of customer data unnecessarily? Less is more, these days, no?

Here's my script:

Code: [Select]
<?php

if(isset($_SESSION['product_currency']) && $_SESSION['product_currency']!=''){
$currency $_SESSION['product_currency'];
}else{
$currency $_SESSION['vendor_currency'];
}

$url "https://www.paypal.com/cgi-bin/webscr";
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round$db->f("order_total"), 2),
"currency_code" => $currency ,

"cpp_header_image" => $vendor_image_url,

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",

"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "1"
);

if( 
$page == "checkout.thankyou" ) {
$query_string "?";
foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
vmRedirect$url $query_string );
} else {
echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Click to pay with PayPal - it is fast, free and secure!" />';

foreach( 
$post_variables as $name => $value ) {
echo 
'<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
}
echo 
'</form>';

}
?>
Joomla 1.5.26 + VirtueMart 1.1.9
In the process for latest Joomla+VM...

MischaH

  • Beginner
  • *
  • Posts: 19
Re: Mod to allow for "any" country... and sending PayPal LESS info
« Reply #1 on: August 04, 2012, 13:41:39 pm »
EDIT:

My mod - AND the original, both calculate the stuff sent to PayPal incorrectly, if there's a coupon discount involved!

This
Code: [Select]
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
does NOT calculate discount EXCLUDING tax, ergo the PayPal amount turns out too low.

My solution, which also does NOT tell PayPal the unnecessary info about tax, etc:
Code: [Select]
"amount" => round( $db->f("order_total"), 2),
This gives a perfect total for PayPal. My book-keeper is happy. And me, and customer...

This tells PayPal the order total, period. PayPal should be my payment processor, not my IRS :P
Joomla 1.5.26 + VirtueMart 1.1.9
In the process for latest Joomla+VM...

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3050
  • VirtueMart Version: 3.6.11
Re: Mod to allow for "any" country... and sending PayPal LESS info
« Reply #2 on: August 15, 2012, 09:39:20 am »
That is what I do for sending the order total to paypal, I agree with you, PayPal is not my tax accountant!
regards
A

Joomla 3.9.15
php 7.2

MischaH

  • Beginner
  • *
  • Posts: 19
Re: Mod to allow for "any" country... and sending PayPal LESS info
« Reply #3 on: August 20, 2012, 23:59:16 pm »
NOTE: My mod is from this post by a developer webgobe - this post: http://forum.virtuemart.net/index.php?topic=49967.msg254289#msg254289

His post is the only good one that also solves another problem with multiple currencies. Amazing that webgobe's script is not a sticky in this forum area!
Joomla 1.5.26 + VirtueMart 1.1.9
In the process for latest Joomla+VM...