I’m tring to get PayPal IPN to work with my site, heres the code:
else if(isset($_GET['source']) && $_GET['source'] == "paypal")
{
$postvars = array();
while (list ($key, $value) = each ($_POST)) {
$postvars[] = $key;
}
if(count($postvars) < 1){die("No parameters");}
$req = 'cmd=_notify-validate';
for ($var = 0; $var < count ($postvars); $var++) {
$postvar_key = $postvars[$var];
$postvar_value = $$postvars[$var];
$req .= "&" . $postvar_key . "=" . urlencode ($postvar_value); }
$command = "curl -d \\"$req\\" http://www.paypal.com";
exec($command, $output, $return);
echo $command;
print_r($output);
if($output['0'] === "VERIFIED") {
$username = $_POST["custom"];
$untilDate = $_POST["payment_date"];
$email = $_POST["payer_email"];
if(checkUser($username)){
if(isset($_POST["txn_type"]) &&
strtolower($_POST["txn_type"]) == "subscr_signup" || strtolower($_POST["txn_type"]) == "subscr_payment") {
updateLicense($username, "PayPal");
$type = strtolower($_POST["txn_type"]);
sendNotification("PayPal", 1, $type, $email);
echo "SUCCESS add";
}else if(isset($_POST["txn_type"]) &&
strtolower($_POST["txn_type"]) == "subscr_cancelled" || strtolower($_POST["txn_type"]) == "subscr_failed") {
updateLicense($username, "null");
$type = strtolower($_POST["txn_type"]);
sendNotification("PayPal", 0, $type, $email);
echo "SUCCESS remove";
}
else {
mail( "me@janbirsa.com", "PayPal IPN Notice", "User: $username Status: Incorrect Transaction Type ", "From: noreply@janbirsa.com" );
}
}
}
}
But for some reason, it doenst work. I checked with PayPal, its all configured properly. I tried to make test HTTP POST, but PayPal returns “INVALID” as $output[‘0’]