Hi to all,
I am using sandbox paypal PDT for checking the online transaction thing.
After paypal returns to my page I again verify the payment before writing them in to database. The code i am using for verification is below,
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "my token";
$req .= "&tx=$tx_token&at=$auth_token";
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
header("location:thankyou_advertiser.php");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
header("location:error.php");
// log for manual investigation
}
}
fclose ($fp);
This piece of code was working fine, few hours back, now what is happening that with the username and password with which i am paying by sandbox is always returning false, but when I login in to paypal sandbox with the same user name and password it show there sucessful transaction.
I am clueless can anybody help ???????
Thanks in advance
Jawed