Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
BeycanDeveloper committed Jul 20, 2024
1 parent ea44d47 commit 5454e2e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 71 deletions.
23 changes: 0 additions & 23 deletions assets/css/main.css

This file was deleted.

33 changes: 15 additions & 18 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -25,8 +20,6 @@
currency: JSON.parse(details.currency),
}

modal.show();

if (key == 'dokan_cryptopay') {
let order = {
amount,
Expand All @@ -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, `
<a href="${transaction.getUrl()}" target="_blank">
${window.CryptoPayLang.openInExplorer}
</a>
`).then(() => {
modal.hide();
modal.close();
});
});
}, 'dokan');
} else if (key == 'dokan_cryptopay_lite') {
let order = {
amount,
Expand All @@ -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, `
<a href="${transaction.getUrl()}" target="_blank">
${window.CryptoPayLiteLang.openInExplorer}
</a>
`).then(() => {
modal.hide();
modal.close();
});
});
}, 'dokan');
}

});
Expand Down
6 changes: 4 additions & 2 deletions classes/DokanCryptoPayWithdrawal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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')) {
Expand Down Expand Up @@ -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();
}
}
}
40 changes: 15 additions & 25 deletions cryptopay-withdrawal-for-dokan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/

Expand All @@ -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__));

Expand Down Expand Up @@ -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 '
<div class="dokan-cryptopay-modal">
<div class="dokan-cryptopay-modal-content">
' .
wp_kses(
$gateway->runCryptoPay(),
[
'div' => [
'id' => [],
'class' => [],
'style' => [],
'data-*' => [],
'data-loading' => []
],
]
)
. '
</div>
</div>
';
echo wp_kses(
$gateway->runCryptoPay(),
[
'div' => [
'id' => [],
'class' => [],
'style' => [],
'data-*' => [],
'data-loading' => []
],
]
);
});
}
} else {
Expand Down
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down

0 comments on commit 5454e2e

Please sign in to comment.