2012-12-22 83 views
1

当我使用IPN让我们说3个网站时,我不是100%清楚,如果有知识的人可以根据我的场景向我解释这一点,我将不胜感激。贝宝多IPN设置

我已经设置我的sanbox测试企业帐户使用IPN侦听器:site1.com/listener.php(工作得很好)。

我想知道如何为我的其他网站设置更多监听器,使用相同的PayPal帐户。

在我的方案中,我与只针对所有网站订购付款

问题1:ipn_notification_url变量。 这个变量,如果设置,告诉贝宝付款时,总是使用这个作为侦听器IPN网址?例;如果订阅失败或类似的东西,当下一个单纯的付款?

因此,当贝宝有需要IPN我的听众,它将使用从变量的监听器,而不是在帐户配置文件设置设置的网址?或者这个变量是否只能用于实际支付时处理?

问题2: 是否有可能分开不同的网站,如果需要有一个主监听器,用于处理转发到正确的监听器网址是什么?例如:定制=用户id,receiver_id =网站

问题2实际上类似的问题1.请问POSTED变量从最初的支付,坚持支付即会全自动的未来我的订阅。所以,当贝宝需要向我发送IPN更新时,它将始终使用我在首次付款时设置的变量的URL?

感谢您对此的任何启发。

回答

2

我发现这个脚本http://codeseekah.com/这将使您能够设置多个PayPal IPN监听器。它可以让你过滤的通知,这意味着你可以发送到根据您设定的条件不同的听众(非常有用!):

<?php 

    ini_set('max_execution_time', 0); // Do not abort with timeouts 
    ini_set('display_errors', 'Off'); // Do not display any errors to anyone 
    $urls = array(); // The broadcast session queue 

    // List of IPN listener points ** ADJUST THESE TO POINT TO YOUR LISTENERS 
    $ipns = array(
      'first' => 'http://www.yourwebsite1.co.uk//paypal/ipn.php', 
      'second' => 'http://www.yourwebsite2.co.uk//paypal/ipn.php', 
      'third' => 'http://www.yourwebsite3.co.uk//paypal/ipn.php' 
     ); 

    // ** ADJUST THESE CONDITIONS TO FILTER 
    if($_POST['txn_type']!='cart') $urls []= $ipns['first']; // Choose this IPN URL if all conditions have been met 
    if(isset($_POST['auction_buyer_id'])) $urls []= $ipns['second']; // Choose this IPN URL if all conditions have been met 
    $urls []= $ipns['third']; // maybe this one is always sent to 

    // Broadcast 
    if (!sizeof($urls)) $urls = $ipns; // No URLs have been matched 
    $urls = array_unique($urls); // Unique, just in case 

    // Broadcast (excluding IPNs from the list according to filter is possible 
    foreach ($urls as $url) broadcast($url); 

    header('HTTP/1.1 200 OK', true, 200); 
    exit(); 

    // Perform a simple cURL-powered proxy request to broadcast 
    function broadcast($url) { 

     // Format POST data accordingly 
     $data = array(); 
     foreach ($_POST as $key => $value) $data []= urlencode($key).'='.urlencode($value); 
     $data = implode('&', $data); 

     // Log the broadcast 
     file_put_contents('_logs/'.time().'.'.reverse_lookup($url).'-'.rand(1,100), $data); 

     $ch = curl_init(); // Initialize 

     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_POST, count($data)); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

     curl_exec($ch); // Execute HTTP request 
     curl_close($ch); // Close 
    } 

    function reverse_lookup($url) { 
     global $ipns; 
     foreach ($ipns as $tag => $_url) { 
      if ($url == $_url) return $tag; 
     } 
     return 'unknown'; 
    } 
?> 

只是定制你需要(与** S),保存部分它在一个文件中,例如名为“multiple-paypal-ipn.php”,然后放在你的一台服务器上。然后在您的PayPal IPN网址设置(在PayPal中)中输入您刚刚放置的完整网址,例如http://www.yourwebsite/paypal/multiple-paypal-ipn.php

这节省了我很大的时间,所以希望能为他人!_g

3

有三个网址,您可以通过在表单隐藏输入元素提供,这些名字:

  1. notify_url:这是这对此次收购所有通知将要发送的URL。
  2. return:这是用户在成功完成结帐时将返回到的URL。
  3. cancel_return:这是用户在贝宝取消结账时返回的URL。

所以,如果您在使用按钮notify_url,也可以是每个网站不同,每个按钮,甚至每个按钮呈现,如果你有这样的事情使用。

请注意,notify_url会覆盖您在付款偏好设置中设置的任何值。

0::用户经由GET 1返回:用户经由GET返回没有付款变量

关于(2),还可以按如下提供rm变量。 2。用户通过PUT返回返回的所有支付变量,即作为按钮发送给PayPal的回声。

我不清楚0和1

的区别见PayPal HTML Variables

编辑在我现在找不到的另一个答案中,PayPal的一个人说你可以在notify_url本身传递任意参数,这个参数会以你发送它们的相同方式返回。