News:

Support the VirtueMart project and become a member

Main Menu

PayPal - Display VAT

Started by Efe, March 31, 2011, 12:31:40 PM

Previous topic - Next topic

Efe

Hello!

I didn't found a solution for my problem.

The VAT(Virtuemart) in the last step will be displayed properly.

If the customer pays with PayPal the VAT will not be displayed.

What change I need to make in PayPal?

The Code:

<?php
$db1 
= new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$user->country."' ORDER BY
country_2_code ASC"
;
$db1->query($q);
$url "https://www.paypal.com/cgi-bin/webscr";
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$shipping_tax_total $db->f("order_tax") + $db->f("order_shipping_tax") - $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"charset" => "utf-8",
"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")+$shipping_tax_total-$discount_total2),
"shipping" => sprintf("%.2f"$db->f("order_shipping")+$db->f("order_shipping_tax")),
"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'),
"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" 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>';
}
?>



Attached two screenshots.

Please help! Thanks

Best regards

[attachment cleanup by admin]

stinga

G'day,

That code look the code I use and I have just found a few problems with it, that I did not notice the first time around....

This seems to work better...

<?php

$db_customer 
= new ps_DB();
$q "select last_name,first_name,address_1,address_2,city,state_name,country,country_2_code,zip,phone_1,user_email from #__vm_user_info ui , #__vm_order_item oi , #__vm_country , #__vm_state where oi.user_info_id=ui.user_info_id and country_3_code = country and state_2_code=state and order_id='$order_id'";

$db_customer->query($q);
$db_customer->next_record();

//Get all the items on the order
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);

$row_num $dboi->num_rows();
$t_quantity 0;
$i=1;

while(
$dboi->next_record())
{
  
$t_quantity $t_quantity intval($dboi->f("product_quantity"));
}

$dboi null;
$dboi = new ps_DB;
$dboi->query($q_oi);

if(
$t_quantity 0)
{
  if(
$discount_totalCP 0) {
    
$disc_perItem round($discount_totalCP $t_quantity2);
  }
  else {
    
$disc_perItem 0;
  }
}
else {
  
$disc_perItem 0;
}

while(
$dboi->next_record()) {

  
$prod_attrib $dboi->f("product_attribute");
  
$supp_var['item_name_' $i] = strip_tags("Order #"$db->f("order_id").": "$dboi->f("order_item_name"));
  
  if(
$prod_attrib ''){
    
$attributes_array explode('<br/>',$prod_attrib);
    
$v 0;
    
$z 1;
    foreach ( 
$attributes_array as $attributes_value){
      
$attrib_name trim(substr($attributes_value0strpos($attributes_value':')), " ");
      
$supp_var['on' $z '_' $i] = $attrib_name;
      
$attrib_sel trim(substr_replace(substr_replace($attributes_value""0strrpos($attributes_value':')), ""02));
      
$supp_var['os' $z '_' $i] = $attrib_sel;
      
$v++;
      
$z++;
      unset(
$attributes_value);
    }
  }

  
$supp_var['item_number_' $i] = $dboi->f("product_id");
  
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
  
$supp_var['amount_' $i] = round(($dboi->f("product_item_price")),2);
  
$i++;
}


$url "https://www.paypal.com/cgi-bin/webscr";
//$url = "http://www.squangle.co.uk/cgi-bin/data_dump.pl";
$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" => "_cart",
"redirect_cmd" => "_ext-enter",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"invoice" => $db->f("order_number"),
"amount" => round$db->f("order_subtotal")-$discount_total2),
"tax_cart" => $tax_total,
"shipping_1" => sprintf("%.2f"$db->f("order_shipping")),
"currency_code" => $db->f("order_currency"),

"item_name" => "test order",

"address_override" => "0",
"first_name" => $db_customer->f('first_name'),
"last_name" => $db_customer->f('last_name'),
"address1" => $db_customer->f('address_1'),
"address2" => $db_customer->f('address_2'),
"zip" => $db_customer->f('zip'),
"city" => $db_customer->f('city'),
"state" => $db_customer->f('state_name'),
"country" => $db_customer->f('country_2_code'),
"email" => $db_customer->f('user_email'),
"night_phone_b" => $db_customer->f('phone_1'),

"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?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"undefined_quantity" => "0",

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

if( 
$page == "checkout.thankyou" ) {
$query_string "?";
foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}

if(
is_array($supp_var) && count($supp_var))
{
    foreach(
$supp_var 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>';

}
?>



Several things wrong with the last code.
Address details where blank in PayPal download.
Vat was missing, it is now shown.
Removed pal => value, it was not needed.
Stinga.
614869 products in 747 categories with 15749 products in 1 category.
                                             Document Complete   Fully Loaded
                Load Time First Byte Start Render   Time      Requests      Time      Requests
First View     2.470s     0.635s     1.276s          2.470s       31            2.470s      31
Repeat View  1.064s     0.561s     1.100s          1.064s       4             1.221s       4

Efe

Hi stinga,

thanks for your information.

I give my feedback when I test it.

Best regards