Changeset 3081701
- Timestamp:
- 05/06/2024 06:46:15 AM (23 months ago)
- Location:
- blockonomics-bitcoin-payments/trunk
- Files:
-
- 4 edited
-
blockonomics-woocommerce.php (modified) (6 diffs)
-
css/blockonomics_options.css (modified) (1 diff)
-
php/Blockonomics.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blockonomics-bitcoin-payments/trunk/blockonomics-woocommerce.php
r3050839 r3081701 4 4 * Plugin URI: https://github.com/blockonomics/woocommerce-plugin 5 5 * Description: Accept Bitcoin Payments on your WooCommerce-powered website with Blockonomics 6 * Version: 3.7. 16 * Version: 3.7.2 7 7 * Author: Blockonomics 8 8 * Author URI: https://www.blockonomics.co … … 211 211 212 212 $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); 237 215 238 216 add_options_page( … … 304 282 $btc_error = isset($setup_errors['btc']) ? $setup_errors['btc'] : 'false'; 305 283 $bch_error = isset($setup_errors['bch']) ? $setup_errors['bch'] : 'false'; 306 $withdraw_requested = $blockonomics->make_withdraw();307 284 } 308 285 ?> … … 366 343 <div class="wrap"> 367 344 <h1><?php echo __('Blockonomics', 'blockonomics-bitcoin-payments')?></h1> 368 <?php369 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; ?>378 345 <form method="post" name="myform" id="myform" onsubmit="return validateBlockonomicsForm()" action="options.php"> 379 346 <h2 class="nav-tab-wrapper"> … … 458 425 <?php 459 426 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'); ?> 470 434 </td> 471 </tr> 472 <?php endif; 473 endif; 435 <tr> 436 <?php 437 } 438 474 439 if (get_option('blockonomics_btc') == '1' && isset($btc_error)): 475 440 if ($btc_error): … … 715 680 delete_option('blockonomics_callback_secret'); 716 681 delete_option('blockonomics_api_key'); 717 delete_option('blockonomics_temp_api_key');718 delete_option('blockonomics_temp_withdraw_amount');719 682 delete_option('blockonomics_margin'); 720 683 delete_option('blockonomics_timeperiod'); -
blockonomics-bitcoin-payments/trunk/css/blockonomics_options.css
r2502317 r3081701 32 32 .bnomics-width { 33 33 max-width: 550px !important; 34 }35 36 .bnomics-width-withdraw {37 max-width: 680px !important;38 34 } 39 35 -
blockonomics-bitcoin-payments/trunk/php/Blockonomics.php
r3021875 r3081701 11 11 const SET_CALLBACK_URL = 'https://www.blockonomics.co/api/update_callback'; 12 12 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';15 13 16 14 const BCH_BASE_URL = 'https://bch.blockonomics.co'; … … 51 49 { 52 50 $api_key = get_option("blockonomics_api_key"); 53 if (!$api_key)54 {55 $api_key = get_option("blockonomics_temp_api_key");56 }57 51 return $api_key; 58 52 } … … 216 210 public function check_callback_urls_or_set_one($crypto, $response) 217 211 { 218 $api_key = get_option("blockonomics_api_key");219 //If BCH enabled and API Key is not set: give error220 if (!$api_key && $crypto === 'bch'){221 $error_str = __('Set the API Key or disable BCH', 'blockonomics-bitcoin-payments');222 return $error_str;223 }224 212 //chek the current callback and detect any potential errors 225 213 $error_str = $this->check_get_callbacks_response_code($response, $crypto); … … 231 219 } 232 220 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 }244 221 245 222 /* … … 275 252 } 276 253 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 305 254 private function get($url, $api_key = '') 306 255 { … … 365 314 public function test_one_crypto($crypto) 366 315 { 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 367 322 $response = $this->get_callbacks($crypto); 368 323 $error_str = $this->check_callback_urls_or_set_one($crypto, $response); … … 808 763 $order['payment_status'] = 2; 809 764 $order = $this->check_paid_amount($paid_satoshi, $order, $wc_order); 810 $this->update_temp_draw_amount($paid_satoshi);811 765 } 812 766 else { … … 852 806 $is_order_underpaid = ($order['expected_satoshi'] - $underpayment_slack > $order['paid_satoshi'] && !empty($order['paid_satoshi'])) ? TRUE : FALSE; 853 807 return $is_order_underpaid; 854 }855 // Keep track of funds in temp wallet856 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 }862 808 } 863 809 -
blockonomics-bitcoin-payments/trunk/readme.txt
r3050839 r3081701 4 4 Requires at least: 3.0.1 5 5 Tested up to: 6.4.2 6 Stable tag: 3.7. 16 Stable tag: 3.7.2 7 7 License: MIT 8 8 License URI: http://opensource.org/licenses/MIT … … 39 39 == Installation == 40 40 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 = 49 42 [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) 50 43 … … 84 77 == Changelog == 85 78 79 = 3.7.2 = 80 * Removed temp wallet support 81 86 82 = 3.7.1 = 87 83 * Fix search order by address/txid if HPOS active
Note: See TracChangeset
for help on using the changeset viewer.