Page 1 of 1

Registration Notification URL Not Firing... Debug?

PostPosted: August 29th, 2011, 4:08 pm
by tkittredge
I am having a problem getting a simple test notification URL to fire (from any event). The script (without query string parameters, no replacement codes) simply opens a text file and writes a line of text (to confirm success). It works when called from a browser address bar or from within WordPress using javascript:window.open but not when configured in s2Member -> API / Notifications -> Registration Notifications. It also works when called from PayPal IPN Simulator Test Tools.

What is the best method to debug the call? Am I missing some other configuration / hosting requirement for s2M?

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 29th, 2011, 5:41 pm
by Cristián Lávaque
The thing is that the notification URL is being loaded by s2Member in that case, not the user, so the page is being served to your s2Member, which is why you don't see it in the browser.

If you have s2Member Pro http://s2member.com, you can either specify the URL as the one to show the user after payment, or you can customize the s2Member one.

WP Admin -> s2Member -> Paypal Buttons -> Shortcode Attributes -> success
WP Admin -> s2Member -> PayPal Options -> PayPal PDT -> Auto-Return Page Template


I hope that helps. :)

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 30th, 2011, 8:57 am
by tkittredge
Slight miss understanding. Although I'd used window.open to test one scenario, the simple test script (below) has no UI and simply writes to a file to confirm it is getting fired (no presentation in intended)...

<?php /* Usage: http://domain.com/notification_test.php */

$file = "notification_test.txt";
$data = 'success!';
file_put_contents($file, $data);

?>

This creates a 'success!' entry in the file (notification_test.txt) when fired from a browser address bar, from PayPal IPN Test environment, and from within WP using window.open, however NOT from s2Member API / Notifications (I'm testing in sandbox mode.)

Is there a way for me to understand/debug/confirm that the test is firing from s2Member API / Notifications?

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 30th, 2011, 2:40 pm
by tkittredge
Okay. Not quite out of the woods, but beginning to find an answer after digging into s2Member code a bit...

I discovered that the remote() function of the c_ws_plugin__s2member_utils_urls class in the utils-urls.inc.php file in the /wp-content/plugins/s2member/includes/classes/ directory uses wp_remote_request() to fire the notification urls.

So... I plugged wp_remote_post() into my test case and it returned "Couldn’t resolve host ‘my.domain.com’". So I plugged in the IP address into the s2member API / Notifications configuration instead of the domain name and it now fires successfully and runs the script.

Not sure why the domain name is not resolving (it's the same domain as where the notification request is running, complete with http://... (non-relative)) but there appears to be a DNS issue of some type.

It would be nice if the s2Member Notification URL could log a return value when fired for debugging purposes. Perhaps this is the case and I've missed it.

So, other than the domain name not being resolved, problem solved. Any clues to that problem appreciated!

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 30th, 2011, 6:49 pm
by Cristián Lávaque
Glad you managed to make it work like that! :)

I'll email Jason about your other questions. I'm pretty sure the Notifications API doesn't have a logging or debugging routine, that's up to the script that it calls, I guess, but I can understand that there's stuff before the script is even called. I'll wait for Jason's comments.

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 31st, 2011, 12:14 am
by Jason Caldwell
Thanks for the heads up on this thread.
Is there a way for me to understand/debug/confirm that the test is firing from s2Member API / Notifications?

One way to further test API Notifications is to enter an email address for each of the Notifications. That way you'll get an email when each of these Notifications are fired, and if your URL did not get called upon, you'll at least know the event did fire, it's just that your URL failed in one way or another.

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 31st, 2011, 8:37 am
by tkittredge
Yup, agreed that using the email argument and receiving notification that the event had fired is useful. Reporting/examining the information returned in the WP_Error class by wp_remote_request() to determine how...
your URL failed in one way or another
...could also help.

So, the debug solution is archived here for anyone having the same problem to check... call wp_remote_post and check the return. Run from a WP page...

<!-- API Notification Test -->
<?php
$result = wp_remote_post('<put your notification url here>');
echo print_r($result);
?>

In any case, not sure why I'm having a problem resolving the domain name and the IP address works, but that's a matter for another thread!
T

Re: Registration Notification URL Not Firing... Debug?

PostPosted: August 31st, 2011, 12:41 pm
by Jason Caldwell
Thanks for the follow-up. Yep, that's a good idea too. I'll see what we can do about that in a future release. It might be helpful to log those connection details. Regarding the DNS issue, I would contact your hosting company on that one, or consult with your sys admin. It sounds like the server may have a DNS configuration problem ( i.e. it's unable to resolve domains ).