PHP PayPal IPN Shell
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP PayPal IPN Shell相关的知识,希望对你有一定的参考价值。
<?php
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header .= "POST /cgi-bin/webscr HTTP/1.0
";
$header .= "Host: www.paypal.com:80
";
// $header .= "Host: www.sandbox.paypal.com:80
";
$header .= "Content-Type: application/x-www-form-urlencoded
";
$header .= "Content-Length: " . strlen($req) . "
";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
// Do some code when your server cannot communicate with PayPal!
mail('email@yourhost.com', 'IPN ERROR', "HTTP ERROR\n\n" . $res);
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if ($_POST['payment_status'] == 'Completed') {
// Do some code when PayPal returns payment completed status!
foreach ($_POST as $key => $value){
$emailtext .= $key . ": " . $value . "\n";
}
mail('email@yourdomain.com', "IPN VARIABLES", $emailtext . "\n\nREQUEST STRING:\n" . $req);
} else {
// Do some code when PayPal returns a different status!
foreach ($_POST as $key => $value) {
$emailtext .= $key . ": " . $value . "\n";
}
mail('email@yourdomain.com', "IPN VARIABLES", $emailtext . "\n\nREQUEST STRING:\n" . $req);
}
} elseif (strcmp ($res, "INVALID") == 0) {
// Do some code when PayPal returns some error!
foreach ($_POST as $key => $value){
$emailtext .= $key . ": " . $value . "\n";
}
mail('email@yourdomain.com', "IPN VARIABLES", $emailtext . "\n\nREQUEST STRING:\n" . $req);
}
}
fclose ($fp);
}
?>
以上是关于PHP PayPal IPN Shell的主要内容,如果未能解决你的问题,请参考以下文章
PayPal IPN 脚本未重定向到 ipn.php
PHP PayPal IPN代码段
与paypal IPN(PHP)相关的问题
Paypal IPN 现在返回 INVALID - PHP 代码以前工作正常
PayPal IPN HTTP 错误 400 - PHP - 使用 PayPal GIT 代码
PHP Paypal“官方”IPN 监听器无法正常工作