【问题标题】:Instant Payment Notification (IPN) simulator dose work即时付款通知 (IPN) 模拟器剂量工作
【发布时间】:2013-02-07 20:02:16
【问题描述】:

IPN 传送失败。无法连接到指定的 URL。请验证 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
    }

【问题讨论】:

  • 提供代码,你试过什么?

标签: php paypal payment-gateway paypal-ipn


【解决方案1】:

Paypal IPN 模拟器不适用于我。我使用了两台不同的服务器,登录到外部 linux 服务器(在另一个国家/地区)并且 wgetting 处理程序 url 工作正常。使用模拟器没有收到任何东西,模拟器页面在一段时间后打印“IPN Delivery Failed:I/O error: Connection timed out; nested exception is java.net.ConnectException: Connection timed out”。

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,它会使用 cmd=_notify-validate& 参数调用 https://www.sandbox.paypal.com/cgi-bin/webscr url,并且 jsp 会按照预期读取 INVALID 字符串回复,因为无论如何这是一个 foodoo 交易。

测试商户账号开启IPN,IPN历史显示交易,尝试重发交易,均失败。我的 Paypal 集成测试用例的大场面,如果不能验证结帐管道,就无法上线。

在商家测试应用程序中启用了 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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 谢谢伙计,是的,我正在免费的网络 000web 主机服务器上测试这个简单的购物车,所以你的意思是我必须将项目移动到另一个网络服务器而不是 000webhost 才能让它工作.... ..
    • 我想是的,我买了自己的域名和网络服务器,并在那里上传了我的文件
    • 但是之前,我可以在 000webhost 上使用 ipn 模拟器,我想那是 2012 年 10 月,我不知道之后发生了什么
    • 欢迎,如果真的有帮助,您可以投票给我的答案,不胜感激
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    • 2016-10-13
    • 2011-12-28
    相关资源
    最近更新 更多