(s2Member / API Notification Email) - Payment - wrong user data

In about 50% of all paypal payments via button - the payer information is correct - but the user information is take from some random user (however for several years the same user).

I don’t know what causes this - but it’s been broken since I can remember. If this email is sent - it should not include user information at all if the user is not yet registered.

maybe include a longer delay - like 10 minutes - that way 95% of users should be captured correctly.

Why is this email for me handy? Well it’s the only way to easily keep track of payer_email vs user_email.
Alternatively it would be nice if for the new user administrative notification email - it would be possible to include the payer data additionally to the user data.

1 Like

Hi Felix.

In about 50% of all paypal payments via button - the payer information is correct - but the user information is take from some random user (however for several years the same user).

That sounds quite odd. I wonder what is causing it…

Could you tell me the steps needed to reproduce the behavior on my side so I can troubleshoot it?

Thanks! :slight_smile:

well that’s really hard - because it can only be reproduced by actual payment via paypal buttons. So I really don’t know how I can tell you to reproduce it.

What I could do is send you all the logfiles and tell you which user (email address/name) this last happened and you could check in the logfiles for a reason - because i don’t know where to search.

It always happens if the user takes a long time to register - so payment via paypal button - but then actually registering 23 hours later. Because the payment notification email is sent pretty soon - never 23 hours later. However sometimes this even happens if user registers very quickly. Maybe check what triggers sending of this email… And make sure that if no registration tool place without 24 hours - this email is sent without the user registration information but only payer registration fields (and maybe a second email later if user registers say 1 week later).

Sure. Please send me message with a link to download the logs, please, I’ll inspect them for the user/email you tell me.

What notification are you having the problem with? Registration, signup, payment?

Only [(s2Member / API Notification Email) - Payment]
email. The other emails are sent correctly. Sorry - but it will be hard to send all logs - which ones do you need - are relevant here?

I think the error should be quite clear - As the payment notification can include user login data - but is sent sometimes before the user is actually registered - it cannot work.

I’ve sent you one example including the logfiles. Hope there is everything you need. Else I can look for others. I think this happens for all users who do not follow the registration link provided after checkout by paypal - but wait at least like 1-2 minutes and then use the link from the email to register instead. If users instantly register the email is fine.

Maybe it would be a good idea to add all the payment data also to the user registration api email. Why are those emails helpful? Well if a user registers with another name or email or both different from the one he used to pay. I often need to find the relevant payments for a user - and often they use different emails for payment as for user registration (sometimes this is related to the problem that the user pays without signing in to an old account which is another thing s2member could improve on)

1 Like

Thanks. The log entry you sent was enough to get some insight.

I looked at the code that generates the notification, and see that s2 gets the user looking it up with the subscr ID or the user ID referenced if the user was logged in when the button was generated.

