Salve ragazzi, qualcuno sa come gestire le info inviate da paypal ??? potreste mostrarmi degli esempi ? In giro su internet ho trovato questo.
Vorrei approfondire la cosa...
PHP:
// intercetta le variabili IPN inviate da PayPal
$req = 'cmd=_notify-validate';
// legge l'intero contenuto dell'array POST e replica una nuova variabile
foreach ($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$req .= '&'.$key.'='.$value;
}
//Generazione degli header secondo il nuovo standard PayPal
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.paypal.com\r\n"; // www.paypal.com for a live site
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Connection: close\r\n\r\n";
// apre una connessione al socket PayPal
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// converte le variabili inviate da IPN in variabili locali
$custom = filter_var($_POST['custom'] , FILTER_SANITIZE_STRING);
$txn_id = filter_var($_POST['txn_id'] , FILTER_SANITIZE_STRING);
$payment_status = filter_var($_POST['payment_status'] , FILTER_SANITIZE_STRING);
$receiver_email = filter_var($_POST['receiver_email'] , FILTER_SANITIZE_EMAIL);
$payer_email = filter_var($_POST['payer_email'] , FILTER_SANITIZE_EMAIL);
$first_name = filter_var($_POST['first_name'] , FILTER_SANITIZE_STRING);
$last_name = filter_var($_POST['last_name'] , FILTER_SANITIZE_STRING);
$address_street = filter_var($_POST['address_street'] , FILTER_SANITIZE_STRING);
$address_city = filter_var($_POST['address_city'] , FILTER_SANITIZE_STRING);
$address_state = filter_var($_POST['address_state'] , FILTER_SANITIZE_STRING);
$address_zip = filter_var($_POST['address_zip'] , FILTER_SANITIZE_STRING);
if( ! $fp ){
exit();
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (stripos($res, "VERIFIED") !== false) {
if($receiver_email == "[email protected]"){
}
}
if (strcmp ($res, "INVALID") == 0) {
}
}//while
}//else