PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Success redirect being ignored in v110815

s2Member Plugin. A Membership plugin for WordPress®.

Success redirect being ignored in v110815

Postby kynatro » August 18th, 2011, 9:18 pm

We recently upgraded to s2member (and s2member Pro) v110815 and unfortunately our success pages are no longer redirecting (this was working in version v110731 and earlier). Purchases are coming through well enough, but it treats the form as though the success value does not exist on the shortcode.

Currently we have our system routing payment IPN calls through the PayPal Central IPN script distributed as part of the PRO Extras package as we are handling multiple sites transactions through a single PayPal account. The IPN calls are coming back properly as far as we can tell. I have pasted in an IPN response from the logs below for our account modification form which upgrades free, level 0 users to paying level 1 users with a monthly subscription cost. This form also grants them a custom capability as well. I have redacted personal information and modified domain, custom capability names and thank you URLs to be generic placeholders for anonymity and security.

Code: Select all
WordPress v3.2.1 :: s2Member v110815 :: s2Member Pro v110815
Memory 8.84 MB :: Real Memory 9.25 MB :: Peak Memory 9.00 MB :: Real Peak Memory 9.25 MB
www.mydomain.com/?s2member_paypal_notify=1&s2member_paypal_proxy=paypal&s2member_paypal_proxy_use=pro-emails,subscr-signup-as-subscr-payment&s2member_paypal_proxy_verification=[REDACTED]&s2member_paypal_proxy_return
_url=https%3A%2F%2Fwww.mydomain.com%2Fthankyou
User-Agent: WordPress/3.2.1; http://www.mydomain.com
array (
  'txn_type' => 'subscr_signup',
  'subscr_id' => '[REDACTED]',
  'custom' => 'www.mydomain.com',
  'txn_id' => '[REDACTED]',
  'period1' => '0 D',
  'period3' => '1 M',
  'mc_amount1' => '0.00',
  'mc_amount3' => '4.95',
  'mc_gross' => '4.95',
  'mc_currency' => 'USD',
  'tax' => '0.00',
  'recurring' => '4.95',
  'payer_email' => '[REDACTED]',
  'first_name' => '[REDACTED]',
  'last_name' => '[REDACTED]',
  'option_name1' => 'Referencing Customer ID',
  'option_selection1' => '[REDACTED]',
  'option_name2' => 'Customer IP Address',
  'option_selection2' => '[REDACTED]',
  'item_name' => '$4.95/month',
  'item_number' => '1:my_custom_capability',
  'proxy_verified' => 'paypal',
  's2member_log' =>
  array (
    0 => 'IPN received on: Thu Aug 18, 2011 10:00:25 pm UTC',
    1 => 's2Member POST vars verified with a Proxy Key',
    2 => 's2Member originating domain ( `$_SERVER["HTTP_HOST"]` ) validated.',
    3 => 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ).',
    4 => 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars.',
    5 => 's2Member Level/Capabilities updated w/ advanced update routines.',
    6 => 'Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.',
    7 => 'Subscr. Return ( `modification=1` ), a Proxy Return URL is ready.',
    8 => 'User exists. Handling `payment` for Subscription via ( `subscr-signup-as-subscr-payment` ).',
    9 => 'Payment Notification URLs have been processed.',
    10 => 'Storing IPN signup vars now. These are associated with a User\'s account record; for future reference.',
  ),
  'subscr_gateway' => 'paypal',
  'eotper' => NULL,
  'ccaps' => 'my_custom_capability',
  'level' => '1',
  'ip' => '[REDACTED]',
  'initial_term' => '0 D',
  'initial' => '4.95',
  'regular' => '4.95',
  'regular_term' => '1 M',
  's2member_paypal_proxy_return_url' => 'https://www.mydomain.com/thankyou',
  's2member_paypal_proxy' => 'paypal',
  's2member_paypal_proxy_use' => 'pro-emails,subscr-signup-as-subscr-payment',
  's2member_paypal_proxy_verification' => '[REDACTED]',
)


Here is the shortcode for the Pro form that returns this IPN response:

