Community Support Forums — WordPress® ( Users Helping Users ) — 2011-04-15T15:55:59-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=3142 2011-04-15T15:55:59-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3142&p=11804#p11804 <![CDATA[Re: IPN Issue]]>
scott_van wrote:
Code:
/* Where the magic happens... */
if (preg_match ("/^example\.com\\subdirectory/i", $_POST["custom"]) || preg_match ("/~example\.com\\subdirectory~/i", $_POST["txn_type"]))
    curlpsr ("http://example.org/subdirectory/ipn.php", http_build_query ($_POST));
/**/
else if (preg_match ("/^example\.com/i", $_POST["custom"]) || preg_match ("/~example\.com~/i", $_POST["rp_invoice_id"]))
    curlpsr ("http://example.org/?s2member_paypal_notify=1", http_build_query ($_POST)); 


In the second phase of this code sample, you're checking for example.com, but then you're calling upon example.org. Other than that, this looks good. Before you go live with this, you might want to have a look below at the updated version of our central IPN example file. Which is as follows:
Code:
<?php
/*
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
*/
@ignore_user_abort(true);
/*
---- Central IPN Processing: ---------------------------------------------------------------------------------

With PayPal® Pro integration you absolutely MUST set an IPN URL inside your PayPal® account.
PayPal® Pro integration does NOT allow the IPN location to be overridden on a per-transaction basis.

So ... if you're using a single PayPal® Pro account for multiple cross-domain installations,
and you need to receive IPN notifications for each of your domains; you'll want to create
a central IPN processing script that scans variables in each IPN response,
forking itself out to each of your individual domains.

In rare cases when this is necessary, you'll find two variables in all IPN responses for s2Member.
The originating domain name will always be included somewhere within, either:
`custom` and/or `rp_invoice_id`; depending on the type of transaction.

These variables can be used to test incoming IPNs, and fork to the proper installation.

---- Instructions: -------------------------------------------------------------------------------------------

1. Set the IPN URL ( in your PayPal® account ) to the location of this script on your server.
    This central processor forks IPNs out to a particular installation of s2Member ( on a particular domain ).

2. Now, here's where the magic happens ( PLEASE CHANGE: www.site1.com, www.site2.com. ).
*/
if (stripos ($_POST["custom"], "www.site1.com") !== false || stripos ($_POST["rp_invoice_id"], "www.site1.com") !== false)
    curlpsr ("http://www.site1.com/?s2member_paypal_notify=1", http_build_query ($_POST));
/**/
elseif (stripos ($_POST["custom"], "www.site2.com") !== false || stripos ($_POST["rp_invoice_id"], "www.site2.com") !== false)
    curlpsr ("http://www.site2.com/?s2member_paypal_notify=1", http_build_query ($_POST));
/*
This is just a utility function ( you must have the cURL extension for PHP enabled ).
*/
function curlpsr ($url = FALSE, $postvars = array (), $max_con_secs = 20, $max_stream_secs = 20, $headers = array ())
    {
        if (($url = trim ($url)) && ($c = curl_init ()))
            {
                if (is_array ($postvars)) /* Because cURL can't deal with complex arrays. */
                    /* Since cURL can't deal with complex arrays, we force this to a query string. */
                    $postvars = http_build_query ($postvars);
                /**/
                curl_setopt_array ($c, /* Configure options. */
                array (CURLOPT_URL => $url, CURLOPT_POST => true,/**/
                CURLOPT_FOLLOWLOCATION => false, CURLOPT_MAXREDIRS => 0,/**/
                CURLOPT_CONNECTTIMEOUT => $max_con_secs, CURLOPT_TIMEOUT => $max_stream_secs, /* Initial connection & stream seconds. */
                CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => $postvars,/**/
                CURLOPT_ENCODING => "", CURLOPT_VERBOSE => false, CURLOPT_FAILONERROR => true, CURLOPT_FORBID_REUSE => true, CURLOPT_SSL_VERIFYPEER => false));
                /**/
                $o = trim (curl_exec ($c));
                /**/
                curl_close($c);
            }
        /**/
        return (!empty ($o)) ? $o : false;
    }
