diff --git a/assets/css/main.css b/assets/css/main.css deleted file mode 100644 index 01c45ee..0000000 --- a/assets/css/main.css +++ /dev/null @@ -1,23 +0,0 @@ -.dokan-cryptopay-modal { - width: 100%; - height: 100%; - position: fixed; - top: 0; - left: 0; - z-index: 999999; - background-color: rgba(0, 0, 0, 0.5); - display: none; -} - -.dokan-cryptopay-modal .dokan-cryptopay-modal-content { - width: auto; - height: auto; - background-color: #fff; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - padding: 20px; - border-radius: 8px; - min-width: 400px; -} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js index ffc0447..ed5e156 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -3,20 +3,15 @@ $(document).ready(() => { let CryptoPayApp; const __ = wp.i18n.__; - const modal = $(".dokan-cryptopay-modal"); - $(window).on('click', function(e) { - if (e.target == modal[0]) { - modal.hide(); - } - }); - - $(document).on('click', '.pay-with-cryptopay', function(e) { + $(document).on('click', '.pay-with-cryptopay', async function() { let key = $(this).data('key'); let parent = $(this).closest('tr'); let details = $(this).data('details'); let currency = DokanCryptoPay.currency; + let helpers = window.cpHelpers ?? window.cplHelpers; let approve = parent.find(".actions .button-group button:eq(0)"); + const modal = window.CryptoPayApp?.modal ?? window.CryptoPayLiteApp?.modal let amount = parseFloat(parent.find(".amount div").text().replace(/[^a-zA-Z0-9.,]/g, "").trim()); details = { @@ -25,8 +20,6 @@ currency: JSON.parse(details.currency), } - modal.show(); - if (key == 'dokan_cryptopay') { let order = { amount, @@ -40,23 +33,25 @@ if (!CryptoPayApp) { CryptoPayApp = window.CryptoPayApp.start(order, params); } else { - CryptoPayApp.reStart(order, params); + await CryptoPayApp.reStart(order, params); } + modal.open(); + CryptoPayApp.store.config.set('networks', [details.network]); window.CryptoPayApp.events.add('transactionReceived', ({transaction}) => { approve.trigger('click'); $(this).prop('disabled', true) $(this).text(__('Processing...')) - cpHelpers.successPopup(window.CryptoPayLang.transactionSent, ` + helpers.successPopup(window.CryptoPayLang.transactionSent, ` ${window.CryptoPayLang.openInExplorer} `).then(() => { - modal.hide(); + modal.close(); }); - }); + }, 'dokan'); } else if (key == 'dokan_cryptopay_lite') { let order = { amount, @@ -70,23 +65,25 @@ if (!CryptoPayApp) { CryptoPayApp = window.CryptoPayLiteApp.start(order, params); } else { - CryptoPayApp.reStart(order, params); + await CryptoPayApp.reStart(order, params); } + modal.open(); + CryptoPayApp.store.config.set('networks', [details.network]); window.CryptoPayLiteApp.events.add('transactionReceived', ({transaction}) => { approve.trigger('click'); $(this).prop('disabled', true) $(this).text(__('Processing...')) - cplHelpers.successPopup(window.CryptoPayLiteLang.transactionSent, ` + helpers.successPopup(window.CryptoPayLiteLang.transactionSent, ` ${window.CryptoPayLiteLang.openInExplorer} `).then(() => { - modal.hide(); + modal.close(); }); - }); + }, 'dokan'); } }); diff --git a/classes/DokanCryptoPayWithdrawal.php b/classes/DokanCryptoPayWithdrawal.php index ba9cdfb..aa2406a 100644 --- a/classes/DokanCryptoPayWithdrawal.php +++ b/classes/DokanCryptoPayWithdrawal.php @@ -66,6 +66,7 @@ public function __construct(string $title, string $key) if ('dokan_cryptopay' == $this->key) { Helpers::registerIntegration($this->key); + Hook::addFilter('mode_' . $this->key, fn () => 'network'); Hook::addFilter('apply_discount_' . $this->key, '__return_false'); Hook::addFilter('receiver_' . $this->key, function (string $receiver, object $data) { if ($data->getParams()->get('receiver')) { @@ -76,6 +77,7 @@ public function __construct(string $title, string $key) }, 10, 2); } else { LiteHelpers::registerIntegration($this->key); + LiteHook::addFilter('mode_' . $this->key, fn () => 'network'); LiteHook::addFilter('apply_discount_' . $this->key, '__return_false'); LiteHook::addFilter('receiver_' . $this->key, function (string $receiver, object $data) { if ($data->getParams()->get('receiver')) { @@ -410,9 +412,9 @@ function getCustomPaymentDetails(details, method, data) { public function runCryptoPay(): string { if ('dokan_cryptopay' == $this->key) { - return (new Payment($this->key))->setConfirmation(false)->html(); + return (new Payment($this->key))->setConfirmation(false)->modal(); } else { - return (new LitePayment($this->key))->setConfirmation(false)->html(); + return (new LitePayment($this->key))->setConfirmation(false)->modal(); } } } diff --git a/cryptopay-withdrawal-for-dokan.php b/cryptopay-withdrawal-for-dokan.php index 12315f8..0c47e2b 100644 --- a/cryptopay-withdrawal-for-dokan.php +++ b/cryptopay-withdrawal-for-dokan.php @@ -10,7 +10,7 @@ /** * Plugin Name: CryptoPay Withdrawal for Dokan - * Version: 1.0.5 + * Version: 1.0.6 * Plugin URI: https://beycanpress.com/cryptopay/ * Description: Add custom cryptocurrency withdrawal method to Dokan plugin * Author: BeycanPress LLC @@ -20,7 +20,7 @@ * Text Domain: dokan-cryptopay * Tags: Cryptopay, Cryptocurrency, WooCommerce, WordPress, MetaMask, Trust, Binance, Wallet, Ethereum, Bitcoin, Binance smart chain, Payment, Plugin, Gateway, Moralis, Converter, API, coin market cap, CMC * Requires at least: 5.0 - * Tested up to: 6.5.5 + * Tested up to: 6.6 * Requires PHP: 8.1 */ @@ -29,7 +29,7 @@ use BeycanPress\CryptoPayLite\Loader as LiteLoader; define('DOKAN_CRYPTOPAY_FILE', __FILE__); -define('DOKAN_CRYPTOPAY_VERSION', '1.0.3'); +define('DOKAN_CRYPTOPAY_VERSION', '1.0.6'); define('DOKAN_CRYPTOPAY_URL', plugin_dir_url(__FILE__)); define('DOKAN_CRYPTOPAY_PATH', plugin_dir_path(__FILE__)); @@ -70,30 +70,20 @@ 'currency' => get_woocommerce_currency(), 'apiUrl' => home_url('/wp-json/dokan/v1/withdraw/') ]); - - wp_enqueue_style('dokan-cryptopay', plugin_dir_url(__FILE__) . 'assets/css/main.css', [], DOKAN_CRYPTOPAY_VERSION); }); add_action('admin_footer', function () use ($gateway): void { - echo ' -
-
- ' . - wp_kses( - $gateway->runCryptoPay(), - [ - 'div' => [ - 'id' => [], - 'class' => [], - 'style' => [], - 'data-*' => [], - 'data-loading' => [] - ], - ] - ) - . ' -
-
- '; + echo wp_kses( + $gateway->runCryptoPay(), + [ + 'div' => [ + 'id' => [], + 'class' => [], + 'style' => [], + 'data-*' => [], + 'data-loading' => [] + ], + ] + ); }); } } else { diff --git a/readme.txt b/readme.txt index c68ff9e..ee7ea9f 100644 --- a/readme.txt +++ b/readme.txt @@ -2,10 +2,10 @@ Contributors: BeycanPress Tags: Bitcoin, Ethereum, Cryptocurrency, Payments, Dokan Requires at least: 5.0 -Tested up to: 6.5.5 +Tested up to: 6.6 Requires PHP: 8.1 -Stable Tag: 1.0.5 -Version: 1.0.5 +Stable Tag: 1.0.6 +Version: 1.0.6 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -44,6 +44,9 @@ You can easily translate with Loco translate. == Changelog == += 1.0.6 = +* Fixed: Configure for new versions + = 1.0.5 = * Fixed: Withdrawal action process