Skip to content

Commit

Permalink
Merge pull request #8 from BitCannaGlobal/v1.0.16
Browse files Browse the repository at this point in the history
Update 1.0.16
  • Loading branch information
atmoner authored Jan 26, 2023
2 parents 42183bc + 00d7985 commit c952728
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
9 changes: 7 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions api-cosmos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions cosmos-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -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' );



Expand Down
6 changes: 4 additions & 2 deletions public/class-cosmos-woocommerce-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions public/js/mainscript.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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 ) {
});
}

Expand Down
17 changes: 13 additions & 4 deletions public/partials/cosmos-payment-tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
} else {
$isLogged = 'false';
}


if( wp_is_mobile() ){
$isMobile = 'true';
} else {
$isMobile = 'false';
}
?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

Expand Down Expand Up @@ -58,7 +63,9 @@
Select your prefered way to pay:
<div class="box">
<select id="selectMethod">
<option value="keplr">Pay automatically with keplr</option>
<?php if (!wp_is_mobile()) { ?>
<option value="keplr">Pay automatically with keplr</option>
<?php } ?>
<option value="another">Pay with another wallet</option>
</select>
</div>
Expand Down Expand Up @@ -222,7 +229,8 @@ function myTimer(sendTo, amount, memo) {
var nonceDeleteOrder = "<?php echo esc_attr( wp_create_nonce( 'cosmos_delete_order' ) ) ?>"
var nonceSwitchMethod = "<?php echo esc_attr( wp_create_nonce( 'cosmos_switch_method' ) ) ?>"
var setDefault = "<?php echo esc_attr( $setDefault ) ?>"
console.log('isLogged '+isLogged)
var isMobile = "<?php echo $isMobile ?>"

startChecking(
order_id,
mainDomain,
Expand All @@ -233,7 +241,8 @@ function myTimer(sendTo, amount, memo) {
nonceSelectChain,
nonceDeleteOrder,
nonceSwitchMethod,
setDefault
setDefault,
isMobile
);
})
function copyRecipient() {
Expand Down

0 comments on commit c952728

Please sign in to comment.