Skip to content

Commit c365404

Browse files
author
Ariano Ângelo
committed
v4.0.7 - Minor bugfixes
- Minor fixes - UI Improvements - Disable QR Code with value in certain currencies due to some wallets not supporting it
1 parent 045b98c commit c365404

7 files changed

Lines changed: 181 additions & 97 deletions

File tree

CryptAPI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
Plugin Name: CryptAPI Payment Gateway for WooCommerce
55
Plugin URI: https://github.com/cryptapi/woocommerce-cryptapi
66
Description: Accept cryptocurrency payments on your WooCommerce website
7-
Version: 4.0.2
7+
Version: 4.0.7
88
Requires at least: 4.0
9-
Tested up to: 5.9
9+
Tested up to: 5.9.1
1010
WC requires at least: 2.4
1111
WC tested up to: 6.2
1212
Requires PHP: 5.5

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,20 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
184184
#### 4.0.2
185185
* Minor fixes
186186

187+
#### 4.0.3
188+
* Minor fixes
189+
190+
#### 4.0.4
191+
* Minor fixes
192+
193+
#### 4.0.5
194+
* UI Improvements
195+
196+
#### 4.0.6
197+
* Disable QR Code with value in certain currencies due to some wallets not supporting it
198+
199+
#### 4.0.7
200+
* Minor fixes
201+
187202
### Upgrade Notice
188203
* No breaking changes

controllers/CryptAPI.php

