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

You can do it with the filter then.

Only if 20-30 new users sign up without problems I would consider this solved

I understand.

I get the correct user - basically the email is fully correct up to the line
coupon_affiliate_id:

then all is wrong with the same wrong user over and over for months to 1-2 years

then the cv0, cv1, cv2,… section is correct again with the new users data.

Okay. just wanted to test that, worth a try.

then all is wrong with the same wrong user

That user data is gotten with the user ID, which is gotten with the line I mentioned before. That’s why I mentioned a couple of times looking into that.

The other variable used to look up the user there is $paypal['option_selection1']. Would be good to use that filter hook to get its value and see if you have the wrong user ID there for some reason.

That is why I wanted to look at your custom code, to see if I spotted that variable, which is in the HTML version of the button in the generator, but no, didn’t find it. Actually, I didn’t find the button or its shortcode in the custom plugin you showed me earlier.

I’m also at a loss what to write exactly in the mu-plugin. So I would need you to write me a mu-plugin so I can upload it.

If you use my mc_openmtbmap.php plugin - you have to put:
[openmtbmap-auswahl]
into the page.

And I forgot - needs a template in the current theme on top.
I’ve attached the template here now.
template_openmtbmap_paybutton.zip (1.1 KB)

I just started trying to debug this - however I’ve run into a problem. With testing mode for Stripe - I only get s2member / API Notification Email - signup AND - registration.
I do not get the - Payment API Notification email… So I’m lost on how I can continue trying to debug this without live payments.

Actually I noticed another bug on all of the Stripe payments. After the initialy s2member api payment notification email - there are no further notification emails being sent.

For those Stripe payments that demote correctly (users that are logged in and prolonging their account by setting up a new stripe subscription) - there is an api notification email sent for each new payment.

