Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha #12

Merged
merged 15 commits into from
Apr 30, 2024
7 changes: 4 additions & 3 deletions app/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@ public static function getWalletAddress(NetworkType $network): ?string
}

/**
* @return int
* @param string $code
* @return integer
*/
public static function getBlockConfirmationCount(): int
public static function getBlockConfirmationCount(string $code): int
{
return 0;
return self::getSetting($code . 'BlockConfirmationCount') ?? 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(string $pluginFile)
public function pluginActionLinks(array $links): array
{
// @phpcs:disable
$links[] = '<a href="https://beycanpress.com/product/cryptopay-all-in-one-cryptocurrency-payments-for-wordpress/?utm_source=lite_version&utm_medium=plugins_list" style="color: #389e38;font-weight: bold;" target="_blank">' . __('Buy Premium', 'cryptopay_lite') . '</a>';
$links[] = '<a href="https://beycanpress.com/chekcout/?add-to-cart=800&utm_source=lite_version&utm_medium=plugins_list" style="color: #389e38;font-weight: bold;" target="_blank">' . __('Buy Premium', 'cryptopay_lite') . '</a>';
$links[] = '<a href="' . admin_url('admin.php?page=cryptopay_lite_settings') . '">' . __('Settings', 'cryptopay_lite') . '</a>';
$links[] = '<a href="https://beycanpress.gitbook.io/cryptopay-docs/" target="_blank">' . __('Documentation', 'cryptopay_lite') . '</a>';
// @phpcs:enable
Expand Down
2 changes: 1 addition & 1 deletion app/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function init(NetworkType $network): InitType

// init data
$receiver = Helpers::getReceiver($this->data);
$blockConfirmationCount = Helpers::getBlockConfirmationCount();
$blockConfirmationCount = Helpers::getBlockConfirmationCount($network->getCode());

// just for pretty
$order = $this->data->getOrder();
Expand Down
10 changes: 10 additions & 0 deletions app/PluginHero/Helpers/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ public static function checkNonceField(?string $externalKey = null): bool

return @wp_verify_nonce(sanitize_text_field($_POST['nonce']), $key) ? true : false;
}

/**
* Get route paths
* @param string $route
* @return array<string>
*/
public static function getRoutePaths(string $route): array
{
return array_values(array_filter(explode('/', $route)));
}
}
1 change: 1 addition & 0 deletions app/PluginHero/Helpers/Feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public static function sendDeactivationInfoApiReal(): void
if (function_exists('curl_version')) {
try {
self::sendDeactivationInfo([
'reasonCode' => isset($_POST['reasonCode']) ? sanitize_text_field($_POST['reasonCode']) : null,
'reason' => isset($_POST['reason']) ? sanitize_text_field($_POST['reason']) : null,
'email' => isset($_POST['email']) ? sanitize_email($_POST['email']) : null,
]);
Expand Down
14 changes: 7 additions & 7 deletions app/PluginHero/templates/feedback.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(($) => {
if (!window.bpPhFeedbakcs) {
window.bpPhFeedbakcs = [];
if (!window.bpPhFeedbacks) {
window.bpPhFeedbacks = [];
}
$(document).ready(() => {

Expand All @@ -10,11 +10,11 @@
let modal = $(this);
let slug = modal.data('slug');

if (window.bpPhFeedbakcs.includes(slug)) {
if (window.bpPhFeedbacks.includes(slug)) {
return;
}

window.bpPhFeedbakcs.push(slug);
window.bpPhFeedbacks.push(slug);
let apiUrl = modal.data('api-url');
let pluginKey = modal.data('plugin-key');
let apiData = {
Expand All @@ -38,7 +38,7 @@
$('#'+pluginKey+'-feedback-modal').css('display', 'none');
});

let exlcludedForReasonBox = [
let excludedForReasonBox = [
pluginKey+'_temporary_deactivation',
pluginKey+'_premium_version',
];
Expand Down Expand Up @@ -90,7 +90,7 @@
return false;
}

if (!detail && !exlcludedForReasonBox.includes($('.'+pluginKey+'_deactivation_reason:checked').attr('id'))) {
if (!detail && !excludedForReasonBox.includes($('.'+pluginKey+'_deactivation_reason:checked').attr('id'))) {
alert('Please provide more information!');
return false;
}
Expand All @@ -104,7 +104,7 @@

$(document).on('change', '.'+pluginKey+'_deactivation_reason', function(e) {
e.preventDefault()
if (exlcludedForReasonBox.includes($(this).attr('id'))) {
if (excludedForReasonBox.includes($(this).attr('id'))) {
$('#'+pluginKey+'-feedback-modal-reason-detail').remove();
return;
}
Expand Down
12 changes: 7 additions & 5 deletions app/RestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public function __construct()
$this->currentUserId = Helpers::getCurrentUserId();

// set current user id for woocommerce process
add_filter('woocommerce_checkout_customer_id', function () {
wp_set_current_user($this->currentUserId);
return $this->currentUserId;
}, 11);
if ($this->currentUserId) {
add_filter('woocommerce_checkout_customer_id', function () {
wp_set_current_user($this->currentUserId);
return $this->currentUserId;
}, 11);
}

// create payment data
add_action('rest_pre_dispatch', [$this, 'middleware'], 10, 3);
Expand Down Expand Up @@ -106,7 +108,7 @@ public function getObjectParam(string $key): object
public function middleware(mixed $result, \WP_REST_Server $server, \WP_REST_Request $request): mixed
{
// check if request is cryptopay
if (false !== strpos($request->get_route(), 'cryptopay-lite')) {
if ('cryptopay-lite' === (Helpers::getRoutePaths($request->get_route())[0] ?? null)) {
if ($addon = $this->request->getParam('cp_addon')) {
try {
// check addon
Expand Down
3 changes: 2 additions & 1 deletion app/Services/Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static function verifyTransaction(TransactionType $transaction): ?bool
{
Helpers::debug('Verifying transaction...', 'INFO', $transaction->forDebug());

$code = $transaction->getCode();
$order = $transaction->getOrder();
$amount = $order->getPaymentAmount();
$currency = $order->getPaymentCurrency();
Expand All @@ -31,7 +32,7 @@ public static function verifyTransaction(TransactionType $transaction): ?bool
return null;
}

$confirmationCount = Helpers::getBlockConfirmationCount();
$confirmationCount = Helpers::getBlockConfirmationCount($code);
if (method_exists($transaction, 'getConfirmations') && $confirmationCount > 0) {
if ($transaction->getConfirmations() < $confirmationCount) {
return null;
Expand Down
12 changes: 8 additions & 4 deletions app/Settings/EvmChains.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EvmChains
*/
public static function initSettings(): void
{
$proMsg = '<div style="display:flex;align-items:center">' . sprintf(esc_html__('This is a pro feature => %s', 'cryptopay_lite'), '<a href="https://beycanpress.com/cryptopay/?utm_source=lite_version&utm_medium=plugin_settings" target="_blank" class="button" style="margin-left: 10px">' . __('Buy pro', 'cryptopay_lite') . '</a>') . '</div><br>';
$proMsg = '<div style="display:flex;align-items:center">' . sprintf(esc_html__('This is a premium feature => %s', 'cryptopay_lite'), '<a href="https://beycanpress.com/chekcout/?add-to-cart=800&utm_source=lite_version&utm_medium=plugin_settings" target="_blank" class="button" style="margin-left: 10px">' . __('Buy premium', 'cryptopay_lite') . '</a>') . '</div><br>';

if (Helpers::getSetting('evmchainsActivePassive') && '' == Helpers::getSetting('evmchainsWalletAddress')) {
Helpers::networkWillNotWorkMessage('EVM Chains');
Expand Down Expand Up @@ -59,21 +59,25 @@ public static function initSettings(): void
[
'id' => 'evmchainsBlockConfirmationCount',
'title' => esc_html__('Block confirmation count', 'cryptopay_lite'),
'type' => 'content',
'content' => $proMsg . esc_html__('Dynamic transaction confirmation value', 'cryptopay_lite')
'type' => 'number',
'default' => 10,
'sanitize' => function ($val) {
return absint($val);
}
],
[
'id' => 'evmchainsWallets',
'type' => 'content',
'title' => esc_html__('Wallets', 'cryptopay_lite'),
'help' => esc_html__('Specify the wallets you want to accept payments from.', 'cryptopay_lite'),
'content' => $proMsg . esc_html__('Specify the wallets you want to accept payments from.', 'cryptopay_lite')
'content' => $proMsg . esc_html__('Specify the wallets you want to accept payments from. WalletConnect and mobile support.', 'cryptopay_lite')
],
[
'id' => 'evmchainsNetworks',
'title' => esc_html__('Networks', 'cryptopay_lite'),
'help' => esc_html__('Specify the networks you want to accept payments from.', 'cryptopay_lite'),
'type' => 'fieldset',
'desc' => esc_html__('Unlimited and custom network support is only available in premium. As with MetaMask, you can add any EVM network you want with its information.', 'cryptopay_lite'),
'fields' => [
[
'id' => 'id_1',
Expand Down
10 changes: 6 additions & 4 deletions app/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
$this->createFeedbackPage($parent = Helpers::getPage('HomePage')->getSlug());
parent::__construct(esc_html__('Settings', 'cryptopay_lite'), $parent);

$proMsg = '<div style="display:flex;align-items:center">' . sprintf(esc_html__('This is a pro feature => %s', 'cryptopay_lite'), '<a href="https://beycanpress.com/cryptopay/?utm_source=lite_version&utm_medium=plugin_settings" target="_blank" class="button" style="margin-left: 10px">' . __('Buy pro', 'cryptopay_lite') . '</a>') . '</div><br>';
$proMsg = '<div style="display:flex;align-items:center">' . sprintf(esc_html__('This is a premium feature => %s', 'cryptopay_lite'), '<a href="https://beycanpress.com/chekcout/?add-to-cart=800&utm_source=lite_version&utm_medium=plugin_settings" target="_blank" class="button" style="margin-left: 10px">' . __('Buy premium', 'cryptopay_lite') . '</a>') . '</div><br>';

self::createSection([
'id' => 'generalSettings',
Expand Down Expand Up @@ -135,7 +135,7 @@ public function __construct()
'id' => 'bitcoinPayments',
'title' => esc_html__('Bitcoin payments', 'cryptopay_lite'),
'type' => 'content',
'content' => esc_html__('CryptoPay supports all EVM-based networks by default, but you can start accepting payments from other blockchain networks by purchasing extra network support.', 'cryptopay_lite') . CPL_BR2 . '<a href="https://beycanpress.com/our-plugins/?categoryId=88&utm_source=plugin_settings&utm_medium=bitcoin_payments&utm_campaign=buy_custom_networks" target="_blank">' . esc_html__('Buy custom network supports', 'cryptopay_lite') . '</a>'
'content' => esc_html__('CryptoPay supports all EVM-based networks by default, but you can start accepting payments from other blockchain networks by purchasing extra network support.', 'cryptopay_lite') . CPL_BR2 . '<a href="https://beycanpress.com/our-plugins/?categoryId=88&utm_source=plugin_settings&utm_medium=bitcoin_payments&utm_campaign=buy_custom_networks#categories" target="_blank">' . esc_html__('Buy custom network supports', 'cryptopay_lite') . '</a>' . CPL_BR2 . 'Bitcoin and all other network support is only available for Premium.'
],
]
]);
Expand Down Expand Up @@ -174,7 +174,9 @@ public function __construct()
'content' => 'Currently, in crypto payments, most people list prices in FIAT currencies, i.e. currencies such as USD, EUR. With the currency converter, we convert these currencies into the currency chosen by the user. By default the CryptoCompare API is available. If your token is listed on Coin Market Cap, Coin Gecko or DEXs. You can get suitable currency converter add-ons to get the price value of your token.
' . CPL_BR2 . '
<a href="https://beycanpress.gitbook.io/cryptopay-docs/currency-converter" target="_blank">' . esc_html__('Click for more information', 'cryptopay_lite') . '</a>
' . CPL_BR2 . '<a href="https://beycanpress.com/our-plugins/?categoryId=167&utm_source=plugin_settings&utm_medium=currency_converter&utm_campaign=buy_custom_converters" target="_blank">' . esc_html__('Buy custom converters', 'cryptopay_lite') . '</a>',
' . CPL_BR2 . '<a href="https://beycanpress.com/our-plugins/?categoryId=167&utm_source=plugin_settings&utm_medium=currency_converter&utm_campaign=buy_custom_converters#categories" target="_blank">' . esc_html__('Buy custom converters', 'cryptopay_lite') . '</a>
' . CPL_BR2 . '
All custom converters are available for premium only.',
'title' => esc_html__('What is a currency converter?', 'cryptopay_lite')
],
[
Expand Down Expand Up @@ -258,7 +260,7 @@ public function __construct()
'type' => 'content',
'dependency' => ['cronType', '==', 'server'],
'content' => '
<strong>API 1</strong>: ' . home_url('?rest_route=/cryptopay/verify-pending-transactions') . ' (GET, POST)
<strong>API 1</strong>: ' . home_url('?rest_route=/cryptopay-lite/verify-pending-transactions') . ' (GET, POST)

' . CPL_BR2 . '

Expand Down
14 changes: 7 additions & 7 deletions assets/js/feedback.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(($) => {
if (!window.bpPhFeedbakcs) {
window.bpPhFeedbakcs = [];
if (!window.bpPhFeedbacks) {
window.bpPhFeedbacks = [];
}
$(document).ready(() => {

Expand All @@ -10,11 +10,11 @@
let modal = $(this);
let slug = modal.data('slug');

if (window.bpPhFeedbakcs.includes(slug)) {
if (window.bpPhFeedbacks.includes(slug)) {
return;
}

window.bpPhFeedbakcs.push(slug);
window.bpPhFeedbacks.push(slug);
let apiUrl = modal.data('api-url');
let pluginKey = modal.data('plugin-key');
let apiData = {
Expand All @@ -38,7 +38,7 @@
$('#'+pluginKey+'-feedback-modal').css('display', 'none');
});

let exlcludedForReasonBox = [
let excludedForReasonBox = [
pluginKey+'_temporary_deactivation',
pluginKey+'_premium_version',
];
Expand Down Expand Up @@ -90,7 +90,7 @@
return false;
}

if (!detail && !exlcludedForReasonBox.includes($('.'+pluginKey+'_deactivation_reason:checked').attr('id'))) {
if (!detail && !excludedForReasonBox.includes($('.'+pluginKey+'_deactivation_reason:checked').attr('id'))) {
alert('Please provide more information!');
return false;
}
Expand All @@ -104,7 +104,7 @@

$(document).on('change', '.'+pluginKey+'_deactivation_reason', function(e) {
e.preventDefault()
if (exlcludedForReasonBox.includes($(this).attr('id'))) {
if (excludedForReasonBox.includes($(this).attr('id'))) {
$('#'+pluginKey+'-feedback-modal-reason-detail').remove();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions cryptopay-wc-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Plugin Name: CryptoPay Lite
* Version: 2.1.4
* Version: 2.1.5
* Plugin URI: https://beycanpress.com/cryptopay/
* Description: All In One Cryptocurrency Payments for WordPress
* Author: BeycanPress LLC
Expand All @@ -22,7 +22,7 @@
* Domain Path: /languages
* Tags: Cryptopay, Cryptocurrency, WooCommerce, WordPress, MetaMask, Trust, Binance, Wallet, Ethereum, Bitcoin, Binance smart chain, Payment, Plugin, Gateway
* Requires at least: 5.0
* Tested up to: 6.4.3
* Tested up to: 6.5.2
* Requires PHP: 8.1
*/

Expand Down
2 changes: 1 addition & 1 deletion languages/cryptopay_lite.pot
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ msgid "Buy premium"
msgstr ""

#: app/Settings/EvmChains.php:30 app/Settings/Settings.php:23
msgid "Buy pro"
msgid "Buy premium"
msgstr ""

#: app/Constants.php:85
Expand Down
14 changes: 9 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ WordPress Cryptocurrency Payment Gateway for WooCommerce by CryptoPay, With Cryp

As you know, virtual POS and many other payment methods deduct commission from you. The only commission here is the “gas” fee that blockchain networks charge. So the money will be transferred directly to your account. You can receive payments with all blockchain networks that have the RPC API and support the wallet that the user is currently using, and tokens and native currencies under these networks.

**Apart from that, here are the advantages that CryptoPay gives you:**
**Nonsense that CryptoPay doesn't have:**

* No 3rd party service
* You can start getting paid as soon as you install the plugin without having any 3rd party services to start with.
* No withdrawal limit, fee, date
* 1-2 business days and no weekend nonsense
* The money is in your account and in use on the same day
* As it is completely peer to peer, customers pay directly to your wallet
* No 1-2 business days and weekend nonsense
* There is no need to wait for weeks or wait to get paid as in the classic financing process
* No touching your money for to get commission
* Because we only charge per license

Are you ready to speed up the process of receiving WooCommerce crypto payments on WordPress with CryptoPay?

Expand Down Expand Up @@ -84,8 +88,7 @@ Are you ready to speed up the process of receiving WooCommerce crypto payments o

**Highlights:**

* Pay with multiple Blockchain network, Ethereum and all EVM based blockchain networks, Bitcoin, Solana, Tron Etc.
* You can receive payments via crypto wallets supported by the plugin and all blockchain networks supported by these wallets. (Currently, EVM Bases networks, Solana, Tron and Bitcoin support are available.) Payment support for many networks will be introduced over time.
* By default, EVM-based networks are supported. To receive payments from other networks such as Bitcoin, Solana and Tron, you need to purchase extra add-ons. You can accept payments from many Web3 wallets integrated for these networks. It is also available on networks that support address transfer (QR Code) payments.
* You can get pay with native money of blockchain networks or with tokens under these networks.
* You can receive payments in your own special currencies (tokens). It is enough to have a price list in one of the APIs you will see in the next article. For example Coin Market Cap and Coin Gecko
* The Crypto Compare API is currently provided. In addition, there are Coin Market Cap, Coin Gecko, Moralis and Pancake Swap API add-ons. Pancake Swap only supports BSC network while Moralis supports EVM based networks and Solana. Crypto Compare, Coin Market Cap and Coin Gecko support all currencies listed in it, regardless of network.
Expand All @@ -101,6 +104,7 @@ Are you ready to speed up the process of receiving WooCommerce crypto payments o
* Dark theme mode is available for your dark themes.
* With Loco Translate, you can easily translate into any language you want.
* You can easily move your settings with the backup system.
* Bitcoin Payment Gateway, Solana Payment Gateway, Ethereum Payment Gateway


Read documentation: **<a href="https://beycanpress.gitbook.io/cryptopay-docs/" target="_blank">Documentation</a>**
Expand Down
Loading
Loading