News:

Support the VirtueMart project and become a member

Main Menu

Paypal Payment Extra Info

Started by byeb1264, November 04, 2009, 14:41:43 PM

Previous topic - Next topic

byeb1264

Hello all,
I made a bonehead mistake and began tinkering with the paypal payment extra info: date without backing up the default data.  Can anyone with a current virtue mart install copy and paste me the default data so I can put it back?   

Thanks,
Brian

byeb1264

Well after digging through phpmyadmin for a while.  I found the original code mentioned above on a different vm db I had.  I had noticed alot of people asking for this info and nobody has replied back with the code.  So here it is, the default paypal payment extra info:

<?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");
$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'),
"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>';

}
?>

mike_9000

Thanks for this! Saved my life... I managed to delete the whole thing.

You're only young once - but you can be immature for ever...

oz_bestsellers

Quote from: byeb1264 on November 04, 2009, 15:40:58 PM
Well after digging through phpmyadmin for a while.  I found the original code mentioned above on a different vm db I had.  I had noticed alot of people asking for this info and nobody has replied back with the code.  So here it is, the default paypal payment extra info:

<?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");
$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'),
"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>';

}
?>


oz_bestsellers

Hello,

This is my first post so pls excuse my ignorance but I am using Virtuemart 1.1.7 & using the code mentioned above for Paypal payments. Every thing works fine but only problem is that when I click on "Cancel & return to mysite name" or after completing payment when I try to return to my site, it gives an error "The requested URL '/index.php' was not found on this server.". Basically it is trying to look for index.php on https://www.paypalobjects.com instead of my site. I have tried modifing below lines

"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",

but am unable to sort this out. Any help will be highly appreciated.

With Regards
A Newbie

PMA

All:

Can you look at my PAYPAL configuration and tell me where I went wrong?

<?php

$url = "https://www.paypal.com/cgi-bin/webscr";

$order_id = $db->f("order_id");

$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");

$discount_total = $db->f("coupon_discount") + $db->f("order_discount"); 



// Query for Order Items

$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();



//Getting Cart Items

$auth = $_SESSION['auth'];

$cart = $_SESSION['cart'];

$t_quantity = 0;

$disc_perItem = 0;

$i=1;



// Query to get User Info

$dbb = new ps_DB;

$q = "SELECT * FROM #__vm_user_info ";

$q .= "WHERE user_id ='".$my->id."' ";

$dbb->setQuery($q);

$dbb->query();


$discount_totalCP = $db->f("coupon_discount") + $db->f("order_discount");



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_quantity, 2);

  }

  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($VM_LANG->_('PHPSHOP_ORDER_LIST_ID') . " " . $db->f("order_id").": ". $dboi->f("order_item_name"));



  if($prod_attrib > ''){

    $attributes_array = explode('
',$prod_attrib);

    $v = 0;

    $z = 1;

    foreach ( $attributes_array as $attributes_value){

      $attrib_name = trim(substr($attributes_value, 0, strpos($attributes_value, ':')), " ");

      $supp_var['on' . $z . '_' . $i] = $attrib_name;

      $attrib_sel = trim(substr_replace(substr_replace($attributes_value, "", 0, strrpos($attributes_value, ':')), "", 0, 2));

      $supp_var['os' . $z . '_' . $i] = $attrib_sel;

      $v++;

      $z++;

      unset($attributes_value);

    }

  }



  $supp_var['item_number_' . $i] = $dboi->f("order_item_sku");

  $supp_var['quantity_' . $i] = $dboi->f("product_quantity");

  $supp_var['amount_' . $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);

  $i++;

}


$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->query($q_oui);





  $first_name = $dboui->f("first_name");

  $last_name = $dboui->f("last_name");

  $address1 = $dboui->f("address_1");

  $address2 = $dboui->f("address_2");

  $city = $dboui->f("city");

  $state = $dboui->f("state");

  $address_country = $dboui->f("country_2_code");

  $zip = $dboui->f("zip");

  $H_PhoneNumber = $dboui->f("phone_1");



$post_variables = Array(

"charset" => "utf8",

"cmd" => "_cart",

"upload" => "1",

"page_style" => "paypal",

"business" => info@irectdist.com ----SHOULD THIS BE HERE?,

"currency_code" => $_SESSION['vendor_currency'],

"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),

"handling_cart" => sprintf("%.2f", $db->f("order_shipping")),

"tax" => $tax_total,

"tax_cart" => $tax_total,

"invoice" => $db->f("order_number"),

"image_url" => $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",

"no_shipping" => "1",

"no_note" => "1",

"email" => $dbb->f("user_email"),

"address_override" => "1",

"first_name" => $first_name,

"last_name" => $last_name,

"address1" => $address1,

"address2" => $address2,

"city" => $city,

"state" => $state,

"country" => $address_country,

"zip" => $zip,

"night_phone_b" => $H_PhoneNumber

);


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">';



  foreach( $post_variables as $name => $value ) {

    echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';

  }



  if(is_array($supp_var) && count($supp_var)) {

    foreach($supp_var as $name => $value) {

      echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';

    }

  }

  echo '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';


  echo '</form>';

}

?>

stinga

Please don't hijack a thread, start a new one.
and you have not told us what the problem is...
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

PMA

I am sorry, I am a newbie to forums and will certainly adapt to the policies...thanks a million!