So the problem finding out why Stripe users are not demoted correctly and the email being sent with wrong user data is clearly the same cause (for paypal however on subscriptions the email was always sent correctly - and user demoted correctly. Paypal I only have one time payments affected (and as EOT is entered correctly - besides the wrong user data in the email everything is fine, paypal subscriptions have correct api notification email or empty user I think (in case user does not register soon).

1 Like

I think I may have found the problem - Autoptimize - I’m attaching my full settings below. However one thing is very strange - it does not seem to happen for paypal subscriptions - they will work fine. But problem is there sometimes for paypal 1 time payments. And problems are there for all stripe payments to not logged in users, but nor for logged in users (even though autoptimize is active for all page views):

1 Like

Yes, the behavior is strange… Why did you suspect Autoptimize? I’m curious.

I’d probably exclude s2member-o in AO’s JS options too. s2’s JS includes user data sometimes. Maybe it’s related?

So the problem finding out why Stripe users are not demoted correctly and the email being sent with wrong user data is clearly the same cause

Okay. So it appears to be something between the custom button options, and a performance optimization?

Because the API email works correctly with autoptimize disabled - noticed this in my secondary site running optmizemember which is incompatible with autoptimize (forms don’t show up correctly). However the demotion I don’t know.

I Will wait a bit and see if the new version solves something or not first however.

But autoptimize doesn’t affect IPN notices, so maybe something in this case is set up wrongly at Stripe or in the website itself, otherwise users would be demoted correctly.

1 Like

I look forward to your update on that. :slight_smile:

Finally got a payment for a new user in via credit card - with Autoptimize enabled - still the same problem. Now I deactivated autoptimize - I’m very sure the email will be fine then (and corresponding of course also demotions). With autoptimize I believe something must go wrong - though I have no clue what as everything looks fine except demotions not happening and API payment email broken.
(and this happens without custom buttons - just simple s2member shortcode as posted 6 days ago above in this thread).

1 Like

Thanks for the update. I look forward to the next one after that change. :slight_smile:

Bummer - also with autoptimize disabled - and wp fastest cache disabled for the checkout page - the problem persists with Stripe payments (on newest beta)

command back - I seem to have some serious problems on my page as soon as I disable autoptimize (even leaving it enabled but unchecking all boxes breaks shortcodes ultimate in combination with s2member - have to debug this and then wait for another payment to be sure autoptimize is really not the cause).

1 Like

Nope - it’s still broken. And I can see s2member is loaded correctly without being minimised by autoptimize (excluded it there):

If I look at the network requests with Chrome Inspect it looks like everything s2member/stripe related is loaded without caches:
page here:

Maybe stripe.js needs to be excluded from Autoptimize? I’m trying around a bit more. I can for sure say that excluding s2member plugin from Autoptimize does not have any effect. That would be more logical too - as it seems to somehow hand over the data wrongly to Stripe. I’m gonna look if I can find some differences there.

Well - it is really not related to any caching. I’m completely lost why this happens. Funny thing is - on two identical setups - except on one domain is with www. vs one without - it is working correctly on the first, but incorrectly on the second for paypal payments.

On the second somehow according to the logs the user exists already - however it doesn’t and also s2member sends out all other registration emails correctly - but according to the gateway core ipn log it doesn’t.

Incorrect - note step 7 user exists. But it cannot exist at the time of payment. This is the first payment via paypal button for a new user:

LOG ENTRY: Fri Oct 18th, 2019 @ precisely 9:20 am UTC
PHP v7.3.10-1+ubuntu18.04.1+deb.sury.org+1 :: WordPress v5.2.4 :: s2Member v191015.1-beta :: s2Member Pro v191015.1-beta
Memory 13.00 MB :: Real Memory 2.00 MB :: Peak Memory 13.10 MB :: Real Peak Memory 2.00 MB
openmtbmap.org/?s2member_paypal_notify=1
User-Agent: PayPal IPN ( https://www.paypal.com/ipn )
Array
(
[mc_gross] => 20.00
[invoice] => 5da983742e6f1~95.XX.xxx.xxx
[protection_eligibility] => Eligible
[address_status] => confirmed
[payer_id] => ST7DE7XJYABRS
[address_street] => street adress
[payment_date] => 02:20:01 Oct 18, 2019 PDT
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => 48465
[first_name] => first name
[option_selection1] => openmtbmap.org
[option_selection2] => 95.XX.xxx.xxx
[mc_fee] => 0.89
[address_country_code] => DE
[address_name] => first name second name
[notify_version] => 3.9
[custom] => {“ip_address”:“95.XX.xxx.xxx”}
[payer_status] => verified
[business] => extremecarver@gmail.com
[address_country] => Germany
[address_city] => Ohne
[quantity] => 1
[verify_sign] => AH7APT5m6fb-w0rO2fusA-L4BFU5APXlMHFt1owstjGjPawCgertHUIg
[payer_email] => user_email@email.com
[option_name1] => Originating Domain
[option_name2] => Customer IP Address
[txn_id] => 65K87035KJ206982L
[payment_type] => instant
[last_name] => second name
[address_state] =>
[receiver_email] => extremecarver@gmail.com
[payment_fee] =>
[shipping_discount] => 0.00
[insurance_amount] => 0.00
[receiver_id] => Z89X4K6BZYG2E
[txn_type] => web_accept
[item_name] => €20 gives you 1 year OpenMTBMap access
[discount] => 0.00
[mc_currency] => EUR
[item_number] => 1::1 Y
[residence_country] => DE
[shipping_method] => Default
[transaction_subject] =>
[payment_gross] =>
[ipn_track_id] => 21a7886d8917d
[option_selection] => openmtbmap.org
[option_name] => Originating Domain
[s2member_log] => Array
(
[0] => IPN received on: Fri Oct 18, 2019 9:20:10 am UTC
[1] => s2Member POST vars verified through a POST back to PayPal.
[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/o update vars.
[5] => Signup Confirmation Email sent to: “first name second name” user_email@email.com.
[6] => Signup Notification Emails have been processed.
[7] => User exists. Handling payment for Subscription via ( web_accept ).
[8] => Payment Notification Emails have been processed.
[9] => Storing IPN signup vars now. These are associated with a User’s account record; for future reference.
)

[subscr_gateway] => paypal
[subscr_id] => 65K87035KJ206982L
[subscr_baid] => 65K87035KJ206982L
[subscr_cid] => 65K87035KJ206982L
[level] => 1
[ccaps] => 
[eotper] => 1 Y
[ip] => 95.XX.xxx.xxx
[period1] => 0 D
[mc_amount1] => 0.00
[period3] => 1 Y
[mc_amount3] => 20.00
[initial_term] => 0 D
[initial] => 20.00
[regular] => 20.00
[regular_term] => 1 Y
[recurring] => 0
[currency] => EUR
[currency_symbol] => €

)

and here a working log - exactly the same button setup:

LOG ENTRY: Thu Oct 17th, 2019 @ precisely 7:51 pm UTC
PHP v7.3.10-1+ubuntu18.04.1+deb.sury.org+1 :: WordPress v5.2.4 :: s2Member v191015.1-beta :: s2Member Pro v191015.1-beta
Memory 13.59 MB :: Real Memory 4.00 MB :: Peak Memory 13.70 MB :: Real Peak Memory 4.00 MB
www.velomap.org/?s2member_paypal_notify=1
User-Agent: PayPal IPN ( https://www.paypal.com/ipn )
Array
(
[mc_gross] => 20.00
[invoice] => 5da8c61ac2ce2~xxxx:xxxxx:user_ip
[protection_eligibility] => Eligible
[address_status] => confirmed
[payer_id] => 9P5VFG2XCY2Z8
[address_street] => Talstraße 18
[payment_date] => 12:51:18 Oct 17, 2019 PDT
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => 53177
[first_name] => user first name
[option_selection1] => www.velomap.org
[option_selection2] => xxxx:xxxxx:user_ip
[mc_fee] => 0.89
[address_country_code] => DE
[address_name] => user first name user_last_name
[notify_version] => 3.9
[custom] => {“ip_address”:“xxxx:xxxxx:user_ip”}
[payer_status] => verified
[business] => extremecarver@gmail.com
[address_country] => Germany
[address_city] => Bonn
[quantity] => 1
[verify_sign] => Ap9lXWD3OrbgdoGlEPBLQIkzwpuIAdNoZ7faV74JdXZEfej4K1H8YH-6
[payer_email] => user_email@email.com
[option_name1] => Originating Domain
[option_name2] => Customer IP Address
[txn_id] => 9TB42154Y2583215J
[payment_type] => instant
[last_name] => user_last_name
[address_state] =>
[receiver_email] => extremecarver@gmail.com
[payment_fee] =>
[shipping_discount] => 0.00
[insurance_amount] => 0.00
[receiver_id] => Z89X4K6BZYG2E
[txn_type] => web_accept
[item_name] => €20 gives you 1 year VeloMap access
[discount] => 0.00
[mc_currency] => EUR
[item_number] => 1::1 Y
[residence_country] => DE
[shipping_method] => Default
[transaction_subject] =>
[payment_gross] =>
[ipn_track_id] => 7ef436dc032a
[option_selection] => www.velomap.org
[option_name] => Originating Domain
[s2member_log] => Array
(
[0] => IPN received on: Thu Oct 17, 2019 7:51:27 pm UTC
[1] => s2Member POST vars verified through a POST back to PayPal.
[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/o update vars.
[5] => Signup Confirmation Email sent to: “user first name user_last_name” user_email@email.com.
[6] => Signup Notification URLs have been processed.
[7] => Signup Notification Emails have been processed.
[8] => Storing payment for Subscription via ( web_accept ).
[9] => Creating an IPN response for subscr_payment. This will go into a Transient Queue; and be processed during registration.
[10] => Storing IPN signup vars into a Transient Queue. These will be processed on registration.
)

[subscr_gateway] => paypal
[subscr_id] => 9TB42154Y2583215J
[subscr_baid] => 9TB42154Y2583215J
[subscr_cid] => 9TB42154Y2583215J
[level] => 1
[ccaps] => 
[eotper] => 1 Y
[ip] => xxxx:xxxxx:user_ip
[period1] => 0 D
[mc_amount1] => 0.00
[period3] => 1 Y
[mc_amount3] => 20.00
[initial_term] => 0 D
[initial] => 20.00
[regular] => 20.00
[regular_term] => 1 Y
[recurring] => 0
[currency] => EUR
[currency_symbol] => €

)

LOG ENTRY: Thu Oct 17th, 2019 @ precisely 7:52 pm UTC
PHP v7.3.10-1+ubuntu18.04.1+deb.sury.org+1 :: WordPress v5.2.4 :: s2Member v191015.1-beta :: s2Member Pro v191015.1-beta
Memory 13.78 MB :: Real Memory 2.00 MB :: Peak Memory 13.86 MB :: Real Peak Memory 2.00 MB
www.velomap.org/?s2member_paypal_notify=1
User-Agent: s2Member v191015.1-beta; https://www.velomap.org/de
Array
(
[txn_type] => subscr_payment
[mc_gross] => 20.00
[invoice] => 5da8c61ac2ce2~xxxx:xxxxx:user_ip
[first_name] => user first name
[option_selection1] => www.velomap.org
[option_selection2] => xxxx:xxxxx:user_ip
[custom] => www.velomap.org|xxxx:xxxxx:user_ip|DE|DE|+49-
[payer_email] => user_email@email.com
[option_name1] => Originating Domain
[option_name2] => Customer IP Address
[txn_id] => 9TB42154Y2583215J
[last_name] => user_last_name
[item_name] => €20 gives you 1 year VeloMap access
[mc_currency] => EUR
[item_number] => 1::1 Y
[subscr_gateway] => paypal
[subscr_id] => 9TB42154Y2583215J
[subscr_baid] => 9TB42154Y2583215J
[subscr_cid] => 9TB42154Y2583215J
[option_selection] => www.velomap.org
[option_name] => Originating Domain
[proxy_verified] => paypal
[s2member_log] => Array
(
[0] => IPN received on: Thu Oct 17, 2019 7:52:01 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 ( subscr_payment|recurring_payment ).
[4] => Updated Payment Times for this Member.
[5] => Payment Notification URLs have been processed.
[6] => Payment Notification Emails have been processed.
)

[level] => 1
[ccaps] => 
[ip] => xxxx:xxxxx:user_ip
[currency] => EUR
[currency_symbol] => €
[s2member_paypal_proxy] => paypal
[s2member_paypal_proxy_verification] => ffe159cd68c60de900b374fe6a8c8dc3

)

For actually existing users on extension button (they are handled correctly) it’s always 10 steps:

[s2member_log] => Array
    (
        [0] => IPN received on: Sat Oct 12, 2019 10:55:07 am UTC
        [1] => s2Member POST vars verified through a POST back to PayPal.
        [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] => Automatic EOT (End Of Term) Time set to: Mon Oct 12, 2020 10:55:07 am UTC.
        [6] => s2Member Level/Capabilities updated w/ advanced update routines.
        [7] => Modification Confirmation Email sent to: "first name last_name" <email@email.de>.
        [8] => User exists. Handling `payment` for Subscription via ( `web_accept` ).
        [9] => Payment Notification Emails have been processed.
        [10] => Storing IPN signup vars now. These are associated with a User's account record; for future reference.
    )

This is the log if an actually existing user pays incorrectly without logging in before:

[s2member_log] => Array
(
[0] => IPN received on: Mon Oct 14, 2019 10:32:37 am UTC
[1] => s2Member POST vars verified through a POST back to PayPal.
[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/o update vars.
[5] => Signup Confirmation Email sent to: “first_name Last Name” email@gmail.com.
[6] => Storing payment for Subscription via ( web_accept ).
[7] => Creating an IPN response for subscr_payment. This will go into a Transient Queue; and be processed during registration.
[8] => Storing IPN signup vars into a Transient Queue. These will be processed on registration.
)

The funny thing - on those new ones - the message:

Storing payment for Subscription via ( web_accept ).

is of course incorrect - this is a one time payment - not a subscription! But there the emails are working correctly.

And I have no caching or autoptimize or similar active on the checkout page. So it’s clearly not related to any cache.