Der Syntax Fehler war nicht im Code vorhanden sondern weil ich das so aus dem Supportticket rübergeholt habe.
Denen ihr System hat die Backslashes entfernt.
Ich versende mit php halt eine Mail und da würde ich die Werte gerne einfügen.
Hier schau mal:
Code
require ("config.php");
function generatePassword ($length = 16)
{
// Passwort
$password = "";
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
return $password;
}
// Rückgabe von PayPal
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$req .= "&tx=$tx_token&at=$auth_token";
// zurück zu PayPal
$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.paypal.com', 80, $errno, $errstr, 30);
// Wenn möglich per HTTPS
// $fp = fsockopen ('ssl://www.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 wurde gelesen, jetzt der Inhalt
$res .= $line;
}
}
// parse
$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 payment_status
// check txn_id
// check receiver_email
// check payment_amount/payment_currency
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
$eml = $keyarray['payer_email'];
$itemid = $keyarray['item_number'];
/* Hack */
$payer_business_name = $keyarray['payer_business_name'];
$contact_phone = $keyarray['contact_phone'];
$address_street = $keyarray['address_street'];
$address_zip = $keyarray['address_zip'];
$address_state = $keyarray['address_state'];
$address_country = $keyarray['address_country'];
$address_city = $keyarray['address_city'];
if ($payer_business_name != "") {
$business_name = "<h2 class=\"name\">$payer_business_name</h2>";
}
/* Hack End */
// parse
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
echo '<p>PayPal-Parameter:</p><ul>';
for ($i = 1; $i < count($lines); $i++) {
list($key, $val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
printf("<li><code>%s</code> = <code>%s</code></li>\n", htmlspecialchars(urldecode($key)), htmlspecialchars(urldecode($value)));
}
echo "</ul>\n";
// == snip ==
}
exit;
Alles anzeigen
gibt das hier aus:
Code
PayPal-Parameter:
mc_gross =
protection_eligibility =
payer_id =
tax =
payment_date =
payment_status =
charset =
first_name =
mc_fee =
custom =
payer_status =
business =
quantity =
payer_email =
txn_id =
payment_type =
last_name =
receiver_email =
payment_fee =
shipping_discount =
insurance_amount =
receiver_id =
txn_type =
item_name =
discount =
mc_currency =
item_number =
residence_country =
handling_amount =
shipping_method =
transaction_subject =
payment_gross =
shipping =
=
Alles anzeigen