Jump to content

empty cart problem on paypal sandbox


sasori

Recommended Posts

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 ? :'(

Link to comment
https://forums.phpfreaks.com/topic/256723-empty-cart-problem-on-paypal-sandbox/
Share on other sites

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;\"";}?>>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.