Posted: 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 EEM_Transaction::instance()->get_all(array I see both receive an array of parameters but i cant find any more info. what would be the best approach? Cheers, |
|
Hi there,
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?
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: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System Once you understand how the model system works, querying for EE data becomes much easier. |
|
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 thanks, $payment->set_txn_id_chq_nmbr($reference); |
|
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.
EE_Payments are assigned to an EE_Transaction, so if you have the EE_Transaction object you can pull all related payments using:
But that’s not really what is needed above, just some additional info. |
|
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); cheers, |
|
You’re most welcome 🙂 Any further questions just let me know. |
|
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.