Skip to content

Commit

Permalink
Merge pull request #1 from BeycanPress/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
BeycanDeveloper committed Jan 30, 2024
2 parents 26f22b2 + 1a90fba commit 96546ba
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 106 deletions.
174 changes: 87 additions & 87 deletions 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, `
<a href="${transaction.getUrl()}" target="_blank">
${window.CryptoPayLang.openInExplorer}
</a>
`).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, `
<a href="${tx.getUrl()}" target="_blank">
${CryptoPayLite.lang.openInExplorer}
</a>
`).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, `
<a href="${transaction.getUrl()}" target="_blank">
${window.CryptoPayLang.openInExplorer}
</a>
`).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, `
<a href="${tx.getUrl()}" target="_blank">
${CryptoPayLite.lang.openInExplorer}
</a>
`).then(() => {
modal.hide();
CryptoPayApp.reset();
});
}
}

});
});

})(jQuery);
12 changes: 11 additions & 1 deletion classes/DokanCryptoPayWithdrawal.php
Expand Up @@ -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

Expand Down Expand Up @@ -306,6 +309,7 @@ function jsonStringToObject(str) {
return null;
}
}

function getCustomPaymentDetails(details, method, data) {
const url = window.location.href;
const regex = /[?&]status=(\w+)/;
Expand Down Expand Up @@ -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
);
</script>
<?php
}
Expand Down
6 changes: 4 additions & 2 deletions dokan-cryptopay-withdrawal.php
Expand Up @@ -2,13 +2,15 @@

declare(strict_types=1);

defined('ABSPATH') || exit;

// @phpcs:disable PSR1.Files.SideEffects
// @phpcs:disable PSR12.Files.FileHeader
// @phpcs:disable Generic.Files.LineLength

/**
* Plugin Name: Dokan - CryptoPay Withdrawal
* Version: 1.0.1
* Version: 1.0.2
* Plugin URI: https://beycanpress.com/cryptopay/
* Description: Add custom cryptocurrency withdrawal method to Dokan plugin
* Author: BeycanPress LLC
Expand All @@ -27,7 +29,7 @@
use BeycanPress\CryptoPayLite\Loader as LiteLoader;

define('DOKAN_CRYPTOPAY_FILE', __FILE__);
define('DOKAN_CRYPTOPAY_VERSION', '1.0.1');
define('DOKAN_CRYPTOPAY_VERSION', '1.0.2');
define('DOKAN_CRYPTOPAY_URL', plugin_dir_url(__FILE__));

add_action('plugins_loaded', function (): void {
Expand Down
34 changes: 21 additions & 13 deletions dokan-cryptopay.pot → languages/dokan-cryptopay.pot
Expand Up @@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Dokan - CryptoPay Withdrawal\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-05 06:15+0000\n"
"POT-Creation-Date: 2024-01-24 11:47+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
Expand All @@ -13,63 +13,71 @@ 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 ""

#. Name of the plugin
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 "
"cannot do anything on its own. It needs CryptoPay to work. You can buy "
"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 ""
9 changes: 6 additions & 3 deletions readme.txt
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 96546ba

Please sign in to comment.