Salve, facendo riferimento all'articolo letto "PHP e Paypal IPN" che si trova a questo url: http://www.html.it/articoli/php-e-paypal-ipn-6/
Facendo svariati tentativi non mi memorizza nulla su db.
Lavoro su un host Linux Aruba.
Nell'articolo non sono riuscito a scaricare il codice sorgente e mi sono creato manualmente il database MySql, non vorrei ci fossero piccoli errori di trascrizione, chi mi può aiutare a risolvere il problema?
Questo è il form di invio:
Questa è ipn.php:codice:<form method="post" name="paypal_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr"> <input type="hidden" name="business" value="xxx@xxxx.it" /> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="return" value="<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/PayPal/conferma_pagamento.php" /> <input type="hidden" name="cancel_return" value="<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/PayPal/cancel.php" /> <input type="hidden" name="notify_url" value="<?php echo "http://".$_SERVER['HTTP_HOST']; ?>/PayPal/ipn.php" /> <input type="hidden" name="rm" value="2" /> <input type="hidden" name="currency_code" value="EUR" /> <input type="hidden" name="lc" value="IT" /> <input type="hidden" name="cbt" value="Continua" /> <input type="hidden" name="shipping" value="0.00" /> <input type="hidden" name="cs" value="1" /> <input type="hidden" name="item_name" value="Acquista il video porno di Max e Ufo" /> <input type="hidden" name="amount" value="5.00" /> <input type="hidden" name="custom" value="ABR24" /> <input type="image" src="http://www.paypal.com/it_IT/i/btn/x-click-but01.gif" border="0" name="submit" alt="Paga subito con PayPal" /> </form>
Codice PHP:<?php
// PHP 4.1
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$cn = mysql_connect("62.149.150.122","Sql376649","dd0c1cb2")or die("Connessione non riuscita: " . mysql_error());
mysql_select_db("Sql376649_4", $cn) or die("Errore nella selezione del database");
$query = mysql_query("INSERT INTO notifiche (txn_id, payment_status, payer_email) VALUES ('$txn_id', '$payment_currency', '$payer_email')",$cn);
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>

Rispondi quotando