($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'], $paypal['option_selection1']))

For s2 to be getting the old user there, it has to be given that old user’s ID or subscription’s ID… I’m suspecting it’s either hardcoded, or there’s some funky cache issue going on…

Are you using the button shortcode or the HTML version? Can I see them?

Do you have buttons in different places? Are they the same or maybe one is different to the others? Have you noticed if the problem happens with one of them in particular?

:slight_smile:

Great - I found out this problem only happens when I use a one time button with fixed time. It does not happen for users paying 20€ first year - then 13€ each following year. So maybe this can help you narrow it down a bit more.

I’m using a custom button - because I need a dropdown for several options plus I need the country of residence also confirmed by the user. However I can trace back this issue to 2011 - or the start of me using s2member - the user that will be entered has changed over the years - but usually stays consistent for minimum several months. I’m only using the custom button since 2015. So it really cannot be caused by page caching as then I would need to see much more frequent changes of the wrongly put user for that email.

The button(s) can be found here: https://openmtbmap.org/support/membership/

Before 2015 I used these 2 buttons - and the problem only appeared on the first multi button - the second button is fine:

<form action="/" method="get"> <select name="paypal-order">
<option selected="selected" value="">please choose the duration</option>
<option value="2">€20 gives you 1 year access</option>
<option value="3">€35 gives you 2 year access</option>
<option value="4">€45 gives you 3 year access</option>
<option value="5">€55 gives you 4 year access</option>
<option value="7">€80 gives you 8 year access</option>
<option value="10">€100 gives you lifelong access (as long as I run openmtbmap)</option>
</select><input style="width: auto; height: auto; border: 0;" alt="PayPal®" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" type="image" /></form>

AND
Second button working correctly.

<p>Standard: First year support for €20, then € 13 for each year. You can cancel the payment whenever you like. (needs a credit card linked to your Paypal Account. - use the button under "donate a variable amount" if you have no credit card linked to your paypal account) [s2Member-PayPal-Button level="1" ccaps="" desc="1 Year Openmtbmap.org Membership" ps="openmtbmap.org" cc="EUR" ns="2" custom="openmtbmap.org" ta="20.00" tp="1" tt="Y" ra="13.00" <span class="s2-hilite s2-mono">rra=”3"</span> rp="1" rt="Y" rr="1" image="default" output="button" /]</p>
<p>&nbsp;</p>

Thanks.

I see. So the button that works fine is generated with the shortcode, but the one giving trouble is the custom one.

I see that you have the options to select, but where is the rest of the values for the transaction? Could you show me the part where you defined the amount, term, and other details?

sorry - working:
[s2Member-PayPal-Button level=“1” ccaps="" desc=“1 Year Openmtbmap.org Membership” ps=“openmtbmap.org” cc=“EUR” ns=“2” custom=“openmtbmap.org” ta=“20.00” tp=“1” tt=“Y” ra=“13.00” rra=”3" rp=“1” rt=“Y” rr=“1” image=“default” output=“button” /]

Oh - sorry - forgot I was using a mu-plugin for them. Cannot remember where I got it from.
The plugin is attached. sst_openmtbmap3.php (added .txt for scanners)sst_openmtbmap3.php.txt.zip (1.1 KB)

Right now I use a different plugin which is more advanced - but based on the old plugin so I guess the bug got carried forward. If you find resources to add a country selector based on geoip plugin (maxmind database) this maybe useful for you:

Plugin (not mu-plugin but real plugin)
mc_openmtbmap.php

quite a lot of the code in that plugin is not used anymore however as I migrated most of the functions to Quaderno.io away from vatapi.com and manual tax rates.

The strange thing is - that even though the new/current plugin (mc_openmtbmap) uses the same array for both 1 year membership with subscription and one time payments - the email is only broken for 1 time payments.

I think I based my mu-plugin on the following topic - but not sure:
https://www.s2member.com/forums/topic/add-multiple-posts-to-a-cart-then-checkout/index.html

Well I can fully understand if you drop this subject here - this is based on my own mess and not related to s2member itself (as there is no dropdown for multiple buttons).

Thanks for showing those to me. I reviewed both, but couldn’t find where this behavior is introduced… Isn’t the second one missing something? I didn’t find the button or the shortcode there.

What you could do is modify your payment notification so it adds the other variables available at that point, to help find what may be causing that particular user to come up.

See s2member/src/includes/classes/paypal-notify-in-subscr-or-wa-w-level.inc.php starting around line 665.

:slight_smile:

I see you deleted the plugin (did you do it because of the copyright mentioned? I have the full copyright for the plugin, I paid Martin Sternsberger to write it for me in december 2014 to 2015. If there is code you would like to use for main s2member it’s fine. Just tell me.) - well it is called by inserting [openmtbmap-auswahl] shortcode.
Strangely as written in the other topic I noticed that even Stripe payments ended up with the broken payments api notification email (actually pretty consistently while for paypal it’s much less often that this bug happens). And exactly those stripe subscriptions will then not demote. I really think this bug is related.

1 Like

what variables should I add? If you provide me with a modified file I can use it for testing.

I will send you privately the logs for the last time it happened to a Stripe payment (it’s easier than editing out all confidential user information)…

did you do it because of the copyright mentioned?

I did it because it had some credentials.

what variables should I add?

You could add all the available ones… Or start with the ones used to find the user:

$paypal['subscr_id']
$paypal['option_selection1'].

You can probably use the filter hook ws_plugin__s2member_payment_notification_email_msg in a must-use plugin, to add the variables you want at the end of the $msg.

See also: https://s2member.com/kb-article/hacking-s2member-plugin-w-hooksfilters-for-wordpress/

:slight_smile:

btw - this is my stripe form - could it be that there is a bug in how shortcodes are wrapped=:

[s2Member-Pro-Stripe-Form]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“20Euro_One_Time_Payment_for_1_year_Openmtbmap_access_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“20” rp=“1” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“35Euro_One_Time_Payment_for_2_years_Openmtbmap_access_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“35” rp=“2” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“45Euro_One_Time_Payment_for_3_years_Openmtbmap_access_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“45” rp=“3” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“55Euro_One_Time_Payment_for_4_years_Openmtbmap_access_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“55” rp=“4” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“80Euro_One_Time_Payment_for_8_years_Openmtbmap_access_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“80” rp=“8” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“100Euro_One_Time_Payment_for_25_years_Openmtbmap_access(Lifetime)_no_subscription” cc=“EUR” custom=“openmtbmap.org” ta=“0” tp=“0” tt=“D” ra=“100” rp=“25” rt=“Y” rr=“BN” coupon="" accept_coupons=“0” default_country_code=“DE” captcha=“0” /]
[s2Member-Pro-Stripe-Form update=“1” desc=“Update_your_billing_information.” default_country_code=“DE” captcha=“0” /]
[/s2Member-Pro-Stripe-Form]

I don’t see something wrong with them…

If you look up the user with the subscr IDs from one of the notifications with the wrong user, do you get that same wrong user or the correct one? E.g.

$user_id = c_ws_plugin__s2member_utils_users::get_user_id_with('8HH81677PT080232R');

Oh and sorry - I don’t understand the code around line 665 well enough - If you send me modifified file I can use it - but I’m afraid to break something if changing that file. Also both paypal and stripe are affected…

Cannot tell about the new beta version - only had 2 new users sign up so far and both times no problems (but it’s not every time there is a problem. Only if 20-30 new users sign up without problems I would consider this solved).