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!

dev_wpwork

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • dev_wpwork
    Participant

    Hello friend,

    Thank you for all the help. I was able to adjust the code so that it generates the address in the wallet and creates a transaction in the “Wallet” plugin. The only point I still haven’t been able to resolve was that after making a deposit and crediting the user’s balance, I tried to make a withdrawal, but the process remains pending.

    In the log of the transaction itself, I verified that it passes all the checks successfully, but it seems that for some reason it does not actually perform the action of making the withdrawal. So, I activated the log and will perform a new withdrawal test to see what happens.

    An important point that I noticed is that as soon as I activated the log, I could notice an interesting error that talks about two tables missing in the database. Should I be worried about this?

    [11-Apr-2024 16:56:09 UTC] [1712854569] Bitcoin and Altcoin Wallets: Starting cron tasks!
    [11-Apr-2024 16:56:09 UTC] [1712854569] Bitcoin and Altcoin Wallets: DSWallets\Migration_Task: Task started.
    [11-Apr-2024 16:56:09 UTC] [1712854569] Bitcoin and Altcoin Wallets: DSWallets\Migration_Task: Running migration task: {“type”:”none”,”add_count”:false,”add_count_ok”:0,”add_count_fail”:0,”add_last_id”:false,”tx_count”:false,”tx_count_ok”:0,”tx_count_fail”:0,”tx_last_id”:false,”bal_last_uid”:0,”bal_pending”:[]}
    [11-Apr-2024 16:56:09 UTC] WordPress database error Table ‘website2.wp_wallets_adds’ doesn’t exist for query SELECT COUNT(*) FROM wp_wallets_adds WHERE 0 OR blog_id = 1 made by do_action_ref_array(‘wallets_cron_tasks’), WP_Hook->do_action, WP_Hook->apply_filters, DSWallets\Task->DSWallets\{closure}, DSWallets\Migration_Task->run
    [11-Apr-2024 16:56:09 UTC] WordPress database error Table ‘website2.wp_wallets_txs’ doesn’t exist for query SELECT COUNT(*) FROM wp_wallets_txs WHERE 0 OR blog_id = 1 made by do_action_ref_array(‘wallets_cron_tasks’), WP_Hook->do_action, WP_Hook->apply_filters, DSWallets\Task->DSWallets\{closure}, DSWallets\Migration_Task->run

    Another interesting point is that I acquired the plugin to finalize a purchase using the balance. However, to my surprise, after making the deposit and validating the user’s balance, I noticed that when reaching the checkout screen, the plugin announces that the user does not have an available balance.

    So, I left a version for testing with JavaScript and its original shortcodes to validate the functionalities. I verified that there seems to be some error, certainly in configuration on my part, as the shortcode itself seems to be relating the decimal places incorrectly. Thus, it appears that there is not enough balance to finalize a purchase.

    However, if I check the user’s balance in the WordPress management panel, the balance is there and matches exactly with the balance in the code I developed. I am sure this must be some wrong configuration on my part. If you could help me with this, it would be appreciated.

    I am also attaching some evidence to support everything I am saying.

    Attachments:
    You must be logged in to view attached files.
    dev_wpwork
    Participant

    Thank you for this, it helped a lot, I was able to display the customer’s balance on the customer’s page through a plugin using your documentation, but now I’m having difficulty generating an address, I used the parameter described in this topic: https://wallets- phpdoc.dashed-slug.net/wallets/classes/DSWallets-Wallet-Adapter.html#method_get_new_address but I was not successful in returning the wallet adapter, is there any topic that helps in communicating with the bitcoin wallet adapter?

    but thank you for your attention

    Here is the plugin code, just for testing I left the code with both features together

    add_shortcode(‘exibir_saldos’, ‘exibir_saldos_usuario’);

    function exibir_saldos_usuario() {
    if (!function_exists(‘DSWallets\get_all_currencies’) || !function_exists(‘DSWallets\get_balance_for_user_and_currency_id’)) {
    return ‘As funções necessárias do plugin não estão disponíveis.’;
    }

    $user_id = get_current_user_id();
    if (!$user_id) {
    return ‘Usuário não identificado.’;
    }

    $currencies = DSWallets\get_all_currencies();
    $output = ‘<div class=”saldos-de-moedas”>’;

    foreach ($currencies as $currency) {
    // Certifique-se de que o objeto $currency tem a propriedade ou método esperado para obter o currency_id
    // Esta linha é um palpite sobre como você poderia acessar o currency_id corretamente
    $currency_id = property_exists($currency, ‘post_id’) ? $currency->post_id : 0; // Ajuste conforme necessário

    $saldo = DSWallets\get_balance_for_user_and_currency_id($user_id, $currency_id);
    $formatted_balance = number_format($saldo * pow(10, -$currency->decimals), $currency->decimals, ‘.’, ”);

    $output .= ‘<div class=”moeda”>’;
    $output .= ‘<span class=”nome-moeda”>’ . esc_html($currency->name) . ‘</span>: ‘;
    $output .= ‘<span class=”saldo-moeda”>’ . esc_html($formatted_balance) . ‘ ‘ . esc_html($currency->symbol) . ‘</span>’;
    $output .= ‘</div>’;
    }

    $output .= ‘</div>’;
    return $output;
    }

    function gerar_novo_endereco() {
    $currency = null;
    $wallets = new Wallets();
    $new_address = $wallets->get_new_address($currency);

    return $new_address->get_address();
    }

    add_shortcode(‘gerar_endereco’, ‘gerar_novo_endereco’);

    dev_wpwork
    Participant

    Could you create an example of a plugin that connects to the Wallet and lists the balance? This way, I can follow the same parameters.

Viewing 3 posts - 1 through 3 (of 3 total)