Ive searched the forums and read the PayPal documentation but I cant figure out an anser to my simple task.
My order is submitting to PayPal correctly and processing correctly. I need the IPN to set a session for the item_number so that I can use it in later processing, but I can get the IPN to set a session. My code is below. What do I have wrong? Or cant I use IPN to set a session? Thanks.
PHP Code:
session_start();
// Include the paypal library
include_once (Paypal.php);
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Log the IPN results
$myPaypal->ipnLog = TRUE;
// Enable test mode if needed
$myPaypal->enableTestMode();
// Check validity and write down it
// 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
$header .= POST /cgi-bin/webscr HTTP/1.0
;
$header .= Content-Type: application/x-www-form-urlencoded
;
$header .= Content-Length: . strlen($req) .
;
$fp = fsockopen (ssl://www.paypal.com, 443, $errno, $errstr, 30);
// assign posted variables to local variables
$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];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, VERIFIED) == 0) {
session_register(item_number);
$_SESSION[item_number] = $_POST[item_number];
}
else if (strcmp ($res, INVALID) == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
Ive searched the forums and read the PayPal documentation but I cant figure out an anser to my simple task.
My order is submitting to PayPal correctly and processing correctly. I need the IPN to set a session for the item_number so that I can use it in later processing, but I can get the IPN to set a session. My code is below. What do I have wrong? Or cant I use IPN to set a session? Thanks.
PHP Code:
session_start();
// Include the paypal library
include_once (Paypal.php);
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Log the IPN results
$myPaypal->ipnLog = TRUE;
// Enable test mode if needed
$myPaypal->enableTestMode();
// Check validity and write down it
// 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
$header .= POST /cgi-bin/webscr HTTP/1.0
;
$header .= Content-Type: application/x-www-form-urlencoded
;
$header .= Content-Length: . strlen($req) .
;
$fp = fsockopen (ssl://www.paypal.com, 443, $errno, $errstr, 30);
// assign posted variables to local variables
$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];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, VERIFIED) == 0) {
session_register(item_number);
$_SESSION[item_number] = $_POST[item_number];
}
else if (strcmp ($res, INVALID) == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
|
|
Search Webmaster Help and Solution
Another simple PayPal IPN questionRelated ItemsQuery failed: connection to localhost:3354 failed (errno=111, msg=Connection refused). |
