dashed-slug.net › Forums › General discussion › New TX hook
Tagged: action, callback, notification, notify, status, transaction wallets_transaction, wallets_deposit
- This topic has 9 replies, 2 voices, and was last updated 5 years, 11 months ago by alexg.
-
AuthorPosts
-
December 31, 2018 at 10:02 pm #5426AnonymousInactive
Is there a way to get information for every new transaction so I can process its information? For example, if I want to automatically thank a user that sends money to a charity address, or if I want to create a list of those users. Or send an SMS to the user when there is a transaction to her address.
I.e. something like walletnotify but within WordPress.January 1, 2019 at 3:03 pm #5430alexgKeymasterHello and happy new year,
You can get notified about transaction data by binding to the
wallets_transaction
action. For example you could add this to your child theme’sfunctions.php
file, or in a new plugin:function wallets_transaction_cb( $tx ) { error_log( print_r( $tx, true ) ); // prints out a stdClass object } add_action( 'wallets_transaction', 'wallets_transaction_cb' );
You will get multiple notifications for each transaction, because the confirmations number is updated each time.
It is your responsibility to handle each transaction only once, so you would have to somehow keep a record of already seen TXIDs. Alternatively, you could perform your action only when the confirmation count is equal to some integer value.
Hope this helps. Please let me know if you have any further questions.
with regards
January 1, 2019 at 3:49 pm #5431AnonymousInactiveThat’s perfect, exactly what I was looking for!
Thanks and Happy New Year to you too!January 2, 2019 at 9:43 am #5435alexgKeymasterHello again,
Continuing after my last post, you might prefer to use the
wallets_deposit
hook. This action only gets notified once for each successful deposit to a user deposit address. This action is part of the notifications mechanism and is also used to send notification emails. Seeincludes/notifications.php
for an example, or see the Notifications chapter in the manual.with regards
January 2, 2019 at 12:07 pm #5437AnonymousInactiveAlex, I’m using your first suggestion to create a log of all transactions, so in case something goes wrong with the database, I have the logs to rebuild lost transactions. But for the examples I pointed out in this post, your second suggestion is better. Thanks!
January 2, 2019 at 1:50 pm #5440AnonymousInactiveInteresting, it seems
wallets_transaction
doesn’t show transfers between users, so it’s not good for logging all transactions as I thought.
Well, I’ll checkwallets_deposit
.January 2, 2019 at 2:16 pm #5442AnonymousInactiveOh, I see the available WP actions now, they are at the bottom of page 36 of the PDF. Sorry for not noticing them before.
January 2, 2019 at 7:32 pm #5445AnonymousInactiveAll internal transfers show status as “pending” (
[status] => pending
) in actionwallets_move_receive
object. Is that normal behavior? Can I trust it is completed, if I’m only using “user confirmations”?
Example output (action is triggered after the sender click her email link):
stdClass Object
(
[id] => 15
[blog_id] => 1
[category] => move
[tags] => receive move
[account] => 2
[other_account] => 1
[address] =>
[extra] =>
[txid] => move-5c2ce304e702c0.16043110-receive
[symbol] => LTCT
[amount] => 1.4500000000
[comment] => test4
[created_time] => 2019-01-02 16:12:52
[updated_time] => 2019-01-02 16:12:52
[confirmations] => 0
[status] => pending
[retries] => 1
[admin_confirm] => 0
[user_confirm] => 1
[nonce] =>
[user] => WP_User Object
I apologize for all these questions, but maybe answers could help other users as well.
Thanks a lot.January 3, 2019 at 8:49 am #5457alexgKeymasterHello,
Again thank you for your feedback. This is indeed a bug. The status of the transaction is updated in the database, but the action receives the state of the transaction before the update. I will fix this in the upcoming
3.9.3
release. You can assume that any internal transactions you receive withwallets_move_receive
have been executed.with regards
January 3, 2019 at 1:11 pm #5480alexgKeymasterIn the latest version
3.9.3
of the plugin, the actions are now reporting the correct latest status and retry count for both move and withdraw transactions. -
AuthorPosts
- You must be logged in to reply to this topic.