?>

Statistics: Posted by Jason Caldwell — April 15th, 2011, 3:55 pm


]]>
2011-04-12T22:30:51-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3142&p=9641#p9641 <![CDATA[Re: IPN Issue]]>
Thank you for your response. I saw Jason's post earlier and the paypal-central-ipn.php file in the Extras download is identical to the central-ipn-sample.php from which I modified the code snippet in my post above - just renamed.

On a wordpress website that does not have s2member installed the other tool works fine with the IPN setup correctly in a (different) PayPal account however when I run it in the s2member site I get an INVALID response from PayPal. I don't know enough about IPN but I suspect PayPal is receiving a response from from s2member instead of the other tool and this breaks the handshake.

I guess my question is will the code snippet above break s2member as I have it? I can't afford to break s2member.

Cheers,
Scott

Statistics: Posted by scott_van — April 12th, 2011, 10:30 pm


]]>
2011-04-12T19:43:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3142&p=9614#p9614 <![CDATA[Re: IPN Issue]]>
Maybe this will help you with your problem viewtopic.php?f=36&t=2905

I hope it does. :)

Statistics: Posted by Cristián Lávaque — April 12th, 2011, 7:43 pm


]]>
2011-04-12T17:13:58-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3142&p=9588#p9588 <![CDATA[Re: IPN Issue]]>
Okay, I came across the central-ipn-sample.php example file in another post in this forum. This might be what I am after but I'm not certain if my remedial PHP modifications shown below are correct or if it will work at all.

Lets say my Wordpress/s2member installation is at example.com and my other tool's IPN file is at example.com/subdirectory/ipn.php

I saw that rp_invoice_id, needed by s2member, is not used in the other tool's PayPal IPN handshake so I used txn_type instead. Don't know if this is correct.

Now, the idea is to set the IPN url in PayPal to point to
example.com/subdirectory/central-ipn-sample.php
and have the script decide which IPN file to use - s2members or the other tool's.

As mentioned this site is in production with s2member and I don't want to mess up the s2member transactions by experimenting. Does this make sense as a solution? I don't know enough about the PayPal IPN handshake to know if this will work. No doubt there are other users of s2members who could use a solution like this if it works.

Code:
/* Where the magic happens... */
if (preg_match ("/^example\.com\\subdirectory/i", $_POST["custom"]) || preg_match ("/~example\.com\\subdirectory~/i", $_POST["txn_type"]))
    curlpsr ("http://example.org/subdirectory/ipn.php", http_build_query ($_POST));
/**/
else if (preg_match ("/^example\.com/i", $_POST["custom"]) || preg_match ("/~example\.com~/i", $_POST["rp_invoice_id"]))
    curlpsr ("http://example.org/?s2member_paypal_notify=1", http_build_query ($_POST)); 


Any advice/help would be greatly appreciated.
Cheers,
Scott

Statistics: Posted by scott_van — April 12th, 2011, 5:13 pm


]]>
2011-04-12T13:51:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3142&p=9581#p9581 <![CDATA[IPN Issue]]>
I've been using s2member very successfully on a non-profit website. No problems so far with this awesome plugin and I'd recommend it to anyone.

The PayPal IPN is correctly setup with the s2member url. However, I've installed a non-wordpress 3rd party tool (formtools.org) in a sub-directory of the domain and it requires a PayPal IPN setup for it. One PayPal account but two IPN urls needed! Essentially I need a way to keep the s2member IPN address in the PayPal account (don't want to mess with that! - ain't broke don't fix) but sill have some kind of router to the other IPN url.

I noticed in the s2members PayPal Options > PayPal IPN Integration panel an "IPN w/ Proxy Key" option. I'm wondering it this is the way to go. I don't quite understand how the Proxy Key would work in this case. Do I just replace [proxy-gateway] in the url with the 3rd party IPN url? Since the s2member site is in production I'm hesitant to experiment with it.

If the "IPN w/ Proxy Key" option is not the way to go what would you recommend?

Best regards,
Scott

Statistics: Posted by scott_van — April 12th, 2011, 1:51 pm


]]>