Mostly You encounter a lot of problems that PayPal IPN (Notify URL) is not working for sandbox accounts. Here I described about how we can use a sandbox business account to notify IPN service.
Now the paypal transaction data would be sent to the notification URL. Now create a pay now button using available scope on developer account on PayPal.
After added button, we need a handler file for get transation information on our database.
mysql_connect("localhost", "db_user", "db_password") or die(mysql_error());
mysql_select_db("PayPal") or die(mysql_error());
// 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\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HANDLE HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// PAYMENT VALIDATED & VERIFIED!
}
else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
}
}
fclose ($fp);
}
Thank you for being here, Please share your feedback in below comment section.
In this tutorial, I have write code to add custom meta query in main query…
This website uses cookies.