Support

Home Forums Event Espresso Premium Trigger function when payment is confirmed

Trigger function when payment is confirmed

Posted: November 25, 2015 at 4:42 am

Viewing 5 reply threads


Zoee

November 25, 2015 at 4:42 am

Hi all, we are using espresso_track_successful_sale_gateway() to run some code that sends the registrants data to another system when they have paid. It seems this function is running even if the order status is “cancelled” or “pending payment” – how can we stop this? We only want our code to run if their status is “approved”…

Thanks ๐Ÿ™‚


Tony

  • Support Staff

November 25, 2015 at 5:05 am

Hi Zoee,

Turns out espresso_track_successful_sale_gateway() was a custom function created by another user on the forums here:

https://eventespresso.com/topic/ee4-and-wp-affiliate/

We can not provide support for that function but it needs to check the current status of the registration using something like $registration->status_ID().

Then check if the status is approved before triggering the code to run.


Zoee

November 26, 2015 at 7:04 am

Do you guys have a function or hook I can use instead? I’d rather use something built in by you guys?


Tony

  • Support Staff

November 26, 2015 at 7:25 am

That function uses 2 hooks that are within core:

AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment
(Fired the registration and transaction status is automatically updated)
and

AHEE__EE_Transaction_Processor__manually_update_registration_statuses
(Fired when the registration status is manually updated)

You can use the function above as a base to start your own if you prefer, the hooks are still the same ๐Ÿ™‚


Zoee

December 1, 2015 at 5:02 am

So those hooks are called whenever an order is placed, how can I confirmed they actually paid?


Tony

  • Support Staff

December 2, 2015 at 12:56 pm

Hmm, you would need to step through the transaction and confirm if a payment was made if using those hooks.

So you want a hook that will only fire once, when a payment made and it updates the transaction?

You could use ‘AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful’ instead.

That passes the EE Transaction and EE Payment objects to the hook so you can use those to pull in any needed data.

Viewing 5 reply threads

The support post ‘Trigger function when payment is confirmed’ 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