Ive spent almost a week changing code over and over trying to get this to work. i dont know what im doing wrong. Right now i have it just down to a basic email just to email me and inform me that its working.
<?php
$host = "www.slexchange.com";
$header .= "GET /ans.php?VerifyKey=" . rawurlencode($_REQUEST["VerifyKey"]) . " HTTP/1.0\r\nHost: " . $host . "\r\nConnection: close\r\n\r\n";
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
// HTTP error
mail("me@email.com","HTTP ERROR","");
} else {
fputs($fp, $header);
while (!feof($fp)) {
$result = fgets($fp, 1024);
if (strcmp($result, "SUCCESS") == 0) {
mail("me@email.com","SUCCESS","");
// TODO:
// Check that the VerifyKey has not previously been processed
// Check that the PaymentGross is correct
// Process the payment
echo "success";
} else if (strcmp($result, "FAILURE") == 0) {
mail("me@email.com","FAILURE","");
// TODO:
// Log the transaction for manual investigation
echo "failure";
}
}
fclose($fp);
}
?>