Lines changed: 118 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,17 @@ function init_form_fields()
228228
'default' => 'none',
229229
'options' => array(
230230
'0.05' => '5%',
231+
'0.048' => '4.8%',
232+
'0.045' => '4.5%',
233+
'0.042' => '4.2%',
231234
'0.04' => '4%',
235+
'0.038' => '3.8%',
236+
'0.035' => '3.5%',
237+
'0.032' => '3.2%',
232238
'0.03' => '3%',
239+
'0.028' => '2.8%',
240+
'0.025' => '2.5%',
241+
'0.022' => '2.2%',
233242
'0.02' => '2%',
234243
'0.018' => '1.8%',
235244
'0.015' => '1.5%',
@@ -268,8 +277,8 @@ function init_form_fields()
268277
'type' => 'select',
269278
'default' => 'ammount',
270279
'options' => array(
271-
'ammount' => __('Default Ammount', 'cryptapi'),
272280
'without_ammount' => __('Default Without Ammount', 'cryptapi'),
281+
'ammount' => __('Default Ammount', 'cryptapi'),
273282
'hide_ammount' => __('Hide Ammount', 'cryptapi'),
274283
'hide_without_ammount' => __('Hide Without Ammount', 'cryptapi'),
275284
),
@@ -372,7 +381,7 @@ function payment_fields()
372381
$addr = $this->{$val . '_address'};
373382
if (!empty($addr)) { ?>
374383
<option value="<?php echo $val; ?>" <?php
375-
if(!empty($selected) && $selected === $val) {
384+
if (!empty($selected) && $selected === $val) {
376385
echo " selected='true'";
377386
}
378387
?>> <?php echo __('Pay with', 'cryptapi') . ' ' . WC_CryptAPI_Gateway::$COIN_OPTIONS[$val] ?></option>
@@ -499,43 +508,39 @@ function process_payment($order_id)
499508

500509
function validate_payment()
501510
{
502-
try {
503-
$data = CryptAPI\Helper::process_callback($_GET);
504-
$order = new WC_Order($data['order_id']);
511+
$data = CryptAPI\Helper::process_callback($_GET);
512+
$order = new WC_Order($data['order_id']);
505513

506-
if ($order->is_paid() || $order->get_status() === 'cancelled' || $data['nonce'] != $order->get_meta('cryptapi_nonce')) {
507-
die("*ok*");
508-
}
514+
if ($order->is_paid() || $order->get_status() === 'cancelled' || $data['nonce'] != $order->get_meta('cryptapi_nonce')) {
515+
die("*ok*");
516+
}
509517

510-
$paid = floatval($order->get_meta('cryptpi_paid')) + floatval($data['value_coin']);
511-
$crypto_coin = strtoupper($order->get_meta('cryptapi_currency'));
518+
$paid = floatval($order->get_meta('cryptpi_paid')) + floatval($data['value_coin']);
519+
$crypto_coin = strtoupper($order->get_meta('cryptapi_currency'));
512520

513-
if (!$data['pending']) {
514-
$order->add_meta_data('cryptapi_paid', $paid);
515-
}
521+
if (!$data['pending']) {
522+
$order->add_meta_data('cryptapi_paid', $paid);
523+
}
516524

517-
if ($paid >= $order->get_meta('cryptapi_total')) {
518-
if ($data['pending']) {
519-
$order->add_meta_data('cryptapi_pending', "1");
520-
} else {
521-
$order->delete_meta_data('cryptapi_pending');
522-
$order->payment_complete($data['address_in']);
523-
}
525+
if ($paid >= $order->get_meta('cryptapi_total')) {
526+
if ($data['pending']) {
527+
$order->add_meta_data('cryptapi_pending', "1");
528+
} else {
529+
$order->delete_meta_data('cryptapi_pending');
530+
$order->payment_complete($data['address_in']);
524531
}
532+
}
525533

526-
$order->add_order_note(
527-
($data['pending'] ? '[PENDING]' : '') .
528-
__('User sent a payment of', 'cryptapi') . ' ' .
529-
$data['value_coin'] . ' ' . $crypto_coin .
530-
'. TXID: ' . $data['txid_in']
531-
);
534+
$order->add_order_note(
535+
($data['pending'] ? '[PENDING]' : '') .
536+
__('User sent a payment of', 'cryptapi') . ' ' .
537+
$data['value_coin'] . ' ' . $crypto_coin .
538+
'. TXID: ' . $data['txid_in']
539+
);
532540

533-
$order->save_meta_data();
541+
$order->save_meta_data();
534542

535-
die("*ok*");
536-
} catch (Exception $e) {
537-
die($e->getMessage());
538-
}
543+
die("*ok*");
539544
}
540545

541546
function order_status()
@@ -591,6 +596,22 @@ function thankyou_page($order_id)
591596
wp_enqueue_script('ca-payment', CRYPTAPI_PLUGIN_URL . 'static/payment.js', array(), CRYPTAPI_PLUGIN_VERSION, true);
592597
wp_add_inline_script('ca-payment', "jQuery(function() {let ajax_url = '{$ajax_url}'; setTimeout(function(){check_status(ajax_url)}, 500)})");
593598
wp_enqueue_style('ca-loader-css', CRYPTAPI_PLUGIN_URL . 'static/cryptapi.css', false, CRYPTAPI_PLUGIN_VERSION);
599+
600+
$allowed_to_value = array(
601+
'btc',
602+
'eth',
603+
'bch',
604+
'ltc',
605+
'miota',
606+
'xml',
607+
'trx',
608+
);
609+
610+
$crypto_allowed_value = false;
611+
612+
if (in_array($crypto_coin, $allowed_to_value, true)) {
613+
$crypto_allowed_value = true;
614+
}
594615
?>
595616
<div class="ca_payment-panel<?php
596617
if ($color_scheme == 'auto') {
@@ -613,61 +634,82 @@ function thankyou_page($order_id)
613634
echo 'display: none';
614635
}
615636
?>; width: <?php echo intval($this->qrcode_size) + 20; ?>px;">
616-
<div class="inner-wrapper">
617-
<figure>
637+
<?php
638+
if ($crypto_allowed_value == true) {
639+
?>
640+
<div class="inner-wrapper">
641+
<figure>
642+
<?php
643+
if ($qr_code_setting != 'hide_ammount') {
644+
?>
645+
<img class="ca_qrcode no_value" <?php
646+
if ($qr_code_setting == 'ammount') {
647+
echo 'style="display:none;"';
648+
}
649+
?> src="data:image/png;base64,<?php echo $qr_code_img; ?>" alt="<?php echo __('QR Code without value', 'cryptapi'); ?>"/>
650+
<?php
651+
}
652+
if ($qr_code_setting != 'hide_without_ammount') {
653+
?>
654+
<img class="ca_qrcode value" <?php
655+
if ($qr_code_setting == 'without_ammount') {
656+
echo 'style="display:none;"';
657+
}
658+
?> src="data:image/png;base64,<?php echo $qr_code_img_value; ?>"
659+
alt="<?php echo __('QR Code with value', 'cryptapi'); ?>"/>
660+
<?php
661+
}
662+
?>
663+
</figure>
618664
<?php
619-
if ($qr_code_setting != 'hide_ammount') {
665+
if ($qr_code_setting != 'hide_ammount' && $qr_code_setting != 'hide_without_ammount') {
620666
?>
621-
<img class="ca_qrcode no_value" <?php
622-
if ($qr_code_setting == 'without_ammount') {
623-
echo 'style="display:none;"';
624-
}
625-
?> src="data:image/png;base64,<?php echo $qr_code_img; ?>" alt="<?php echo __('QR Code without value', 'cryptapi'); ?>"/>
667+
<div class="ca_qrcode_buttons">
626668
<?php
627-
}
628-
if ($qr_code_setting != 'hide_without_ammount') {
629-
?>
630-
<img class="ca_qrcode value" <?php
631-
if ($qr_code_setting == 'ammount') {
632-
echo 'style="display:none;"';
669+
if ($qr_code_setting != 'hide_without_ammount') {
670+
?>
671+
<button class="ca_qrcode_btn no_value<?php
672+
if ($qr_code_setting == 'without_ammount') {
673+
echo ' active';
674+
}
675+
?>" aria-label="<?php echo __('Show QR Code without value', 'cryptapi'); ?>">
676+
<?php echo __('ADDRESS', 'cryptapi'); ?>
677+
</button>
678+
<?php
679+
}
680+
if ($qr_code_setting != 'hide_ammount') {
681+
?>
682+
<button class="ca_qrcode_btn value<?php
683+
if ($qr_code_setting == 'ammount') {
684+
echo ' active';
685+
}
686+
?>" aria-label="<?php echo __('Show QR Code with value', 'cryptapi'); ?>">
687+
<?php echo __('WITH AMMOUNT', 'cryptapi'); ?>
688+
</button>
689+
</div>
690+
<?php
633691
}
634-
?> src="data:image/png;base64,<?php echo $qr_code_img_value; ?>"
635-
alt="<?php echo __('QR Code with value', 'cryptapi'); ?>"/>
636-
<?php
637692
}
638693
?>
639-
</figure>
694+
</div>
640695
<?php
641-
if ($qr_code_setting != 'hide_ammount' && $qr_code_setting != 'hide_without_ammount') {
642-
?>
696+
} else {
697+
?>
698+
<div class="inner-wrapper">
699+
<figure>
700+
<img class="ca_qrcode no_value" src="data:image/png;base64,<?php echo $qr_code_img; ?>"
701+
alt="<?php echo __('QR Code without value', 'cryptapi'); ?>"/>
702+
</figure>
643703
<div class="ca_qrcode_buttons">
644-
<?php
645-
if ($qr_code_setting != 'hide_without_ammount') {
646-
?>
647-
<button class="ca_qrcode_btn no_value<?php
648-
if ($qr_code_setting == 'ammount') {
649-
echo ' active';
650-
}
651-
?>" aria-label="<?php echo __('Show QR Code without value', 'cryptapi'); ?>">
704+
<button class="ca_qrcode_btn no_value active" aria-label="<?php echo __('Show QR Code without value', 'cryptapi'); ?>">
652705
<?php echo __('ADDRESS', 'cryptapi'); ?>
653706
</button>
654-
<?php
655-
}
656-
if ($qr_code_setting != 'hide_ammount') {
657-
?>
658-
<button class="ca_qrcode_btn value<?php
659-
if ($qr_code_setting == 'without_ammount') {
660-
echo ' active';
661-
}
662-
?>" aria-label="<?php echo __('Show QR Code with value', 'cryptapi'); ?>">
663-
<?php echo __('WITH AMMOUNT', 'cryptapi'); ?>
664-
</button>
665-
</div>
666-
<?php
667-
}
668-
}
669-
?>
670-
</div>
707+
</div>
708+
</div>
709+
710+
<?php
711+
}
712+
?>
671713
</div>
672714
<div class="ca_details_box">
673715
<div class="ca_details_text">

define.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

3-
define('CRYPTAPI_PLUGIN_VERSION', '4.0.2');
3+
define('CRYPTAPI_PLUGIN_VERSION', '4.0.7');
44
define('CRYPTAPI_PLUGIN_PATH', plugin_dir_path(__FILE__));
55
define('CRYPTAPI_PLUGIN_URL', plugin_dir_url(__FILE__));

readme.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: cryptapi
33
Tags: crypto payments, woocommerce, payment gateway, crypto, payment, pay with crypto, payment request, bitcoin, bnb, usdt, ethereum, monero, litecoin, bitcoin cash, shib, doge
44
Requires at least: 4.4
5-
Tested up to: 5.9
6-
Stable tag: 4.0.2
5+
Tested up to: 5.9.1
6+
Stable tag: 4.0.7
77
Requires PHP: 5.5
88
WC requires at least: 2.4
99
WC tested up to: 6.2
@@ -198,5 +198,20 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
198198
= 4.0.2 =
199199
* Minor fixes
200200

201+
= 4.0.3 =
202+
* Minor fixes
203+
204+
= 4.0.4 =
205+
* Minor fixes
206+
207+
= 4.0.5 =
208+
* UI Improvements
209+
210+
= 4.0.6 =
211+
* Disable QR Code with value in certain currencies due to some wallets not supporting it
212+
213+
= 4.0.7 =
214+
* Minor fixes
215+
201216
== Upgrade Notice ==
202217
* No breaking changes

0 commit comments

Comments
 (0)