Author Topic: Paypal Integral evolution : how sending the shipment variable??  (Read 11526 times)

lejeannotfr

  • Jr. Member
  • **
  • Posts: 59
Re: Paypal Integral evolution : how sending the shipment variable??
« Reply #15 on: October 09, 2012, 12:22:55 pm »
Sorry for the delay.

Try this Let us know how it goes

Hi panikos, well i have a good & a bad new :
1 - the good one is that your code works on the fisrt page of paypal integral evolution, when you arrive on the paypal page, the "credit card bank payment" (choose to pay with card) shows the shipping address of the buyer, then it's good.
2 - if the customer choose to pay with its paypal account, as you know, he should click on a button to arrive on a second paypal form asking to "sign in" paypal and in this form, the shipping adresse is not automaticaly entered in the form fields.

then i can say it works a half, the shipping address for the payment with paypal account always bugs.
I forgot to tell you, in my form configuration in VM 1.1 i use a payment class "ps_paypal" & not "ps_paypal_api" ... i don't know if this detail is important for you.

Best regard.

lejeannotfr

  • Jr. Member
  • **
  • Posts: 59
Re: Paypal Integral evolution : how sending the shipment variable??
« Reply #16 on: August 14, 2013, 19:52:11 pm »
hi, just to confirm to panikos that this code seems to work but need to be modified this way for me to see it work in france (and europe...hope it will be usefull) but the address form stays empty ... i have just configure it like this... (for france you don't need to put the country and state, neither the "no_shipping" value put as "0" not "1")

Code: [Select]
<?php
$url 
"https://securepayments.paypal.com/acquiringweb";

$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$shipping $db->f("order_shipping");
$order_id $db->f("order_id") ;

// get user info i.e. address etc
$dbb = new ps_DB;
$q "SELECT * FROM jos_vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();

//Query used to find whether to use Bill Address or Ship to address
$dboui = new ps_DB;
$q_oui "SELECT * FROM #__vm_order_user_info ";
$q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY #__vm_order_user_info.order_info_id DESC";
$dboui->setQuery($q_oui);
$dboui->query($q_oui);
$oui_st $dboui->f("address_type");

//now lets see if the order was placed using a shipping address we then send paypal the shipping address
if($oui_st == "ST"){
$db1 = new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$dboui->f("country")."' ORDER BY country_2_code ASC";
$db1->setQuery($q);
$db1->query($q);
$first_name $dboui->f("first_name");
$last_name $dboui->f("last_name");
$address1 $dboui->f("address_1");
$address2 $dboui->f("address_2");
$zip $dboui->f("zip");
$city $dboui->f("city");
$email $dboui->f("user_email");
$night_phone_b $dboui->f("phone_1");
}
//if no shipping address we use send paypal the bill to address
else {
$db2 = new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$dbb->f("country")."' ORDER BY country_2_code ASC";
$db2->setQuery($q);
$db2->query($q);
$first_name $dbb->f("first_name");
$last_name $dbb->f("last_name");
$address1 $dbb->f("address_1");
$address2 $dbb->f("address_2");
$zip $dbb->f("zip");
$city $dbb->f("city");
$email $dbb->f("user_email");
$night_phone_b $dbbt->f("phone_1");
}

$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$shipping $db->f("order_shipping");
$post_variables = Array(

"cmd" => "_ext-enter",
"redirect_cmd" => "_hosted-payment",
"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"),
"subtotal" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"currency_code" => $currency,

"address_override" => "1",

"buyer_email" => $email,
"billing_first_name" => $first_name,
"billing_last_name" => $last_name,
"billing_address1" => $address_1,
"billing_address2" => $address_2,
"billing_city" => $city,
"billing_country" => $country,
"billing_zip" => $zip,
"night_phone_b" => $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.cancel.php&order_id=".$db->f("order_id")."&invoice=".$db->f("order_number"),
"undefined_quantity" => "0",

"test_ipn" => PAYPAL_DEBUG,
"pal" => "XXXXXXXXX(pal_number)",
"no_shipping" => "0",
"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/XXXXXXXXX_limagedetonchoix.gif" alt="bla la la lala " />';

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

}
?>
Will tell you if there's any changes in the way it works...