Savan Paun
Savan Paun

Reputation: 1733

paypal sandbox testing doesn't return automatic and payment failed error

My testing here http://evasoft.in/paypal/products.php. I am new in paypal, i am try to setup paypal payment via my website and return collect buyer's information like transaction id, date etc. But i got payment failed error and i doesn't get any value from paypal. I WANT AUTOMATIC REDIRECT AFTER SUCCESS.

My product page's code

 <form action='<?php echo $paypal_url; ?>' method='post' name='frmPayPal1'>
                    <input type='hidden' name='business' value='<?php echo $paypal_id;?>'>
                    <input type='hidden' name='cmd' value='_xclick'>

                    <input type='hidden' name='item_name' value='<?php echo $row['product'];?>'>
                    <input type='hidden' name='item_number' value='<?php echo $row['pid'];?>'>
                                   <input type='hidden' name='amount' value='<?php echo $row['price'];?>'>

                    <input type='hidden' name='no_shipping' value='1'>
                    <input type='hidden' name='currency_code' value='USD'>
                    <input type='hidden' name='handling' value='0'>
                    <input type='hidden' name='cancel_return' value='http://evasoft.in/paypal/cancel.php'>
                    <input type='hidden' name='return' value='http://evasoft.in/paypal/success.php'>

                    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
                    <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
                </form> 

My Sucess.php page code here

<?php
require 'db_config.php';
$item_no = $_GET['item_number'];
$item_transaction = $_GET['tx'];
$item_price = $_GET['amt'];
$item_currency = $_GET['cc'];

//Getting product details
$sql=mysql_query("select product,price,currency from products where pid='$item_no'");
$row=mysql_fetch_array($sql);
$price=$row['price'];
$currency=$row['currency'];

//Rechecking the product details
if($item_price==$price && item_currency==$currency)
{

$result = mysql_query("INSERT INTO sales(pid, uid, saledate,transactionid) VALUES('$item_no', '$uid', NOW(),'$item_transaction')");
if($result){
  echo "<h1>Welcome, $username</h1>";
    echo '<h1>Payment Successful</h1>';
    echo "<b>Example Query</b>: INSERT INTO sales(pid, uid, saledate) VALUES('<font color='#f00;'>$item_no</font>', '<font color='#f00;'>$uid</font>', <font color='#f00;'>NOW()</font>)";
}else{
    echo "Payment Error";
}
}
else
{
echo "Payment Failed";
}
?>

Upvotes: 0

Views: 1222

Answers (1)

Vimalnath
Vimalnath

Reputation: 6463

I have done a test checkout on your website and could see that Auto Return feature is turned off on your sandbox account.

Auto Return is turned off by default.

1.To turn on Auto Return

2.Log in to your PayPal account at https://www.paypal.com.

3.The My Account Overview page appears.

4.Click the Profile subtab.

5.The Profile Summary page appears. Under the Selling Preferences column, click the Website Payment Preferences link.

6.The Website Payment Preferences page appears, as shown below.

7.Under Auto Return for Website Payments, click the On radio button to enable Auto Return.

8.In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments.

Also, note that Auto Return Feature will not work if the Payment is made with Debit or credit card. You need to manually click in "return" link to get re-directed to your return URL.

Upvotes: 1

Related Questions