I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

New TX hook

dashed-slug.net Forums General discussion New TX hook

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #5426
    Anonymous
    Inactive

    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.

    #5430
    alexg
    Keymaster

    Hello 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’s functions.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

    #5431
    Anonymous
    Inactive

    That’s perfect, exactly what I was looking for!
    Thanks and Happy New Year to you too!

    #5435
    alexg
    Keymaster

    Hello 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. See includes/notifications.php for an example, or see the Notifications chapter in the manual.

    with regards

    #5437
    Anonymous
    Inactive

    Alex, 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!

    #5440
    Anonymous
    Inactive

    Interesting, 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 check wallets_deposit.

    #5442
    Anonymous
    Inactive

    Oh, I see the available WP actions now, they are at the bottom of page 36 of the PDF. Sorry for not noticing them before.

    #5445
    Anonymous
    Inactive

    All internal transfers show status as “pending” ([status] => pending) in action wallets_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.

    #5457
    alexg
    Keymaster

    Hello,

    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 with wallets_move_receive have been executed.

    with regards

    #5480
    alexg
    Keymaster

    In 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.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.