Salve,
vorrei sottoporre un problema con il pagamento con paypal e php.
Nel mio sito ho una pagina dinamica, dove mostro dei disegni che vendo online.
Ogni disegno ha un pulsante di pagamento paypal.
Questo è il codice del carrello standard di paypal:
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="bn" value="webassist.dreamweaver.4_5_0" />
<input type="hidden" name="business" value="riservata22@virgilio.it " />
<input type="hidden" name="item_name" value="<?php echo $row_rsDisegni['Titolo']; ?>" />
<input type="hidden" name="item_number" value="<?php echo $row_rsDisegni['Riferimento']; ?>" />
<input type="hidden" name="amount" value="<?php echo $row_rsDisegni['Prezzo']; ?>" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="lc" value="IT">
<input type="hidden" name="return" value="http://mio-sito.it/conferma.php" />
<input type="hidden" name="cancel_return" value="" />
<input type="hidden" name="receiver_email" value="riservata22@virgilio.it" />
<input type="hidden" name="mrb" value="R-3WH47588B4505740X" />
<input type="hidden" name="pal" value="ANNSXSLJLYR2A" />
<input type="hidden" name="rm" value="2">
<input type="hidden" name="no_shipping" value="0" />
<input type="hidden" name="no_note" value="0" />
<input type="image" class="senza" name="submit" src="immagini/carrello3.png" border="0" title="Effettua i toui pagamenti con PayPal. Un sistema rapido, gratuito e sicuro!" />
</form>
Il pagamento avviene regolarmente. Dentro sandbox ho verificato gli ordini effettuati, le email partite regolarmente.
Quello che non funziona regolarmente e il Trasferimento dei dati di pagamento (PDT).
Ho usato lo script trovato su paypal:
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "1aHBkHhVULUvZ6bimImLx7Wq3tqVIN4J4zpHJTrabT0NScXO8 MAE6GY4pvi";
$req .= "&tx=$tx_token&at=$auth_token";
// 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 ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// 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
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
<?php /*?>$amount = $keyarray['payment_gross'];<?php */?>
echo ("
<h3>Grazie per il tuo acquisto!</h3></p>");
echo ("Dettagli del pagamento
\n");
echo ("[*]Nome: $firstname $lastname\n");
echo ("[*]Oggetto: $itemname\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
}
fclose ($fp);
?>
Quando paypal, dopo la transazione regolarmente effettuata, torna alla pagina del mio sito pdt.php, si visualizza solo il nome e cognome dell'acquirente, ma non il nome del prodotto acquistato. Dove sbaglio?