Code: Select all
[s2Member-Pro-PayPal-Form modify="1" level="1" ccaps="my_custom_capability" desc="$4.95/month" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="www.mydomain.com" ta="0" tp="0" tt="D" ra="4.95" rp="1" rt="M" rr="1" rrt="" rra="2" accept="paypal,visa,mastercard,amex,discover" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" success="https://www.mydomain.com/thankyou" /]


We have attempted success URL values both absolute and relative to no avail. Please keep in mind that transactions are going through, users are being upgraded and given their custom capability and being associated with the transaction, they are just not being directed to the success URL thank you page.

Any help on this would be greatly appreciated.
User avatar
kynatro
Registered User
Registered User
 
Posts: 5
Joined: August 18, 2010

Re: Success redirect being ignored in v110815

Postby Jason Caldwell » August 20th, 2011, 2:22 pm

Thanks for reporting this important issue.

I've just tested the latest version of s2Member Pro v110815 in this regard, and everything seems to be working properly without the central IPN system, so I suspect the conflict in your case lies somewhere in the way your central IPN handler has been implemented.

The success return URL is passed through a proxy request to your IPN handler, and then returned with all possible Replacement Codes having been filled, by the IPN routine for s2Member. So, when you see this value in the IPN log: s2member_paypal_proxy_return_url, that indicates to me that everything is working fine, up until the point at which the IPN routine returns the value of that variable, which is your success attribute. If the value is not returned properly by s2Member's IPN handler, your Pro Form won't get it back, and thus, will NOT use it.

I would start by updating your central IPN handler to the latest version, attached to this post.
paypal-central-ipn.zip
(1.77 KiB) Downloaded 13 times

Next, I would make sure that your WordPress installation is not somehow preventing s2Member's IPN handler from returning/outputting the URL after it finishes processing. For instance, I've seen some web sites make attempts to integrate output buffering through PHP-based mechanisms like ob_gzhandler, deflate, or zlib.output_compression. If your site utilizes any of these PHP-based mechanisms for output buffering, that could be causing corrupt data in PHP scripts that don't expect that, such as s2Member's IPN handler. My advice in that case, is to use Apace for output buffering instead, with something like this in your .htaccess file.
Code: Select all
# COMPRESSION FOR SPEED
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/plain
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/rdf+xml application/rss+xml application/atom+xml image/svg+xml
AddOutputFilterByType DEFLATE font/truetype application/x-font-ttf font/opentype application/x-font-otf
</IfModule>

If all else fails, please send me a Dashboard login and I'll take a look for you by running diagnostics on s2Member. If you'd like to go this route, please send that information privately though this contact form: http://www.s2member.com/contact/
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Success redirect being ignored in v110815

Postby svillee » August 23rd, 2011, 4:03 pm

I have a WordPress site with s2Member Pro (build 110815) installed, and I am seeing the same problem. I am specifying a success attribute in my s2Member-Pro-PayPal-Form shortcode, and apparently it is being ignored.

I am not using PayPal Central IPN. kynatro, I'm curious...has your issue been resolved?

I have added some debugging/tracing code to plugins/s2member/includes/classes/paypal-notify-in.inc.php. Here is the exit statement at line 191:

Code: Select all
exit (((!empty ($paypal["s2member_paypal_proxy_return_url"])) ? $paypal["s2member_paypal_proxy_return_url"] : ""));


I have determined that $paypal["s2member_paypal_proxy_return_url"] has the right value at this point, i.e., the url I specified on my success attribute. But somehow it is being ignored. Do I understand correctly that this value is being sent back to PayPal as the response to its IPN? Is there some way to trace the response as PayPal sees it?

Thanks in advance for any help.
User avatar
svillee
Registered User
Registered User
 
Posts: 10
Joined: August 1, 2011

Re: Success redirect being ignored in v110815

Postby Jason Caldwell » August 23rd, 2011, 8:24 pm

OK. Thanks for reporting this important issue.
I'll assume at this point there MUST be something to this.
Can I see the s2Member Shortcode that you're using for your Pro Form integration please?
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Success redirect being ignored in v110815

Postby svillee » August 24th, 2011, 9:03 am

Here is the shortcode, with my domain replaced with "www.mydomain.com":

Code: Select all
[s2Member-Pro-PayPal-Form level="1" ccaps="" desc="$9.00 USD / Monthly - 1 Free Credit Every 30 Days" ps="paypal" cc="USD" ns="1" custom="www.mydomain.com" ta="0" tp="0" tt="D" ra="9.00" rp="1" rt="M" rr="1" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" success="http://www.mydomain.com/membership-signup/gha-member-success/" /]


If it would be helpful to add logging statements (similar to error_log) to some php module, let me know. The scenario is solidly reproducible.
User avatar
svillee
Registered User
Registered User
 
Posts: 10
Joined: August 1, 2011

Re: Success redirect being ignored in v110815

Postby plymplan » August 26th, 2011, 9:03 am

Hi Jason, et al,

What is the status of this issue? I am working with svillee on a site and we would like to be able to report *something* back to our client today.

Thanks
User avatar
plymplan
Registered User
Registered User
 
Posts: 1
Joined: August 26, 2011

Re: Success redirect being ignored in v110815

Postby svillee » August 26th, 2011, 2:31 pm

I did some debugging/tracing of my own, and I think I found the problem. In plugins/s2member-pro/includes/classes/gateways/paypal/paypal-checkout-rdp-in.inc.php at line 668, we have this:

Code: Select all
$ipn["s2member_paypal_proxy_return_url"] = c_ws_plugin__s2member_utils_urls::remote (site_url ("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array ("timeout" => 20));


I verified that after this call, $ipn["s2member_paypal_proxy_return_url"] has the correct url (my success attribute), but with three CR/LF pairs (i.e., "\r\n\r\n\r\n") prepended to it. I don't know exactly where these CR/LF pairs are coming from. But then in line 672 we have this:

Code: Select all
if ($post_vars["attr"]["success"] && substr ($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr ($post_vars["attr"]["success"], 0, 2) /* In case the IPN routine returns something weird. */


The substr check is failing, because of the prepended CR/LF pairs. Thus, it ignores the redirect entirely.

For now, I have added a trim() call to line 668, so it now looks like this:

Code: Select all
$ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote (site_url ("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array ("timeout" => 20)));


It's working fine with this change.
User avatar
svillee
Registered User
Registered User
 
Posts: 10
Joined: August 1, 2011

Re: Success redirect being ignored in v110815

Postby Cristián Lávaque » August 27th, 2011, 1:50 am

Thanks for the update and the hack! I hope Jason finds what's adding those newlines.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Success redirect being ignored in v110815

Postby Jason Caldwell » August 27th, 2011, 1:25 pm

Hey, thanks for your hard work in tracking this down.
svillee wrote:I did some debugging/tracing of my own, and I think I found the problem. In plugins/s2member-pro/includes/classes/gateways/paypal/paypal-checkout-rdp-in.inc.php at line 668, we have this:

Code: Select all
$ipn["s2member_paypal_proxy_return_url"] = c_ws_plugin__s2member_utils_urls::remote (site_url ("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array ("timeout" => 20));


I verified that after this call, $ipn["s2member_paypal_proxy_return_url"] has the correct url (my success attribute), but with three CR/LF pairs (i.e., "\r\n\r\n\r\n") prepended to it. I don't know exactly where these CR/LF pairs are coming from. But then in line 672 we have this:

Code: Select all
if ($post_vars["attr"]["success"] && substr ($ipn["s2member_paypal_proxy_return_url"], 0, 2) === substr ($post_vars["attr"]["success"], 0, 2) /* In case the IPN routine returns something weird. */


The substr check is failing, because of the prepended CR/LF pairs. Thus, it ignores the redirect entirely.

For now, I have added a trim() call to line 668, so it now looks like this:

Code: Select all
$ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote (site_url ("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array ("timeout" => 20)));


It's working fine with this change.

Interesting. I wonder where the newlines are coming from? That's not s2Member introducing those, is it possible that you have output buffering enabled via PHP, or something like that?

In the mean time, certainly, trim() won't hurt anything and should fix this problem. We'll add that change to the next release so this problem is avoided. I would like to find the cause of the newlines though. We'll take a look, but if you find anything further, please let me know :-)
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Success redirect being ignored in v110815

Postby svillee » August 28th, 2011, 4:05 pm

We have this in our php.ini file:

output_buffering = 4096
zlib.output_compression = Off

We do not have an "output_handler =" line in php.ini, so we are taking the default.

I believe these are all normal, recommended settings, but if you think they might be causing a problem, let me know.
User avatar
svillee
Registered User
Registered User
 
Posts: 10
Joined: August 1, 2011

Re: Success redirect being ignored in v110815

Postby Jason Caldwell » August 29th, 2011, 7:29 pm

Thank you for the follow-up.

We're working on some improvements for the next release that will hopefully work around this issue, and we're going to implement a trim in these key locations as well, just as a second line of defense in this specific case. It's possible that your output_buffering setting is causing this. You might try setting output_buffering to the default value of 0. See: http://www.php.net/manual/en/outcontrol ... ration.php

Changelog excerpt for next release:
* (s2Member Pro) **Bug fix**. Some site owners running s2Member Pro, on server configurations with PHP-based output compression enabled, were causing problems with the `success=""` Shortcode Attribute for s2Member Pro Forms. s2Member Pro has been improved in this regard *( i.e. s2Member Pro now makes better attempts to clear output buffers before returning plain text data with it's handlers )*. In addition, calls to `trim()` have also been implemented as an additional line of defense against errors reported in the previous release; which were related to URLs with leading white space, returned by s2Member's core PayPal® IPN processor.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron