sasori Posted February 9, 2012 Share Posted February 9, 2012 Hi, is there something wrong with my code ? <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" <?php if(empty($_SESSION['cart'])){echo "onsubmit=\"return false;\"";} ?>> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="business" value="<?=$ppemail['email']?>" /> <?php $i = 1; foreach($_SESSION['cart'] as $id => $qty): $product = $myCart->getProduct($id); ?> <input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo $product['ProductName']; ?>"> <input type="hidden" name="item_number_<?php echo $i; ?>" value="<?php echo $product['ProductID']; ?>"> <input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $product['ProductOverridePrice']; ?>"> <input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $qty; ?>"> <?php $i++; endforeach; ?> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="shipping_1" value="<?php echo $shipping; ?>"> <input type="hidden" name="return" value="<?php echo $the_class->settings[0]['DomainName'];?>shopping-cart-details.php"> <input type="hidden" name="cancel_return" value="<?php echo $the_class->settings[0]['DomainName'];?>"> <input type="hidden" name="notify_url" value="<?php echo $the_class->settings[0]['DomainName'];?>classes/paypal.php"> <input type="image" src="images/continue-btn.png" name="pay now" value="pay" /> while cart is not empty, I tested it locally and it worked fine.. but when I tested it on a live server, sandbox says, your cart is empty, even if it's not empty at all.. any ideas why is this happening ? :'( Quote Link to comment https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/ Share on other sites More sharing options...
darkfreaks Posted February 9, 2012 Share Posted February 9, 2012 use isset as well //if empty and not isset return false else return cart session $cart= (empty($_SESSION['cart') && !isset($_SESSION['cart'])) ? 'onsubmit=\"return false;\"' : $_SESSION['cart']; Quote Link to comment https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/#findComment-1316062 Share on other sites More sharing options...
sasori Posted February 9, 2012 Author Share Posted February 9, 2012 use isset as well //if empty and not isset return false else return cart session $cart= (empty($_SESSION['cart') && !isset($_SESSION['cart'])) ? 'onsubmit=\"return false;\"' : $_SESSION['cart']; it didn't helped, I did it like this <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" <?php if(empty($_SESSION['cart']) && !isset($_SESSION['cart'])){echo "onsubmit=\"return false;\"";}?>> Quote Link to comment https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/#findComment-1316065 Share on other sites More sharing options...
delickate Posted February 9, 2012 Share Posted February 9, 2012 Hi, You must check your session value. I just check your code in a simple way. <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="business" value="[email protected]" /> <input type="hidden" name="item_name_1" value="testing product name"> <input type="hidden" name="item_number_1" value="432432423"> <input type="hidden" name="amount_1" value="22"> <input type="hidden" name="quantity_1" value="1"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="shipping_1" value="0"> <input type="hidden" name="return" value="http://www.miricreation.ae.com/shopping-cart-details.php"> <input type="hidden" name="cancel_return" value="http://www.miricreation.ae.com/"> <input type="hidden" name="notify_url" value="http://www.miricreation.ae.com/classes/paypal.php"> <input type="submit" value="pay" /> </form> it works fine. and i payed successfully through my test account. after my payment success. it should came back to my specified URL. but it didn't. any one know how it'll auto back to my website after payment completion.???? Please help Quote Link to comment https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/#findComment-1316067 Share on other sites More sharing options...
sasori Posted February 9, 2012 Author Share Posted February 9, 2012 pfft, nevermind this thread.. I found the bug..the field name of the products table is small caps...geez.. Quote Link to comment https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/#findComment-1316075 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.