Home Forums Event Espresso Premium Check if transaction exists (By ID)

Check if transaction exists (By ID)

Posted: March 21, 2024 at 11:45 am

Viewing 5 reply threads


March 21, 2024 at 11:45 am

Hello there

im trying to check if a transaction exists. I need to check if the id (reference #) has been entered before by another user in a custom payment method i have developed.

I think i could use one of this 2 methods

(‘TXN_ID’ => $reference)
(‘TXN_ID’ => $reference)

I see both receive an array of parameters but i cant find any more info.

what would be the best approach?



  • Support Staff

March 21, 2024 at 12:47 pm

Hi there,

I need to check if the id (reference #) has been entered before by another user in a custom payment method i have developed.

Hang on a second here, if the user entered a reference during the payment options step, that’s not going to be used as the EE_Transaction ID (TXN_ID)…. the transaction would already have been created at that point and will alread have an ID from the autoincremnting TXN_ID column.

So before we start walk down the wrong path, where is this reference stored and what is it?

EEM_Transaction::instance()->get_all(array(‘TXN_ID’ => $reference));
EEM_Transaction::instance()->get_one(array(‘TXN_ID’ => $reference));

Neither of those are correct as your adding the TXN_ID as a query_param and not as a WHERE condition within the query_params (really simple fix).

You need to work through the docs here:–Model-System

Once you understand how the model system works, querying for EE data becomes much easier.


March 21, 2024 at 7:47 pm

Hello Tony

Im storing the payment reference number in txn_id_chq_nmbr

this way in my doDirectPayment function after getting the gateway response…

I need to query transactions to see if there is on using this reference in field txn_id_chq_nmbr




  • Support Staff

March 22, 2024 at 5:31 am

Ok, so that’s usually intended to be the payment merchants TXN/Payment ID they return when yo request a caputre/sale/etc and its saved on the EE_Payment object itself, it’s not the TXN_ID for the EE_Transaction.

$payment_txn_id = 12345;

$previous_payment = EEM_Payment::instance()->get_payment_by_txn_id_chq_nmbr($payment_txn_id);

if ($previous_payment instanceof EEI_Payment) {
    // Do something with the payment object here

EE_Payments are assigned to an EE_Transaction, so if you have the EE_Transaction object you can pull all related payments using:

$payments = $transaction->payments();

But that’s not really what is needed above, just some additional info.


March 22, 2024 at 11:27 am

Hello Tony

Thanks for your help

this is just what i need to query if exists…

$previous_payment = EEM_Payment::instance()->get_payment_by_txn_id_chq_nmbr($payment_txn_id);



  • Support Staff

March 25, 2024 at 5:32 am

You’re most welcome 🙂

Any further questions just let me know.

Viewing 5 reply threads

The support post ‘Check if transaction exists (By ID)’ 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