VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Payment VM 1.1 => PayPal / PayPal Pro VM 1.1 => Topic started by: rossi256 on July 08, 2008, 13:16:41 PM

Title: Paypal Setup for Virtuemart 1.1 Code
Post by: rossi256 on July 08, 2008, 13:16:41 PM
Hi guys,

I have a problem which actually must appear with everybody using the paypal-code...
In my case i think the country was not delivered correctly - instead there was another country (standard country) delivered and the customer could not change it when checking out/registering at the paypal pages.
For example a customer from Chile had Austria as country - greyed out so he could not change it when he wanted to register...

I solved this problem by changing the code to the following:
<?php
$ct 
$dbbt->f("country");
$db1 = new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$ct."' ORDER BY country_2_code ASC";
$db1->query($q);

// echo "debug".$dbbt->f("country").$db1->f('country_2_code');
$url "https://www.paypal.com/cgi-bin/webscr";
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$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_subtotal")+$tax_total-$discount_total2),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"currency_code" => $_SESSION['vendor_currency'],
"address_override" => "1",
"first_name" => $dbbt->f('first_name'),
"last_name" => $dbbt->f('last_name'),
"address1" => $dbbt->f('address_1'),
"address2" => $dbbt->f('address_2'),
"zip" => $dbbt->f('zip'),
"city" => $dbbt->f('city'),
"state" => $dbbt->f('state'),
"country" => $db1->f('country_2_code'),
"lc" => $db1->f('country_2_code'),
"email" => $dbbt->f('user_email'),
"night_phone_b" => $dbbt->f('phone_1'),
"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>';

}
?>



I am NOT good in programming - but i found that the $user->country in the 3rd line did not work...so i added the
$ct = $dbbt->f("country");

And changed the next line to:
$q = "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$ct."' ORDER BY country_2_code ASC";

now the 2digit countrycode is correctly delivered to paypal.

However, the problem i am still having is, that i want to have Paypal in the customers language.
- I found that there are around 5-6 languages supportet in total ...
- I think that a country code of for example CL for Chile (which should be in spanish language), posted through the lc variable, still brings up the standard language in the Paypal pages (which is in my case US/English).

So my approach would now be to deliver the chosen Joomfish Language of the website to Joomla...
Can anybody help me with getting the Joomla/Joomfish language into the paypal-script?? ("lc"=> xxxxxxxxxxx,)

This would make sense and be a big step for virtuemart <-> Paypal, or ??

any comments are welcome!!

thanks in advance
Rossi
Title: Re: Paypal Setup for Virtuemart 1.1 Code
Post by: norman kaui on April 21, 2010, 06:17:44 AM
Thanks for posting this.  Could you tell me what file you got this code from?  I've been trying for hours to fix an issue where paypal is receiving the wrong country code.

Paypal support told us we need to find out "what we're passing" to them?  I have no idea how to see "what we're passing". :)  So after some additional research I found your post and have a feeling that's it!

Thank for your help. :)