Support

Home Forums Community Forum Get paying users ID on completed payments

Get paying users ID on completed payments

Posted: September 15, 2014 at 6:27 am

Viewing 4 reply threads


Gabriel Merovingi

September 15, 2014 at 6:27 am

Hi.

I am looking to award points to users upon completed payments (no matter which gateway) and found the AHEE__EE_Gateway__update_transaction_with_payment__done action hook which seems to be a good place to start.

There is a great deal of information available at this instance so I am unsure what would be the easiest way for me to get the paying users ID. Any suggestions?


Dean

September 16, 2014 at 6:17 am

Hi,

Thanks for this question! Our new OOP code is still something new to me so it was nice having a look through.

Anyway.

You will need two functions, one hooked into AHEE__EE_Gateway__update_transaction_with_payment__done

and one hooked into AHEE__EE_Gateway__update_transaction_with_payment__no_payment otherwise you will miss the invoice related payments.

In both those functions you can make a variable like so

$x = $transaction->session_data();

This will give you an array of session data that includes the user ID (numeric if logged in, NULL if logged out).

You can then use that as you normally would, e.g.

echo $x['user_id'];

These are my testing functions http://take.ms/WzWq1


Gabriel Merovingi

September 16, 2014 at 6:31 am

Excellent thank you!
I ignored the AHEE__EE_Gateway__update_transaction_with_payment__no_payment action because I only want the instances where payments have actually been made. I assumed this action would fire in all other cases (which I need to ignore).

I basically need to ensure that payments are completed before awarding points to users.


Dean

September 17, 2014 at 2:14 am

Hey,

Then yeah it sounds like just using AHEE__EE_Gateway__update_transaction_with_payment__done should be fine.


Gabriel Merovingi

September 17, 2014 at 4:15 am

Thank you Dean.

Viewing 4 reply threads

The support post ‘Get paying users ID on completed payments’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso