即时付款通知(IPN)模拟器剂量工作

时间:2013-02-22 08:52:31

标签: php paypal payment-gateway paypal-ipn

IPN传递失败。无法连接到指定的URL。请验证该网址,然后重试。

我正在尝试使用我的Paypal ipn模拟器,但每次它给我这个错误消息,似乎ipn模拟器无法命中指定的URL,即使我确定指定的URL是正确的。任何帮助,请

// Connect to database --------------------------------------------------------------------------------------------------

----
    require_once ('../config/cart_api.php');

    // bussines email
    $bussines_email = 'tbuss_1358873839_biz@hotmail.com';


// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST") die ("No Post Variables");

// Initialize the $req variable and add CMD key value pair
$req = 'cmd=_notify-validate';
// Read the post from PayPal
foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
}

// Now Post all of that back to PayPal's server using curl, and validate everything with PayPal
// We will use CURL instead of PHP for this for a more universally operable script (fsockopen has issues on some environments)
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
//$url = "https://www.paypal.com/cgi-bin/webscr";
$curl_result=$curl_err='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req)));
curl_setopt($ch, CURLOPT_HEADER , 0);   
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$curl_result = @curl_exec($ch);
$curl_err = curl_error($ch);
curl_close($ch);

$req = str_replace("&", "\n", $req);  // Make it a nice list in case we want to email it to ourselves for reporting

// Check that the result verifies
if (strpos($curl_result, "VERIFIED") !== false) {
    $req .= "\n\nPaypal Verified OK";
    mail("eagleeyes26@hotmail.com", "IPN interaction verified keep going", "$req", "eagleeyes26@hotmail.com" );

} else {
    $req .= "\n\nData NOT verified from Paypal!";
    mail("eagleeyes26@hotmail.com", "IPN interaction not verified", "$req", "eagleeyes26@hotmail.com" );
    exit();
}

/* CHECK THESE 4 THINGS BEFORE PROCESSING THE TRANSACTION, HANDLE THEM AS YOU WISH
1. Make sure that business email returned is your business email
2. Make sure that the transaction�s payment status is �completed�
3. Make sure there are no duplicate txn_id
4. Make sure the payment amount matches what you charge for items. (Defeat Price-Jacking) */

// Check Number 1 ------------------------------------------------------------------------------------------------------------
if ($bussines_email != $_POST['receiver_email']) 
{
    $message = "Investigate why and how receiver email is wrong. Email = " . $_POST['receiver_email'] . "\n\n\n$req";
    mail("eagleeyes26@hotmail.com", "Receiver Email is incorrect", $message, "From: eagleeyes26@hotmail.com" );
    exit(); // exit script
}

// Check number 2 ------------------------------------------------------------------------------------------------------------
if ($_POST['payment_status'] != "Completed") {
    // Handle how you think you should if a payment is not complete yet, a few scenarios can cause a transaction to be incomplete
}
else 
    {
        $message = "Payment status is completed = " . $_POST['payment_status'] . "\n\n\n$req";
        mail("eagleeyes26@hotmail.com", "Payment status is completed", $message, "From: eagleeyes26@hotmail.com" );
        exit(); // exit script
    }

2 个答案:

答案 0 :(得分:1)

您是否已将文件上传到免费的Weberver上?或免费域名?这发生在我身上,当我尝试将我的ipn脚本存储在000webhost上时,我在其他网络服务器上传输我的文件,令我惊讶的是,ipn模拟器成功地向我的ipn处理程序页面发送了一个ipn

答案 1 :(得分:0)

Paypal IPN模拟器对我不起作用。我使用了两个不同的服务器,登录到外部Linux服务器(在另一个国家)和wgetting处理程序URL工作正常。使用模拟器没有收到任何信息并且模拟器页面打印“IPN Delivery Failed:I / O错误:连接超时;嵌套异常是java.net.ConnectException:连接超时”一段时间后。

Handler url是tomcat jsp页面,使用ip和hostname没有帮助。

https://developer.paypal.com/webapps/developer/applications/ipn_simulator
http://111.222.333.444:8080/testing/paypal_IPN.jsp
http://myserver.com:8080/testing/paypal_IPN.jsp

如果我自己在浏览器中调用了paypal_IPN.jsp,则会调用https://www.sandbox.paypal.com/cgi-bin/webscr url并使用cmd = _notify-validate& param和jsp读取INVALID字符串的回复,因为期待'因为这无论如何都是foodoo事务。

测试商家帐户已启用IPN,IPN历史记录显示交易,尝试重新发送交易,全部失败。我的Paypal集成测试用例的大型showstopper,无法验证结帐管道,无法上线。

在商家测试应用程序中启用了IPN,但这不应该影响IPN模拟器。使用POSTFORM经典提交cgibin按钮顺利,测试签证付款确定,但即使这样,IPN处理程序url也不会被调用。 IPN历史记录显示状态失败的交易。

https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-ipn-notify https://www.sandbox.paypal.com/cgi-bin/webscr