From a968206d36a4fea3a72073d19163586e2a252ae8 Mon Sep 17 00:00:00 2001 From: atmoner Date: Thu, 26 Jan 2023 10:34:20 +0100 Subject: [PATCH 1/4] Fix call api-store only on checkout page --- public/class-cosmos-woocommerce-public.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/class-cosmos-woocommerce-public.php b/public/class-cosmos-woocommerce-public.php index 93a0526..625fd0c 100644 --- a/public/class-cosmos-woocommerce-public.php +++ b/public/class-cosmos-woocommerce-public.php @@ -95,8 +95,10 @@ public function enqueue_scripts() { * between the defined hooks and the functions defined in this * class. */ - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/bundle.js', array( 'jquery' ), $this->version, 'all' ); - wp_enqueue_script( $this->plugin_name . '_mainscript', plugin_dir_url( __FILE__ ) . 'js/mainscript.js', array( 'jquery' ), $this->version, true ); + if ( is_checkout() ) { + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/bundle.js', array( 'jquery' ), $this->version, 'all' ); + wp_enqueue_script( $this->plugin_name . '_mainscript', plugin_dir_url( __FILE__ ) . 'js/mainscript.js', array( 'jquery' ), $this->version, true ); + } } /** * Start cosmos pay form From f17e03476c40e81978a357b1a662ca9e34bd3d77 Mon Sep 17 00:00:00 2001 From: atmoner Date: Thu, 26 Jan 2023 10:40:13 +0100 Subject: [PATCH 2/4] Fix mobile view on checkout --- public/js/mainscript.js | 13 +++++++++---- public/partials/cosmos-payment-tpl.php | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/public/js/mainscript.js b/public/js/mainscript.js index e54ce01..a32c026 100644 --- a/public/js/mainscript.js +++ b/public/js/mainscript.js @@ -1,4 +1,4 @@ -function startChecking( order_id, mainDomain, finalApiUrl, memo, isBlocked, isLogged, nonceSelectChain, nonceDeleteOrder, nonceSwitchMethod, setDefault ) { +function startChecking( order_id, mainDomain, finalApiUrl, memo, isBlocked, isLogged, nonceSelectChain, nonceDeleteOrder, nonceSwitchMethod, setDefault, isMobile ) { $('.woocommerce-thankyou-order-received').hide() $('.woocommerce-order-details').hide() @@ -47,9 +47,14 @@ function startChecking( order_id, mainDomain, finalApiUrl, memo, isBlocked, isLo $( "#chainIcon" ).show() timerOrder( result.startTime ) }); - - $.post( finalApiUrl, { switchMethod: 'keplr', order_id: order_id, nonce: nonceSwitchMethod }, function( result ) { - // console.log(result); + + let finalMethod = '' + if(isMobile) { + finalMethod = 'another' + } else + finalMethod = 'keplr' + + $.post( finalApiUrl, { switchMethod: finalMethod, order_id: order_id, nonce: nonceSwitchMethod }, function( result ) { }); } diff --git a/public/partials/cosmos-payment-tpl.php b/public/partials/cosmos-payment-tpl.php index 5564fcc..497bdc8 100644 --- a/public/partials/cosmos-payment-tpl.php +++ b/public/partials/cosmos-payment-tpl.php @@ -16,7 +16,12 @@ } else { $isLogged = 'false'; } - + + if( wp_is_mobile() ){ + $isMobile = 'true'; + } else { + $isMobile = 'false'; + } ?> @@ -58,7 +63,9 @@ Select your prefered way to pay:
@@ -222,7 +229,8 @@ function myTimer(sendTo, amount, memo) { var nonceDeleteOrder = "" var nonceSwitchMethod = "" var setDefault = "" - console.log('isLogged '+isLogged) + var isMobile = "" + startChecking( order_id, mainDomain, @@ -233,7 +241,8 @@ function myTimer(sendTo, amount, memo) { nonceSelectChain, nonceDeleteOrder, nonceSwitchMethod, - setDefault + setDefault, + isMobile ); }) function copyRecipient() { From 18defa5801b945b88f4ffdc4efc2089d566c97b8 Mon Sep 17 00:00:00 2001 From: atmoner Date: Thu, 26 Jan 2023 10:42:45 +0100 Subject: [PATCH 3/4] Implementation of BCNAracle on bitcanna --- api-cosmos.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api-cosmos.php b/api-cosmos.php index f651c42..9ef72e9 100644 --- a/api-cosmos.php +++ b/api-cosmos.php @@ -104,9 +104,13 @@ } // Check the currency from woocommerce and convert it to price chain $currencyList = "usd,aed,ars,aud,bdt,bhd,bmd,brl,cad,chf,clp,cny,czk,dkk,eur,gbp,hkd,huf,idr,ils,inr,jpy,krw,kwd,lkr,mmk,mxn,myr,ngn,nok,nzd,php,pkr,pln,rub,sar,sek,sgd,thb,try,twd,uah,vef,vnd,zar,xdr"; - // $dataValueCoin = file_get_contents('https://api.coingecko.com/api/v3/simple/price?ids='.$dataChain['coingeckoId'].'&vs_currencies='.$currencyList); - $dataValueCoin = wp_remote_retrieve_body( wp_remote_get( 'https://api.coingecko.com/api/v3/simple/price?ids='.$dataChain['coingeckoId'].'&vs_currencies='.$currencyList ) ); + if ($dataChain['coingeckoId'] === 'bitcanna') { + $dataValueCoin = wp_remote_retrieve_body( wp_remote_get( 'https://bcnaracle.bitcanna.io/bcnaracle.json' ) ); + } else { + $dataValueCoin = wp_remote_retrieve_body( wp_remote_get( 'https://api.coingecko.com/api/v3/simple/price?ids='.$dataChain['coingeckoId'].'&vs_currencies='.$currencyList ) ); + } + $decodedData = json_decode($dataValueCoin); $currencyNow = strtolower(get_woocommerce_currency()); // And display good price! From 00d7985d5c0d7d5f609cca9d1040954320a23425 Mon Sep 17 00:00:00 2001 From: atmoner Date: Thu, 26 Jan 2023 10:45:19 +0100 Subject: [PATCH 4/4] Update version 1.0.16 --- README.txt | 9 +++++++-- cosmos-woocommerce.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.txt b/README.txt index 220e0fe..586a44e 100644 --- a/README.txt +++ b/README.txt @@ -5,7 +5,7 @@ Donate link: https://commerce.bitcanna.io Tags: payments, cryptocurrency, blockchain Requires at least: 3.0.1 Tested up to: 6.1.1 -Stable tag: 1.0.15 +Stable tag: 1.0.16 Requires PHP: 7.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -37,11 +37,16 @@ For our FAQ we'd like to refer you to our [documentation website](https://docs.b 5. After just a couple seconds, the payment will be performed and you can view your transaction. == Changelog == += 1.0.16 = +* Fix call api-store only on checkout page +* Fix mobile view on checkout +* Implementation of BCNAracle on bitcanna + = 1.0.15 = * Fix bug on default chain selected * Add message error if no chain is selected in adminCP -= 1.0.13 = += 1.0.14 = * Add failover on RPC/LCD * Fix bech32 admin confirmation diff --git a/cosmos-woocommerce.php b/cosmos-woocommerce.php index ec56f56..e8e0cfd 100644 --- a/cosmos-woocommerce.php +++ b/cosmos-woocommerce.php @@ -16,7 +16,7 @@ * Plugin Name: Cosmos Pay * Plugin URI: https://twitter.com/bitcannaglobal * Description: Easily accept cryptocurrency payments on your WordPress site. Enable multiple currencies from the interconnected Cosmos ecosystem. - * Version: 1.0.15 + * Version: 1.0.16 * Author: BitCanna * Author URI: https://commerce.bitcanna.io * License: GPL-2.0+ @@ -35,7 +35,7 @@ * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.15' ); +define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.16' );