贝宝多个IPN设置 [英] Paypal multiple IPN setup

查看:113
本文介绍了贝宝多个IPN设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用3个网站使用IPN时,我不是100%清楚,如果有知识的人可以根据我的情况向我解释这一点,

I am not 100% clear about this when using IPN for let's say 3 websites, and if someone with the knowledge could explain this to me according to my scenario, I will appreciate it.

我已经设置了我的sanbox测试企业帐户以使用IPN侦听器:site1.com/listener.php(工作正常).

I have setup my sanbox test business account to use the IPN listener : site1.com/listener.php (Working just fine).

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

I am wondering about how to setup more listeners for my other sites, using the same paypal account.

在我的情况下,我正在为所有网站使用仅订阅付款.

In my scenario, I am working with only subscription payments for all sites.

问题1: ipn_notification_url 变量. 如果设置了此变量,是否会告诉Paypal付款的时间,以便始终将其用作侦听器ipn url?例子;如果订阅失败或在进行下一次每月分期付款时出现类似情况?

Question 1: The ipn_notification_url variable. Will this variable, if set, tell paypal when the payment is made, to always use this as the listener ipn url? Example; if the subscription fail or something like that when next montly payment is made?

因此,当贝宝需要IPN我的监听器时,它将使用变量中的监听器,而不是帐户配置文件设置中的设置url?还是仅在处理蜜蜂时将此变量用于实际付款?

So when paypal have the need to IPN my listener, it will use the listener from the variable and not the set url in account profile settings? Or will this variable ONLY be used for the actual payment when beeing processed?

问题2: 如果需要拥有一个主侦听器,则可以将网站分开来处理转发到正确侦听器URL的网站吗?例如:custom = userId,receiver_id =站点名称

Question 2: Is it possible to distinct the websites apart, if need to have a master listener, that handles the forwarding to the correct listener url? Example: custom = userId , receiver_id = Sitename

问题2实际上类似于问题1.请问 POSTED变量从初始付款 STICK到将来为我的订阅自动进行的付款 .这样,当贝宝需要向我发送IPN更新时,它将始终使用初始付款时我的变量集中提供的网址?

Question 2 is actually similar to the question 1. Will the POSTED variables from the initial payment, STICK to the payments that are going automaticly in the future for my subscriptions. So that when paypal need to send me IPN updates, it will always use the url from my variable set on initial payment??

谢谢您的启发.

推荐答案

我从 http://codeseekah.com/找到了此脚本,它将使您可以设置多个PayPal IPN侦听器.它使您可以过滤通知,这意味着您可以根据您设置的条件将其发送到不同的侦听器(非常有用!):

I found this script from http://codeseekah.com/ which will enable you to set-up multiple PayPal IPN listeners. It allows you to filter the notifications which means that you can send to different listeners depending on conditions that you set (so useful!):

<?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';
    }
?>

只需自定义您需要的部分(带有**),将其保存在文件中,例如"multiple-paypal-ipn.php",然后将其放在您的一台服务器上即可.然后在您的PayPal IPN URL设置中(在PayPal中)放入您刚刚放置的完整URL,例如 http://www.yourwebsite/paypal/multiple-paypal-ipn.php

Just customise the parts you need to (with **s), save it in a file, for example called "multiple-paypal-ipn.php", then put it on one of your servers. Then in your PayPal IPN URL setting (in PayPal) put in the full URL where you have just placed it, e.g. http://www.yourwebsite/paypal/multiple-paypal-ipn.php

这节省了我很多时间,希望对其他人有帮助!_g

This saved me BIG time so hopefully will for others!_g

这篇关于贝宝多个IPN设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