latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Help with paypal-central-ipn.php and IPN

Home Forums Community Forum Help with paypal-central-ipn.php and IPN

Tagged: ,

This topic contains 13 replies, has 4 voices. Last updated by  Cristián Lávaque 4 years, 6 months ago.

Topic Author Topic
Posted: Wednesday Jun 6th, 2012 at 8:53 pm #15735
Sacha Greif
Username: sachag

I recently changed domains for my site. Since PayPal stores individual IPN URLs indefinitely for the subscriber profiles that have been created before the switch, all the notifications for these users are going to http://old_domain.com/?s2_member_notify=1 (instead of http://new_domain.com/?s2_member_notify=1).

So I’m trying to set up a script to redirect those notifications from the old domain to the new. Everything seems to be working fine, except that the notifications are not firing on the new server…

Instead of sending the cURL request to http://new_domain.com/?s2_member_notify=1 I tried sending it to a custom script that only echoes $_POST variables, and that worked. So apparently the cURL call succeeds, but something breaks down afterwards with the s2member_notify script.

Any idea what could be the problem?

My second question is, where is the script that handles incoming notifications located in the s2member files? I would like to insert some logging calls to make sure the variables are being received properly.

Thanks!

List Of Topic Replies

Viewing 13 replies - 1 through 13 (of 13 total)
Author Replies
Author Replies
Posted: Thursday Jun 7th, 2012 at 10:35 am #15787
Raam Dev
Username: Raam
Staff Member

Sacha,

Have you updated your IPN URL in PayPal with the new URL? To the best of my knowledge, PayPal will begin sending new IPN messages for existing subscriptions to the new IPN URL if you update PayPal with it. I could not find any documentation that stated this was not the case. If you know of some, could you link me to it?

Posted: Thursday Jun 7th, 2012 at 7:48 pm #15858
Sacha Greif
Username: sachag

I did update the global IPN URL, and it wasn’t effective. And I got in touch with PayPal support directly and they told me you couldn’t change individual IPN URL, sorry I don’t have a more specific source.

Posted: Friday Jun 8th, 2012 at 9:34 pm #16011
Sacha Greif
Username: sachag

I’ve confirmed that the cURL call is passing the POST variables from one domain to the other, but nothing happens after this. Any idea why? If not, could you tell me where the code that deals with this is located in the S2Member plugin files?

Also, for some reason PayPal seems to be sending each notification twice… Will that be a problem, or is S2Member smart enough to ignore the second one?

Posted: Friday Jun 8th, 2012 at 10:27 pm #16022
Staff Member

Thanks for the follow-up.

Also, for some reason PayPal seems to be sending each notification twice… Will that be a problem, or is S2Member smart enough to ignore the second one?

Yes, that’s fine. s2Member will ignore duplicates. However, the fact that you’re getting duplicates, usually indicates that PayPal thinks the IPN is not being received properly.

If you’d like, you can use the central-ipn-sample.php file that we’ve prepared. It can certainly work for you in this situation. I’m attaching a copy to this post for you. Upload this file to your old domain, and make sure it accepts requests for the old IPN location (i.e. the one PayPal is still trying to send IPNs to).

At the top of the file, you’ll find the configuration section.
You’ll want to have something like this, as your configuration.

$config = array
	(
		"www.old-domain.com" => "http://www.new-domain.com/?s2member_paypal_notify=1"
	);
You will also need to run a search/replace on the IPN POST data, to replace occurrences of old-domain, with new-domain, BEFORE you actually forward the IPN. The sample script does NOT do this, so that’s something you will need a couple lines of custom code for.

$_p = $_POST;
foreach($_p as &$value)
	{
		if(is_string($value))
			$value = str_ireplace('www.old-domain.com', 'www.new-domain.com', $value);
	}

I’ve confirmed that the cURL call is passing the POST variables from one domain to the other, but nothing happens after this. Any idea why? If not, could you tell me where the code that deals with this is located in the S2Member plugin files?

s2Member already logs all of the incoming IPNs that it receives. You’ll just need to enable logging from your Dashboard. Dashboard -› s2Member® -› PayPal® Options -› Account Details -› Logging After you enable logging, you can check s2Member’s log, and you should find the issue there.

Posted: Friday Jun 8th, 2012 at 10:29 pm #16024
Staff Member

This is also included in the s2m-pro-extras.zip file,
which can be downloaded from your My Account page here at s2Member.com.

Posted: Saturday Jun 9th, 2012 at 2:06 am #16042
Sacha Greif
Username: sachag

I’ve done exactly this. I’m at a point where everything seems to be set up properly, the POST variables are sent from one site to the other, yet the notifications are not firing from new-domain.com?s2member_paypal_notify=1

If there are any common reasons why this might happen I’d love to know, otherwise I would also like to know where this behavior is handled in the S2member plugin files so that I can try and figure out what’s happening by myself.

Posted: Tuesday Jun 12th, 2012 at 8:13 pm #16303
Sacha Greif
Username: sachag

Any help with this? All I’d like to know is where to look for the class or function that deals with incoming notifications in the S2Member plugin files?

Posted: Tuesday Jun 12th, 2012 at 10:26 pm #16317
Sacha Greif
Username: sachag

I had completely forgotten about the IPN logs. I checked them and it turns out there’s an error:

