Paypal - Automatische Zahlung
Hallo,
und zwar komme ich bei der automatischen Zahlung mit Rückwert nicht weiter.
Die Zahlung funktioniert. Jedoch nicht der SQL-Eintrag. Wo ist mein Fehler?
paypal.php
paypal_2.php
Hallo,
und zwar komme ich bei der automatischen Zahlung mit Rückwert nicht weiter.
Die Zahlung funktioniert. Jedoch nicht der SQL-Eintrag. Wo ist mein Fehler?
paypal.php
PHP:
<?php
$link_return = "http://".$_SERVER['HTTP_HOST'].'/paypal_2.php';
$cancel_return = "http://".$_SERVER['HTTP_HOST'].'/paypal.php';
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="E-Mail-Adresse">
<input type="hidden" name="item_name" value="Tes - Aufladen">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="return" value="<?php echo $link_return; ?>">
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return; ?>">
<input type="hidden" name="notify_url" value="<?php echo $link_return; ?>">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="lc" value="DE">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="submit" value="weiter zu PayPal" tabindex="1" class="submit">
</form>
paypal_2.php
PHP:
<?php
// Datenbankverbindung
...
// 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 (replaces old headers)
$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";
$header .= "Connection: close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
//
//successful connection
if ($fp)
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
$res = trim($res); //NEW & IMPORTANT
if (strcmp($res, "VERIFIED") == 0 AND $_POST["payment_status"] == "Completed")
{
$strSQL = "UPDATE test SET test = '".$_POST["amount"]."' WHERE user_id = '".$_POST["item_number"]."'";
mysql_query($strSQL);
}
}
fclose($fp);
}
?>
Zuletzt bearbeitet: