faxemichel
Script Dealer
- 7 Mai 2006
- 1.759
- 114
Hallo,
vielleicht hatte ja schon einmal jemand das Problem. Ich bekomme immer die Rückmeldung Invalid. Kann da jemand Helfen ?
Das IPN Script
Der Bezahlbutton
vielleicht hatte ja schon einmal jemand das Problem. Ich bekomme immer die Rückmeldung Invalid. Kann da jemand Helfen ?
Code:
VERIFIED
[2017-01-14 10:13 America/Los_Angeles] HTTP request of validation request:POST /cgi-bin/webscr HTTP/1.1
Host: www.sandbox.paypal.com
Accept: */*
Connection: Close
Content-Length: 20
Content-Type: application/x-www-form-urlencoded
for IPN payload: cmd=_notify-validate
[2017-01-14 10:13 America/Los_Angeles] HTTP response of validation request: HTTP/1.1 200 OK
Date: Sat, 14 Jan 2017 18:13:46 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=IXZUub5rSgE-8qY_4KVYhGV10k5l68tcCtHkei_nLvRi7XaPyx9S9ZHMMGV81lkU33daS6aWgNs3ci06FpK6o8k4EG1x37zZOCZb1ke7XAL3sKcH0X5NU0b8DyAO7u4mMG8E0RXUPfasYSLaJV1fKF1Ioa3wyJDFUbDdRt8TxqXZsO-AfQ3GqDR9Uh0LUaniS54Ozqg8zRCB6VAu62KisFjbzpBawCAVStotQUHS0AT2XRcCkA_4Yl-ytRbu28B9N4jZB927neoUuKFRFx3mPd-iiQlwd5bt37S7ViI2FXXeOjywpq0ZSJkgjjshhKAuu6W9JxhYdl7tJtGlFp2naxeToHENR5iAtJXnqLw7ka53nf2Y4W2vUg5EP9J3TBwaNUC762kymYV0ZxBKLCvBlAIzOWedONcB_NDG8LbYPIk6oe_VVyQBl1I5yEy; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Tue, 12-Jan-2027 18:13:46 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Mon, 14-Jan-2019 18:13:46 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1484417626068297; path=/; expires=Mon, 07-Jan-47 18:13:46 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
HTTP_X_PP_AZ_LOCATOR: sandbox.slc
Paypal-Debug-Id: eedee6d7c924
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D1880%26app%3Dappdispatcher%26TIME%3D1516927576%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Sat, 14 Jan 2017 18:43:46 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
INVALID
[2017-01-14 10:13 America/Los_Angeles] Invalid IPN: cmd=_notify-validate
Das IPN Script
PHP:
<?
$sale_amount = "20.00";
$product = "Listen Aufbau PLR Paket";
// CONFIG: Enable debug mode. This means we'll log requests into 'ipn.log' in the same directory.
// Especially useful if you encounter network errors or other intermittent problems with IPN (validation).
// Set this to 0 once you go live or don't require logging.
define("DEBUG", 1);
// Set to 0 once you're ready to go live
define("USE_SANDBOX", 1);
define("LOG_FILE", "ipn.log");
rawurlencode(file_get_contents('php://input'));
// Read POST data
// reading posted data directly from $_POST causes serialization
// issues with array data in POST. Reading raw POST data from input stream instead.
//$raw_post_data = rawurlencode(file_get_contents('php://input'));;
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost 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";
}
// Post IPN data back to PayPal to validate the IPN data is genuine
// Without this step anyone can fake IPN data
if(USE_SANDBOX == true) {
$paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$paypal_url = "https://www.paypal.com/cgi-bin/webscr";
}
$ch = curl_init($paypal_url);
if ($ch == FALSE) {
return FALSE;
}
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_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
if(DEBUG == true) {
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
}
// CONFIG: Optional proxy configuration
//curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
// Set TCP timeout to 30 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// CONFIG: Please download 'cacert.pem' from "https://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below. Ensure the file is readable by the webserver.
// This is mandatory for some environments.
//$cert = __DIR__ . "./cacert.pem";
//curl_setopt($ch, CURLOPT_CAINFO, $cert);
$res = curl_exec($ch);
if (curl_errno($ch) != 0) // cURL error
{
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Can't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE);
}
curl_close($ch);
exit;
} else {
// Log the entire HTTP response if debug is switched on.
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "HTTP request of validation request:". curl_getinfo($ch, CURLINFO_HEADER_OUT) ." for IPN payload: $req" . PHP_EOL, 3, LOG_FILE);
error_log(date('[Y-m-d H:i e] '). "HTTP response of validation request: $res" . PHP_EOL, 3, LOG_FILE);
// Split response headers and payload
list($headers, $res) = explode("\r\n\r\n", $res, 2);
}
curl_close($ch);
}
// Inspect IPN validation result and act accordingly
if (strcmp (!$res, "VERIFIED") == 0) { // Response contains VERIFIED - process notification
//AFFILAITE PRO ACTIONS//
$sale_amount = $_POST['mc_gross'];
$product = $_POST['item_name'];
$affiliate = $_POST['custom']; //YOUR PAYPAL FORM SHOULD INCLUDE A CUSTOM FIELD TO PASS THE AFFILIATE ID TO THE IPN = REFER TO PAYPAL DEV DOCS FOR MORE INFORMATION
include('ipn-record-sale.php');
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE);
}
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
// Add business logic here which deals with invalid IPN messages
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE);
// Send an email announcing the IPN message is INVALID
$mail_From = "";
$mail_To = "";
$mail_Subject = "ASM INVALID IPN";
$mail_Body = $req;
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
}
?>
Der Bezahlbutton
HTML:
<form action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='[email protected]'>
<input type="hidden" name="custom" value="3">
<input type='hidden' name='item_name' value='Listen Aufbau PLR Paket'>
<input type='hidden' name='item_number' value='Listen Aufbau PLR Paket'>
<input type='hidden' name='amount' value='20'>
<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='return' value='https://listen-aufbau.pw/partner/controller/paypal-ipn.php'>
<input type='hidden' name='cancel_return' value='https://listen-aufbau.pw/partner/controller/paypal-ipn.php'>
<input type='hidden' name='bn' value='PP-BuyNowBF'>
<input type='image' src='https://www.paypal.com/de_DE/DE/i/btn/x-click-but6.gif' border='0' name='submit' alt='Zahlen Sie mit PayPal - schnell, kostenlos und sicher!' onFocus='if (this.blur) this.blur()'>
<img alt='' border='0' src='https://www.paypal.com/de_DE/i/scr/pixel.gif' width='1' height='1'>
</form>