Ich weiß, es gibt viele Fragen zu dieser Anfrage, aber ich kann nicht die richtige Antwort auf meine Bedürfnisse zu beurteilen. Hier ist mein aktueller Code für mein Projekt. und ich bekomme immer eine ungültige Antwort von Paypal mit Paypal Sandbox IPN Simulator.Neueste 2016 Paypal IPN Code immer UNGÜLTIGE Antwort
Kann mir jemand zeigen, was mit meinem Code falsch ist, schätze ich Ihre Hilfe. Vielen Dank im Voraus.
<?php
$post_data = file_get_contents('php://input');
$post_array = explode('&', $post_data);
$dataFromPayPal = array();
foreach ($post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$dataFromPayPal[$keyval[0]] = urldecode($keyval[1]);
}
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($dataFromPayPal as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if(!($res = curl_exec($ch))) {
curl_close($ch);
exit;
}
curl_close($ch);
$tokens = explode("\r\n\r\n", trim($res));
$res = trim(end($tokens));
if (strcmp ($res, "INVALID") == 0) {
echo "INVALID";
}
else if (strcmp ($res, "VERIFIED") == 0) {
$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'];
//STORE temporary info to table
//================
require 'config.php';
$query = "INSERT INTO Payments (ItemName,ItemNumber,PayStatus,PayAmount,PayCurrency,PayTransID,PayEmail,RecEmail)
VALUES('$item_name', '$item_number', '$payment_status', '$payment_amount', '$payment_currency', '$txn_id', '$payer_email', '$receiver_email')";
$result = mysqli_query($con, $query);
mysqli_close($con);
}
?>