Author Topic: [TRACKER # 1505] PayPal and empty shopping cart  (Read 23665 times)

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
[TRACKER # 1505] PayPal and empty shopping cart
« on: October 19, 2007, 03:58:34 am »
Joomla 1.0.13
VirtueMart 1.1 r1002

Until now, due to this error I used cash on delivery method for testing, today I decided to give PayPal another try, the error has gone however when I get redirected to PayPal to complete payment I get the following message "Error detected - Your shopping cart is empty".

I am testing in sandbox, here is the PayPal code.
Code: [Select]
<?php
$url 
"https://www.sandbox.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" => "_cart",
"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'],"first_name" => $dbbt->f('first_name'),
"last_name" => $dbbt->f('last_name'),
"address_street" => $dbbt->f('address_1'),
"address_zip" => $dbbt->f('zip'),
"address_city" => $dbbt->f('city'),
"address_state" => $dbbt->f('state'),
"address_country" => $dbbt->f('country'),
"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",
"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) ."&";
}
mosRedirect$url $query_string );
} else {

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!" />';

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

echo 
'</form>';

}
?>

Is it me or others have same issue.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27385
  • Always on vacation
    • Jenkin Hill Internet
Re: PayPal and empty shopping cart
« Reply #1 on: October 19, 2007, 18:26:09 pm »
Confirmed. "Error Detected   Your shopping cart is empty"

Database Version: 4.1.20
PHP Version: 4.4.2
Web Server: Apache
VirtueMart 1.1: Ver. 1002
Joomla! Version: Joomla! 1.0.13 Stable [ Sunglow ]
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.6 PHP 7.0.33
Testing VM 3.4.5.10058 on Joomla 3.9.6

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27385
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.6 PHP 7.0.33
Testing VM 3.4.5.10058 on Joomla 3.9.6

patrik60

  • Guest
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #3 on: October 21, 2007, 17:52:45 pm »
hi

change "cmd" => "_cart", 

into

"cmd" => "_xclick",

then it works.

patrik

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #4 on: October 22, 2007, 21:08:17 pm »
As suggested by Patrick changing the code from this

Code: [Select]
"cmd" => "_cart", to this worked.

Code: [Select]
"cmd" => "_xclick",
So does this code by Scott Carroll (see link for more)
http://forum.virtuemart.net/index.php?topic=28867.msg88075#msg88075

Code: [Select]
<?php
$db1 
= new ps_DB();
$q "SELECT country_2_code FROM joom_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" => "_xclick",
"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" => $user->first_name,
"last_name" => $user->last_name,
"address1" => $user->address_1,
"address2" => $user->address_2,
"city" => $user->city,
"state" => $user->state,
"zip" => $user->zip,
"country" => $db1->f("country_2_code"),
"email" => $user->user_email,
"night_phone_c" => $user->phone_1,

"cpp_header_image" => "YOUR_IMAGE_FILE",
"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) ."&";
}
mosRedirect$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.'" />';
}

echo 
'</form>';

}
?>

patrik60

  • Guest
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #5 on: October 22, 2007, 23:59:38 pm »
The problem with the special characters remains. If you have a character like ä, ö, ü in  your name you will get an other error message on the paypal site. to solve this problem I need the following changes:

Code: [Select]
"first_name " => $dbbt->f('åçêëèöäöüß'),
"last_name" => $dbbt->f('åçêëèöäöüß'),
"address_street" => $dbbt->f('åçêëèöäöüß'),
"address_zip" => $dbbt->f('zip'),
"address_city" => $dbbt->f('åçêëèöäöüß'),

Scott Carroll

  • Jr. Member
  • **
  • Posts: 70
    • my test site
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #6 on: October 25, 2007, 21:48:38 pm »
Okay, the difference is that cmd = "_xclick" will send the entire order as one invoice. It expects the shopping cart software (virtuemart) to have itemized the cart. Whereas cmd = "_cart" is expecting to use paypal's shopping cart software.

So, since we only need paypal as a payment processor, we should have cmd set to _xclick.


aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #8 on: October 26, 2007, 00:00:10 am »
Another change to VM 1.1 default PayPal code based on tracker 1395 is to change image_url to cpp_header_image due to PayPal changes

Scott Carroll

  • Jr. Member
  • **
  • Posts: 70
    • my test site
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #9 on: November 01, 2007, 18:00:04 pm »
Okay, the code should be:
Code: [Select]
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",

and yes, cpp_header_image works.

Scott Carroll

  • Jr. Member
  • **
  • Posts: 70
    • my test site
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #10 on: November 01, 2007, 22:42:46 pm »
Let me know if there are still issues with the following code:

Code: [Select]
<?php
// Get the 2 character country code
$db1 = new ps_DB();
$q "SELECT country_2_code FROM joom_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",

"cpp_header_image" => $vendor_image_url,
"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'),
"address_street" => $dbbt->f('address_1'),
"address_zip" => $dbbt->f('zip'),
"address_city" => $dbbt->f('city'),
"address_state" => $dbbt->f('state'),
"address_country" => $db1->f("country_2_code"),

"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_note" => "1"
);

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

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!" />';

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

echo 
'</form>';

}
?>

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #11 on: November 01, 2007, 22:50:49 pm »
Scott, in revision 1026 Soeren and Greg did some changes to the code I was testing it, which seems to be working OK, are you saying to change that code to the one you posted?

Scott Carroll

  • Jr. Member
  • **
  • Posts: 70
    • my test site
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #12 on: November 02, 2007, 21:34:05 pm »
Mine is supposed to propagate the address info. I have received one report that it doesn't. Could you test it more for me. It works for me, using my paypal account - but if someone checks out without a paypal account, I am not 100% sure if it does what it is supposed to by sending address info.

milescook

  • Beginner
  • *
  • Posts: 1
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #13 on: November 05, 2007, 11:00:26 am »
I also don't get my address information carried on to Paypal.  I also get order not found when returning from Paypal, but if I keep refreshing a few seconds later it works.

Joomla 1.5 9292
VM 1.1 1029
MySQL 4.1.15
PHP 4.4.7

Scott Carroll

  • Jr. Member
  • **
  • Posts: 70
    • my test site
Re: [TRACKER # 1505] PayPal and empty shopping cart
« Reply #14 on: November 11, 2007, 16:11:08 pm »
OMG,
I just noticed that I posted the wrong code here...
I do have paypal working using the following code:

Code: [Select]
<?php
$db1 
= new ps_DB();
$q "SELECT country_2_code FROM joom_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",
"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('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_note" => "1"
);
if( 
$page == "checkout.thankyou" ) {
$query_string "?";
foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
mosRedirect$url $query_string );
} else {

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!" />';

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

echo 
'</form>';

}
?>

I am sorry for the confusion.