Hello, I am trying to understand PayPal IPN proccess. I have built this simple script to test with the IPN simulator in the developer section of PayPal. I have tried different type of transaction status but it keeps returning VERIFIED. Can someone please explain to me how does this work? Thanks, Farris
<?php
require_once('../includes/main.php');
// Notify command
$request = "cmd=_notify-validate";
// Prepare the URL to send via cURL
foreach ($_POST as $key => $value){
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()){
$value = urlencode(stripslashes($value));
}else{
$value = urlencode($value);
}
$request .= "&$key=$value";
}
// Initial cURL
$ch = curl_init();
// Set opt
curl_setopt($ch,CURLOPT_URL,"https://www.sandbox.paypal.com/cgi-bin/webscr");
//curl_setopt($ch,CURLOPT_URL,"https://www.paypal.com");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$request);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
// Return result
$result = curl_exec($ch);
// Close cURL connection
curl_close($ch);
// If condition
if($result == 'VERIFIED'){
update_record('users', "ad_space = '{$result}'", ' WHERE user_id = 1');
}else{
update_record('users', "ad_space = '{$result}'" , ' WHERE user_id = 1');
}
?>