ok i tried that and i got this error
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/tnuke/public_html/order/done.php on line 21
Warning: fsockopen(): unable to connect to
https://www.paypal.com:80 in /home/tnuke/public_html/order/done.php on line 21
Warning: fclose(): supplied argument is not a valid stream resource in /home/tnuke/public_html/order/done.php on line 97
------------------------------------------------------------
so i tried a different attempt, i tried payment data transfer code, and it worked! but when i tried to see if TXN_ID exist i get the error that it exist, and theres nothing in the database!!!
done.php
-------------------------------------------------------------------------
<?php
$db_hostname = "localhost";
$db_username = "user";
$db_password = "pass";
$db_database = "tnuke_templatenuke";
$mysql_connect = mysql_connect("$db_hostname","$db_username","$db_password") or die("Connection Failed!");
$db_select = mysql_select_db($db_database) or die("Database Failed!");
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "my token key is here";
$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.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) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
$txn_id = $keyarray['txn_id'];
$payment_status = $keyarray['payment_status'];
$receiver_email = $keyarray['receiver_email'];
$payment_currency = $keyarray['mc_currency'];
if ($payment_status != "Completed") {
print "payment not completed, <a href=
http://templatenuke.com/order/buy.php?id=14>try agian</a>";exit;
}
if ($receiver_email != "
webmaster@splitnetworks.com") {
print "emails dont match, <a href=
http://templatenuke.com/order/buy.php?id=14>try agian</a>";exit;
}
$sql = mysql_query("SELECT txn_id FROM orders WHERE txn_id ='".$txn_id."'");
$row = mysql_fetch_array($sql);
if ($row['txn_id'] == "$txn_id") {
print "txn exist, <a href=
http://templatenuke.com/order/buy.php?id=14>try agian</a>";
die;
}
include("/home/tnuke/public_html/inc/top.php");
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("<li>Order ID: $txn_id </li>\n");
echo ("");
include("/home/tnuke/public_html/inc/bottom.php");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
}
fclose ($fp);
?>
----------------------------------------------------------------------------------
it worked fine without the
$sql = mysql_query("SELECT txn_id FROM orders WHERE txn_id ='".$txn_id."'");
$row = mysql_fetch_array($sql);
if ($row['txn_id'] == "$txn_id") {
print "txn exist, <a href=
http://templatenuke.com/order/buy.php?id=14>try agian</a>";
die;
}
but that doesnt make any sense!