Plugin Directory

Changeset 3081701


Ignore:
Timestamp:
05/06/2024 06:46:15 AM (23 months ago)
Author:
blockonomics
Message:

Removed temp wallet support

Location:
blockonomics-bitcoin-payments/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • blockonomics-bitcoin-payments/trunk/blockonomics-woocommerce.php

    r3050839 r3081701  
    44 * Plugin URI: https://github.com/blockonomics/woocommerce-plugin
    55 * Description: Accept Bitcoin Payments on your WooCommerce-powered website with Blockonomics
    6  * Version: 3.7.1
     6 * Version: 3.7.2
    77 * Author: Blockonomics
    88 * Author URI: https://www.blockonomics.co
     
    211211
    212212        $nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce( sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])), 'update-options' ) : "";
    213         if (isset($_POST['generateSecret']) && $nonce)
    214         {
    215             generate_secret(true);
    216         }
    217 
    218         $api_key = $blockonomics->get_api_key();       
    219         // get_api_key() will return api key or temp api key
    220         // if both are null, generate new blockonomics guest account with temporary wallet
    221         // temp wallet will be used with temp api key
    222         if (!$api_key)
    223         {
    224             generate_secret();
    225             $callback_url = get_callback_url();
    226             $response = $blockonomics->get_temp_api_key($callback_url);
    227             if ($response->response_code != 200)
    228             {
    229                 $message = __('Error while generating temporary APIKey: '. isset($response->message) ? $response->message : '', 'blockonomics-bitcoin-payments');
    230                 display_admin_message($message, 'error');
    231             }
    232             else
    233             {
    234                 update_option("blockonomics_temp_api_key", isset($response->apikey) ? $response->apikey : '');
    235             }
    236         }
     213        $force_generate = isset($_POST['generateSecret']) && $nonce ? true : false;
     214        generate_secret($force_generate);
    237215
    238216        add_options_page(
     
    304282            $btc_error = isset($setup_errors['btc']) ? $setup_errors['btc'] : 'false';
    305283            $bch_error = isset($setup_errors['bch']) ? $setup_errors['bch'] : 'false';
    306             $withdraw_requested = $blockonomics->make_withdraw();
    307284        }
    308285        ?>
     
    366343        <div class="wrap">
    367344            <h1><?php echo __('Blockonomics', 'blockonomics-bitcoin-payments')?></h1>
    368             <?php
    369                 if (isset($withdraw_requested)):?>
    370                 <div class="bnomics-width-withdraw">
    371                     <td colspan='2' class="bnomics-options-no-padding bnomics-width">
    372                         <p class='notice notice-<?php echo $withdraw_requested[1]?>'>
    373                             <?php echo $withdraw_requested[0].'.' ?>
    374                         </p>
    375                     </td>
    376                 </div>
    377             <?php endif; ?>
    378345            <form method="post" name="myform" id="myform" onsubmit="return validateBlockonomicsForm()" action="options.php">
    379346                <h2 class="nav-tab-wrapper">
     
    458425                        <?php
    459426                        get_started_message();
    460                         $btc_enabled = get_option("blockonomics_btc");
    461                         if ($btc_enabled || get_option("blockonomics_btc") === false): 
    462                             $total_received = get_option('blockonomics_temp_withdraw_amount') / 1.0e8;
    463                             $api_key = get_option("blockonomics_api_key");
    464                             $temp_api_key = get_option("blockonomics_temp_api_key");
    465                             if ($temp_api_key): ?>
    466                                 <th class="blockonomics-narrow-th" scope="row"><b><?php echo __('Temporary Destination', 'blockonomics-bitcoin-payments')?></b></th>
    467                                 <td colspan="2" class="bnomics-options-no-padding">
    468                                     <label><b><?php echo __("Blockonomics Wallet (Balance: $total_received BTC)", 'blockonomics-bitcoin-payments')?></b></label>
    469                                     <label><?php echo __("Our temporary wallet receives your payments until your configure your own wallet. Withdraw to your wallet is triggered automatically when configuration is done", 'blockonomics-bitcoin-payments')?></label>
     427                        $total_received = get_option('blockonomics_temp_withdraw_amount', 0);
     428                        if ($total_received) {
     429                            $formatted_total_received = ($total_received < 10000) ? rtrim(number_format($total_received/1.0e8, 8),0) : ($total_received / 1.0e8);
     430                            ?>
     431                            <tr>
     432                                <td colspan="2" class="notice notice-info">
     433                                    <?php echo __("You have $formatted_total_received BTC in your temporary wallet.<br>Please submit a ticket to <a href='https://help.blockonomics.co/support/tickets/new'>Blockonomics Support</a> to withdraw the funds.", 'blockonomics-bitcoin-payments'); ?>
    470434                                </td>
    471                             </tr>
    472                             <?php endif;
    473                         endif;
     435                            <tr>
     436                            <?php
     437                        }
     438
    474439                        if (get_option('blockonomics_btc') == '1' && isset($btc_error)):
    475440                            if ($btc_error):
     
    715680    delete_option('blockonomics_callback_secret');
    716681    delete_option('blockonomics_api_key');
    717     delete_option('blockonomics_temp_api_key');
    718     delete_option('blockonomics_temp_withdraw_amount');
    719682    delete_option('blockonomics_margin');
    720683    delete_option('blockonomics_timeperiod');
  • blockonomics-bitcoin-payments/trunk/css/blockonomics_options.css

    r2502317 r3081701  
    3232.bnomics-width {
    3333    max-width: 550px !important;
    34 }
    35 
    36 .bnomics-width-withdraw {
    37     max-width: 680px !important;
    3834}
    3935
  • blockonomics-bitcoin-payments/trunk/php/Blockonomics.php

    r3021875 r3081701  
    1111    const SET_CALLBACK_URL = 'https://www.blockonomics.co/api/update_callback';
    1212    const GET_CALLBACKS_URL = 'https://www.blockonomics.co/api/address?&no_balance=true&only_xpub=true&get_callback=true';
    13     const TEMP_API_KEY_URL = 'https://www.blockonomics.co/api/temp_wallet';
    14     const TEMP_WITHDRAW_URL = 'https://www.blockonomics.co/api/temp_withdraw_request';
    1513
    1614    const BCH_BASE_URL = 'https://bch.blockonomics.co';
     
    5149    {
    5250        $api_key = get_option("blockonomics_api_key");
    53         if (!$api_key)
    54         {
    55             $api_key = get_option("blockonomics_temp_api_key");
    56         }
    5751        return $api_key;
    5852    }
     
    216210    public function check_callback_urls_or_set_one($crypto, $response)
    217211    {
    218         $api_key = get_option("blockonomics_api_key");
    219         //If BCH enabled and API Key is not set: give error
    220         if (!$api_key && $crypto === 'bch'){
    221             $error_str = __('Set the API Key or disable BCH', 'blockonomics-bitcoin-payments');
    222             return $error_str;
    223         }
    224212        //chek the current callback and detect any potential errors
    225213        $error_str = $this->check_get_callbacks_response_code($response, $crypto);
     
    231219    }
    232220
    233 
    234     public function get_temp_api_key($callback_url)
    235     {
    236 
    237         $url = Blockonomics::TEMP_API_KEY_URL;
    238         $body = json_encode(array('callback' => $callback_url));
    239         $response = $this->post($url, '', $body);
    240         $responseObj = json_decode(wp_remote_retrieve_body($response));
    241         $responseObj->{'response_code'} = wp_remote_retrieve_response_code($response);
    242         return $responseObj;
    243     }
    244221
    245222    /*
     
    275252    }
    276253
    277     public function make_withdraw()
    278     {
    279         $api_key = $this->api_key;
    280         $temp_api_key = get_option('blockonomics_temp_api_key');
    281         if (!$api_key || !$temp_api_key || $temp_api_key == $api_key) {
    282             return null;
    283         }
    284         if (get_option('blockonomics_temp_withdraw_amount') > 0)
    285         {
    286 
    287             $url = Blockonomics::TEMP_WITHDRAW_URL.'?tempkey='.$temp_api_key;
    288             $response = $this->post($url, $api_key);
    289             $responseObj = json_decode(wp_remote_retrieve_body($response));
    290             $response_code = wp_remote_retrieve_response_code($response);
    291             if ($response_code != 200)
    292             {
    293                 $message = __('Error while making withdraw: '.$responseObj->message, 'blockonomics-bitcoin-payments');
    294                 return [$message, 'error'];
    295             }
    296             update_option("blockonomics_temp_api_key", null);
    297             update_option('blockonomics_temp_withdraw_amount', 0);
    298             $message = __('Your funds withdraw request has been submitted. Please check your Blockonomics registered emailid for details', 'blockonomics-bitcoin-payments');
    299             return [$message, 'success'];
    300         }
    301         update_option("blockonomics_temp_api_key", null);
    302         return null;
    303     }
    304 
    305254    private function get($url, $api_key = '')
    306255    {
     
    365314    public function test_one_crypto($crypto)
    366315    {
     316        $api_key = get_option("blockonomics_api_key");
     317        //If API Key is not set: give error
     318        if (!$api_key){
     319            return __('Set your Blockonomics API Key', 'blockonomics-bitcoin-payments');
     320        }
     321
    367322        $response = $this->get_callbacks($crypto);
    368323        $error_str = $this->check_callback_urls_or_set_one($crypto, $response);
     
    808763            $order['payment_status'] = 2;
    809764            $order = $this->check_paid_amount($paid_satoshi, $order, $wc_order);
    810             $this->update_temp_draw_amount($paid_satoshi);
    811765        }
    812766        else {
     
    852806        $is_order_underpaid = ($order['expected_satoshi'] - $underpayment_slack > $order['paid_satoshi'] && !empty($order['paid_satoshi'])) ? TRUE : FALSE;
    853807        return $is_order_underpaid;
    854     }
    855     // Keep track of funds in temp wallet
    856     public function update_temp_draw_amount($paid_satoshi){
    857         if(get_option('blockonomics_temp_api_key') && !get_option("blockonomics_api_key")) {
    858             $current_temp_amount = get_option('blockonomics_temp_withdraw_amount');
    859             $new_temp_amount = $current_temp_amount + $paid_satoshi;
    860             update_option('blockonomics_temp_withdraw_amount', $new_temp_amount);
    861         }
    862808    }
    863809
  • blockonomics-bitcoin-payments/trunk/readme.txt

    r3050839 r3081701  
    44Requires at least: 3.0.1
    55Tested up to: 6.4.2
    6 Stable tag: 3.7.1
     6Stable tag: 3.7.2
    77License: MIT
    88License URI: http://opensource.org/licenses/MIT
     
    3939== Installation ==
    4040
    41 You can operate the plugin in two different modes: 
    42 
    43 = Default Mode  =
    44 - There is **no installation** procedure required. Blockonomics automatically starts working in this mode on activation of plugin
    45 - Bitcoin payments go to a Blockonomics temporary wallet   
    46 - To withdraw received funds, user has to change to *Direct to Wallet* mode
    47 
    48 = Direct to Wallet Mode (Recommended)  =
     41= Direct to Wallet  =
    4942[Video Tutorial](https://www.youtube.com/watch?v=lNFBAk2x6ns) | [Blog Tutorial](https://blog.blockonomics.co/how-to-accept-bitcoin-payments-on-woocommerce-using-blockonomics-f18661819a62) 
    5043 
     
    8477== Changelog ==
    8578
     79= 3.7.2  =
     80* Removed temp wallet support
     81
    8682= 3.7.1  =
    8783* Fix search order by address/txid if HPOS active
Note: See TracChangeset for help on using the changeset viewer.