diff --git a/assets/js/main.js b/assets/js/main.js index 2fa159e..1677d7a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,88 +1,88 @@ -(($) => { - - $(document).ready(() => { - let CryptoPayApp; - const modal = $(".dokan-cryptopay-modal"); - - $(window).on('click', function(e) { - if (e.target == modal[0]) { - modal.hide(); - if (CryptoPayApp.reset) { - CryptoPayApp.reset(); - } - } - }); - - $(document).on('click', '.pay-with-cryptopay', function(e) { - let key = $(this).data('key'); - let parent = $(this).closest('tr'); - let details = $(this).data('details'); - let currency = DokanCryptoPay.currency; - let approve = parent.find(".actions .button-group button:eq(0)"); - let amount = parseFloat(parent.find(".amount div").text().replace(/[^a-zA-Z0-9.,]/g, "").trim()); - - details = { - receiver: details.address, - network: JSON.parse(details.network), - currency: JSON.parse(details.currency), - } - - modal.show(); - - if (key == 'dokan_cryptopay') { - let order = { - amount, - currency, - } - - let params = { - receiver: details.receiver, - } - - if (!CryptoPayApp) { - CryptoPayApp = window.CryptoPayApp.start(order, params); - } else { - CryptoPayApp.reStart(order, params); - } - - CryptoPayApp.store.config.set('networks', [details.network]); - - window.CryptoPayApp.events.add('transactionReceived', ({transaction}) => { - approve.trigger('click'); - cpHelpers.successPopup(window.CryptoPayLang.transactionSent, ` - - ${window.CryptoPayLang.openInExplorer} - - `).then(() => { - modal.hide(); - }); - }); - } else if (key == 'cryptopay_lite') { - CryptoPayLite.networks = [ - details.network, - ]; - - CryptoPayApp = CryptoPayLite.startPayment({ - amount, - currency, - }, { - receiver: details.receiver, - }); - - CryptoPayLite.hooks.transactionSent = (n, tx) => { - approve.trigger('click'); - cpHelpers.successPopup(CryptoPayLite.lang.transactionSent, ` - - ${CryptoPayLite.lang.openInExplorer} - - `).then(() => { - modal.hide(); - CryptoPayApp.reset(); - }); - } - } - - }); - }); - +(($) => { + + $(document).ready(() => { + let CryptoPayApp; + const modal = $(".dokan-cryptopay-modal"); + + $(window).on('click', function(e) { + if (e.target == modal[0]) { + modal.hide(); + if (CryptoPayApp.reset) { + CryptoPayApp.reset(); + } + } + }); + + $(document).on('click', '.pay-with-cryptopay', function(e) { + let key = $(this).data('key'); + let parent = $(this).closest('tr'); + let details = $(this).data('details'); + let currency = DokanCryptoPay.currency; + let approve = parent.find(".actions .button-group button:eq(0)"); + let amount = parseFloat(parent.find(".amount div").text().replace(/[^a-zA-Z0-9.,]/g, "").trim()); + + details = { + receiver: details.address, + network: JSON.parse(details.network), + currency: JSON.parse(details.currency), + } + + modal.show(); + + if (key == 'dokan_cryptopay') { + let order = { + amount, + currency, + } + + let params = { + receiver: details.receiver, + } + + if (!CryptoPayApp) { + CryptoPayApp = window.CryptoPayApp.start(order, params); + } else { + CryptoPayApp.reStart(order, params); + } + + CryptoPayApp.store.config.set('networks', [details.network]); + + window.CryptoPayApp.events.add('transactionReceived', ({transaction}) => { + approve.trigger('click'); + cpHelpers.successPopup(window.CryptoPayLang.transactionSent, ` + + ${window.CryptoPayLang.openInExplorer} + + `).then(() => { + modal.hide(); + }); + }); + } else if (key == 'dokan_cryptopay_lite') { + CryptoPayLite.networks = [ + details.network, + ]; + + CryptoPayApp = CryptoPayLite.startPayment({ + amount, + currency, + }, { + receiver: details.receiver, + }); + + CryptoPayLite.hooks.transactionSent = (n, tx) => { + approve.trigger('click'); + cpHelpers.successPopup(CryptoPayLite.lang.transactionSent, ` + + ${CryptoPayLite.lang.openInExplorer} + + `).then(() => { + modal.hide(); + CryptoPayApp.reset(); + }); + } + } + + }); + }); + })(jQuery); \ No newline at end of file diff --git a/classes/DokanCryptoPayWithdrawal.php b/classes/DokanCryptoPayWithdrawal.php index 6f4d232..6035795 100644 --- a/classes/DokanCryptoPayWithdrawal.php +++ b/classes/DokanCryptoPayWithdrawal.php @@ -2,6 +2,9 @@ declare(strict_types=1); +defined('ABSPATH') || exit; + +// @phpcs:disable PSR1.Files.SideEffects // @phpcs:disable Generic.Files.InlineHTML // @phpcs:disable Generic.Files.LineLength @@ -306,6 +309,7 @@ function jsonStringToObject(str) { return null; } } + function getCustomPaymentDetails(details, method, data) { const url = window.location.href; const regex = /[?&]status=(\w+)/; @@ -347,7 +351,13 @@ function getCustomPaymentDetails(details, method, data) { return details; } - dokan.hooks.addFilter('dokan_get_payment_details', 'getCustomPaymentDetails', getCustomPaymentDetails, 33, 3); + dokan.hooks.addFilter( + 'dokan_get_payment_details', + 'getCustomPaymentDetails', + getCustomPaymentDetails, + 33, + 3 + ); \n" "Language-Team: \n" @@ -13,30 +13,30 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Loco https://localise.biz/\n" -"X-Loco-Version: 2.6.4; wp-6.2.2\n" +"X-Loco-Version: 2.6.6; wp-6.4.2\n" "X-Domain: dokan-cryptopay" #. Description of the plugin msgid "Add custom cryptocurrency withdrawal method to Dokan plugin" msgstr "" -#: classes/DokanCryptoPayWithdrawal.php:172 +#: classes/DokanCryptoPayWithdrawal.php:189 msgid "Address" msgstr "" #. Author of the plugin -msgid "BeycanPress" +msgid "BeycanPress LLC" msgstr "" -#: index.php:57 +#: dokan-cryptopay-withdrawal.php:40 dokan-cryptopay-withdrawal.php:84 msgid "clicking here" msgstr "" -#: index.php:32 +#: dokan-cryptopay-withdrawal.php:55 msgid "CryptoPay" msgstr "" -#: index.php:34 +#: dokan-cryptopay-withdrawal.php:58 msgid "CryptoPay Lite" msgstr "" @@ -44,7 +44,7 @@ msgstr "" msgid "Dokan - CryptoPay Withdrawal" msgstr "" -#: index.php:57 +#: dokan-cryptopay-withdrawal.php:84 #, php-format msgid "" "Dokan - CryptoPay Withdrawal: This plugin is an extra feature plugin so it " @@ -52,24 +52,32 @@ msgid "" "CryptoPay by %s." msgstr "" +#: dokan-cryptopay-withdrawal.php:40 +#, php-format +msgid "" +"Dokan - CryptoPay Withdrawal: This plugin is an extra feature plugin so it " +"cannot do anything on its own. It needs Dokan to work. You can buy download " +"Dokan by %s." +msgstr "" + #. Author URI of the plugin msgid "https://beycanpress.com" msgstr "" #. URI of the plugin -msgid "https://beycanpress.com/cryptopay" +msgid "https://beycanpress.com/cryptopay/" msgstr "" -#: classes/DokanCryptoPayWithdrawal.php:323 -#: classes/DokanCryptoPayWithdrawal.php:324 +#: classes/DokanCryptoPayWithdrawal.php:340 +#: classes/DokanCryptoPayWithdrawal.php:341 #, php-format msgid "Pay with %s" msgstr "" -#: classes/DokanCryptoPayWithdrawal.php:156 +#: classes/DokanCryptoPayWithdrawal.php:173 msgid "Payment currency" msgstr "" -#: classes/DokanCryptoPayWithdrawal.php:140 +#: classes/DokanCryptoPayWithdrawal.php:157 msgid "Payment network" msgstr "" diff --git a/readme.txt b/readme.txt index fdc147d..9ee39f7 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: BeycanPress Tags: Bitcoin, Ethereum, Binance Smart Chain, Blockchain, Networks, Cryptocurrency, Payments, Gateway, WordPress, Dokan Requires at least: 5.0 Tested up to: 6.4.2 -Requires PHP: 7.4 -Stable Tag: 1.0.1 -Version: 1.0.1 +Requires PHP: 8.1 +Stable Tag: 1.0.2 +Version: 1.0.2 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.2 = +* Updated: Compatibility due to updates in CryptoPay 2.1.0 + = 1.0.1 = *Improved: For CryptoPay 2.0.0