Skip to content

Commit

Permalink
v2.3.1 release
Browse files Browse the repository at this point in the history
* Order would be confirmed even if user closed the payment page before transaction was confirmed
* Copy buttons fix if clicked on icon
  • Loading branch information
olegabr committed Jul 17, 2018
1 parent a2b5bdd commit 8ba0fcb
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 308 deletions.
15 changes: 14 additions & 1 deletion ether-and-erc20-tokens-woocommerce-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: Ether and ERC20 tokens WooCommerce Payment Gateway
Plugin URI: https://wordpress.org/plugins/ether-and-erc20-tokens-woocommerce-payment-gateway
Description: Ether and ERC20 tokens WooCommerce Payment Gateway enables customers to pay with Ether or any ERC20 or ERC223 token on your WooCommerce store.
Version: 2.3.0
Version: 2.3.1
WC requires at least: 2.6.0
WC tested up to: 3.4
Author: ethereumicoio
Expand Down Expand Up @@ -50,6 +50,8 @@ function epg_plugin_admin_notice() {
$GLOBALS['ether-and-erc20-tokens-woocommerce-payment-gateway'] = new \Ethereumico\Epg\Main( plugins_url( '', __FILE__ ), plugin_dir_path( __FILE__ ) );
$GLOBALS['ether-and-erc20-tokens-woocommerce-payment-gateway']->run();

require_once dirname( __FILE__ ) . '/vendor/prospress/action-scheduler/action-scheduler.php';

// Place in Option List on Settings > Plugins page
function ether_and_erc20_tokens_woocommerce_payment_gateway_actlinks( $links, $file ) {
// Static so we don't call plugin_basename on every plugin row.
Expand All @@ -67,6 +69,17 @@ function ether_and_erc20_tokens_woocommerce_payment_gateway_actlinks( $links, $f
return $links;
}
add_filter( 'plugin_action_links', 'ether_and_erc20_tokens_woocommerce_payment_gateway_actlinks', 10, 2 );

function ether_and_erc20_tokens_woocommerce_payment_gateway_complete_order($order_id) {
$payment_gateway = wc_get_payment_gateway_by_order( $order_id );
if (!$payment_gateway) {
$GLOBALS['ether-and-erc20-tokens-woocommerce-payment-gateway']->log("ether_and_erc20_tokens_woocommerce_payment_gateway_complete_order failed to get payment gateway for order: $order_id");
return;
}
$payment_gateway->complete_order($order_id);
}
add_action("ether_and_erc20_tokens_woocommerce_payment_gateway_complete_order", 'ether_and_erc20_tokens_woocommerce_payment_gateway_complete_order', 0, 1);

} else {
add_action( 'admin_init', 'epg_plugin_deactivate' );
add_action( 'admin_notices', 'epg_plugin_admin_notice_woocommerce' );
Expand Down
50 changes: 27 additions & 23 deletions js/ether-and-erc20-tokens-woocommerce-payment-gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,12 @@ function epg_sendTransaction_eth_step2_impl() {

function epg_show_wait_icon() {
jQuery('#epg-spinner').addClass('is-active');
jQuery('#epg-alert').removeClass('hidden');
jQuery('#epg-alert').removeAttr('hidden');
// jQuery('#epg-alert').removeClass('hidden');
// jQuery('#epg-alert').removeAttr('hidden');

jQuery('#epg-ether-spinner').addClass('is-active');
jQuery('#epg-ether-alert').removeClass('hidden');
jQuery('#epg-ether-alert').removeAttr('hidden');
// jQuery('#epg-ether-alert').removeClass('hidden');
// jQuery('#epg-ether-alert').removeAttr('hidden');

jQuery('#epg-token').attr('disabled', 'disabled');

Expand All @@ -745,12 +745,12 @@ function epg_hide_wait_icon(step) {
step = epg_get_step_number();
}
jQuery('#epg-spinner').removeClass('is-active');
jQuery('#epg-alert').addClass('hidden');
jQuery('#epg-alert').attr('hidden', ' hidden');
// jQuery('#epg-alert').addClass('hidden');
// jQuery('#epg-alert').attr('hidden', ' hidden');

jQuery('#epg-ether-spinner').removeClass('is-active');
jQuery('#epg-ether-alert').addClass('hidden');
jQuery('#epg-ether-alert').attr('hidden', ' hidden');
// jQuery('#epg-ether-alert').addClass('hidden');
// jQuery('#epg-ether-alert').attr('hidden', ' hidden');

jQuery('#epg-token').removeAttr('disabled');

Expand Down Expand Up @@ -1013,7 +1013,7 @@ function epg_pay_ether() {
if ('undefined' === typeof window.epg['web3metamask']) {
return;
}
if (!jQuery('#epg-ether-alert').hasClass('hidden') && !jQuery('#epg-ether-alert').is('[hidden]')) {
if (jQuery('#epg-ether-spinner').hasClass('is-active') || jQuery('#epg-spinner').hasClass('is-active')) {
// do not proceed if some task is in progress
return false;
}
Expand Down Expand Up @@ -1196,7 +1196,11 @@ function epg_copyAddress(e) {
var $temp = jQuery("<input>");
jQuery("body").append($temp);

var id = jQuery(e.target).data("input-id");
var target = e.target;
if ("BUTTON" !== e.target.tagName) {
target = target.parentElement;
}
var id = jQuery(target).data("input-id");
console.log("Copy from: ", id);

var value = jQuery("#" + id).val();
Expand Down Expand Up @@ -1341,7 +1345,7 @@ function epg_initWizard(cb) {
},
onPrevious: function(tab, navigation, index) {
console.log('prev: ' + index);
if (!jQuery('#epg-alert').hasClass('hidden') && !jQuery('#epg-alert').is('[hidden]')) {
if (jQuery('#epg-ether-spinner').hasClass('is-active') || jQuery('#epg-spinner').hasClass('is-active')) {
// do not change tab if some task is in progress
return false;
}
Expand All @@ -1351,7 +1355,7 @@ function epg_initWizard(cb) {
},
onNext: function(tab, navigation, index) {
console.log('next: ' + index);
if (!jQuery('#epg-alert').hasClass('hidden') && !jQuery('#epg-alert').is('[hidden]')) {
if (jQuery('#epg-ether-spinner').hasClass('is-active') || jQuery('#epg-spinner').hasClass('is-active')) {
// do not change tab if some task is in progress
return false;
}
Expand Down Expand Up @@ -1611,17 +1615,17 @@ jQuery(document).ready(function () {
});
}

// https://stackoverflow.com/a/19538231/4256005
window.addEventListener("beforeunload", function (e) {
if (!jQuery('#epg-ether-alert').hasClass('hidden') && !jQuery('#epg-ether-alert').is('[hidden]')) {
// some task is in progress

var confirmationMessage = window.epg.str_page_unload_text;

(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome
}
});
// // https://stackoverflow.com/a/19538231/4256005
// window.addEventListener("beforeunload", function (e) {
// if (jQuery('#epg-ether-spinner').hasClass('is-active') || jQuery('#epg-spinner').hasClass('is-active')) {
// // some task is in progress
//
// var confirmationMessage = window.epg.str_page_unload_text;
//
// (e || window.event).returnValue = confirmationMessage; //Gecko + IE
// return confirmationMessage; //Webkit, Safari, Chrome
// }
// });

// Init QR codes
jQuery('.epg-ether-canvas-qr1').qrcode({
Expand Down
4 changes: 2 additions & 2 deletions js/ether-and-erc20-tokens-woocommerce-payment-gateway.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8ba0fcb

Please sign in to comment.