0 => 'Unable to verify $_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.',
1 => 'If you\'re absolutely SURE that your configuration is valid, you may want to run some tests on your server, just to be sure $_POST variables are populated, and that your server is able to connect/communicate with your Payment Gateway over an HTTPS connection.',
2 => 's2Member uses the `WP_Http` class for remote connections; which will try to use `cURL` first, and then fall back on the `FOPEN` method when `cURL` is not available. On a Windows® server, you may have to disable your `cURL` extension; and instead, set `allow_url_fopen = yes` in your php.ini file. The `cURL` extension (usually) does NOT support SSL connections on a Windows® server.',
3 => 'Please see this thread: `http://www.s2member.com/forums/topic/ideal-server-configuration-for-s2member/` for details regarding the ideal server configuration for s2Member.',
4 => 'array (
  \'s2member_paypal_notify\' => \'1\',
  \'payer_id\' => \'EFKFZRFE******\',
  \'option_selection1\' => \'www.nrfight.tv\',
  \'option_selection2\' => \'89.90.******\',
  \'ipn_track_id\' => \'3838092******\',
  \'invoice\' => \'4ed531804a******\',
  \'charset\' => \'windows-1252\',
  \'payment_gross\' => \'\',
  \'verify_sign\' => \'AFcWxV21C7fd0v3bYYYRCpSSRl31AzzQ64U******\',
  \'item_name\' => \'Membre NRFight\',
  \'txn_type\' => \'subscr_payment\',
  \'receiver_id\' => \'CKBECGS******\',
  \'payment_fee\' => \'\',
  \'mc_currency\' => \'EUR\',
  \'transaction_subject\' => \'Membre NRFight\',
  \'custom\' => \'www.nrfight.tv\',
  \'protection_eligibility\' => \'Ineligible\',
  \'payer_status\' => \'verified\',
  \'first_name\' => \'Matthieu\',
  \'subscr_id\' => \'I-A71CCSB******\',
  \'mc_gross\' => \'10.00\',
  \'payment_date\' => \'05:14:34 Jun 06, 2012 PDT\',
  \'payment_status\' => \'Completed\',
  \'business\' => \'info@nrfight.com\',
  \'item_number\' => \'1\',
  \'last_name\' => \'******\',
  \'txn_id\' => \'41Y21071VD8******\',
  \'mc_fee\' => \'0.43\',
  \'resend\' => \'true\',
  \'payment_type\' => \'instant\',
  \'notify_version\' => \'3.4\',
  \'option_name1\' => \'Originating Domain\',
  \'option_name2\' => \'Customer IP Address\',
  \'payer_email\' => \'matt******@******.com\',
  \'receiver_email\' => \'******@nrfight.com\',
  \'residence_country\' => \'FR\',
)',
  ),

Just to be clear, IPN are working fine from PayPal to NRFight.tv (the new domain). It’s only when PayPal sends the IPN to NRFight.com (the old domain), and NRFight.com forwards it to NRFight.tv that this problem occurs.

  • This reply was modified 4 years, 6 months ago by  Sacha Greif.
  • This reply was modified 4 years, 6 months ago by  Sacha Greif.
  • This reply was modified 4 years, 6 months ago by  Sacha Greif.
  • This reply was modified 4 years, 6 months ago by  Sacha Greif.
Posted: Tuesday Jun 12th, 2012 at 10:54 pm #16326
Staff Member

Thanks for the follow-up.

Yes, I’m so sorry. I left out one key component that MUST be implemented before this is going to work.

When s2Member finally receives the forwarded IPN data, it is posted back to PayPal for verification. However, since you’re changing the data in the IPN response itself, which is required in your case (i.e. the old-domain is changing to that of your new-domain); PayPal is not going to verify it, because the data is different now.

The solution to this, is to force verification. This can be accomplished with the use of an s2Member Proxy Key, which is sent to the IPN handler. All you really need to do, is change this line in the configuration section of the central IPN handler. I’ve written instructions below.

Instead of just this:

$config = array
	(
		"www.old-domain.com" => "http://www.new-domain.com/?s2member_paypal_notify=1"
	);

You will need this (including the proxy verification):

$config = array
	(
		"www.old-domain.com" => "http://www.new-domain.com/?s2member_paypal_notify=1&s2member_paypal_proxy=[proxy-gateway]&s2member_paypal_proxy_verification=xxxxxxxxxxxxxxxxxxxxx"
	);

Before you can make this change, you will need to log into your s2Member installation, and check this section of your Dashboard. Here you will find the full Proxy IPN URL (which includes a Proxy Key for your installation).

See: Dashboard -› s2Member® -› PayPal® Options -› PayPal® IPN Integration -> IPN w/ Proxy Key

Posted: Tuesday Jun 12th, 2012 at 11:20 pm #16328
Sacha Greif
Username: sachag

It worked!

Well, I got rid of the errors in the IPN logs at least. I haven’t received the email notification, but that might be because I’m using old transaction data to test my setup and S2Member (or PayPal) doesn’t want to fire the same IPN twice. I’m a little burned out from working on this right now, so I’ll just assumes it really does work for now :)

Anyway, I’ll keep my fingers crossed that the notification does fire next time a real IPN comes through. I’ll keep you posted. Thanks a lot for your help!

Posted: Wednesday Jun 13th, 2012 at 5:00 am #16349

Great! Thanks for the update. Let us know how it goes. :)

Posted: Saturday Jun 16th, 2012 at 10:22 pm #16698
Sacha Greif
Username: sachag

Hopefully this will be the last update on this. Things were still not working because the “custom” POST variable was not being properly replaced by the new domain.

This is the code I was using:

foreach($data as $key => $value){
  if(is_string($value)){
    $value = str_ireplace('www.oldomain.com', 'www.newdomain.com', $value);
  }
}

For some unknown reason, this was not working. So I decided to simply replace it by:

$data["custom"]="www.newdomain.com";

And now everything seems to work at last!

Posted: Tuesday Jun 19th, 2012 at 3:00 am #16829

Great! :D

Viewing 13 replies - 1 through 13 (of 13 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.