Skip to content

Commit 7755dc3

Browse files
authored
Merge pull request #2 from arianoangelo/master
v3.1
2 parents fe47636 + cab6b9e commit 7755dc3

8 files changed

Lines changed: 198 additions & 91 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,12 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
141141
* Minor fixes
142142
* UI Improvements
143143

144-
#### Upgrade Notice
144+
#### 3.1
145+
* Support CryptAPI Pro
146+
* Minor fixes
147+
148+
#### 3.1.1
149+
* Minor fixes
150+
151+
== Upgrade Notice ==
145152
* No breaking changes

upload/admin/controller/extension/payment/cryptapi.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ public function index()
113113
$data['payment_cryptapi_title'] = $this->config->get('payment_cryptapi_title');
114114
}
115115

116+
if (isset($this->request->post['payment_cryptapi_api_key'])) {
117+
$data['payment_cryptapi_api_key'] = $this->request->post['payment_cryptapi_api_key'];
118+
} else {
119+
$data['payment_cryptapi_api_key'] = $this->config->get('payment_cryptapi_api_key');
120+
}
121+
116122
if (isset($this->request->post['payment_cryptapi_standard_geo_zone_id'])) {
117123
$data['payment_cryptapi_standard_geo_zone_id'] = $this->request->post['payment_cryptapi_standard_geo_zone_id'];
118124
} else {
@@ -176,6 +182,12 @@ public function index()
176182
$data['payment_cryptapi_qrcode'] = $this->config->get('payment_cryptapi_qrcode');
177183
}
178184

185+
if (isset($this->request->post['payment_cryptapi_qrcode_default'])) {
186+
$data['payment_cryptapi_qrcode_default'] = $this->request->post['payment_cryptapi_qrcode_default'];
187+
} else {
188+
$data['payment_cryptapi_qrcode_default'] = $this->config->get('payment_cryptapi_qrcode_default');
189+
}
190+
179191
if (isset($this->request->post['payment_cryptapi_qrcode_size'])) {
180192
$data['payment_cryptapi_qrcode_size'] = $this->request->post['payment_cryptapi_qrcode_size'];
181193
} else {

upload/admin/language/en-gb/extension/payment/cryptapi.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
$_['branding'] = 'Show CryptAPI logo and credits below the QR code';
3737

38+
$_['qrcode_default'] = 'Show QR Code';
3839
$_['qrcode'] = 'QR Code to show';
3940
$_['qrcode_size'] = 'QR Code size';
4041
$_['qrcode_without_ammount'] = 'Default Without Ammount';
@@ -69,13 +70,17 @@
6970
$_['error_permission'] = 'Warning: You do not have permission to modify the CryptAPI payment module';
7071

7172
// Help hints
72-
$_['help_cryptocurrencies'] = 'Select which coins do you wish to accept (Don\'t forget to paste your address in the respective field).';
73-
$_['help_cryptocurrency'] = 'Click the checkbox to enable ';
73+
$_['help_cryptocurrencies'] = 'If you are using CryptAPI Pro you can choose if setting the receiving addresses here bellow or in your CryptAPI Pro settings page.<br/>- In order to set the addresses on plugin settings, you need to select “Address Override” while creating the API key.<br/>- In order to set the addresses on CryptAPI Pro settings, you need to NOT select “Address Override” while creating the API key.';
74+
$_['help_cryptocurrency'] = 'Click the checkbox to enable the cryptocurrency';
7475

7576

7677
// Order page - payment tab
7778
$_['text_payment_info'] = 'Payment information';
7879

7980
$_['disable_conversion'] = 'Disable Conversion';
8081
$_['disable_conversion_warn_bold'] = 'Attention: This option will disable the price conversion for ALL cryptocurrencies!';
81-
$_['disable_conversion_warn'] = 'If you check this, pricing will not be converted from the currency of your shop to the cryptocurrency selected by the user, and users will be requested to pay the same value as shown on your shop, regardless of the cryptocurrency selected';
82+
$_['disable_conversion_warn'] = 'If you check this, pricing will not be converted from the currency of your shop to the cryptocurrency selected by the user, and users will be requested to pay the same value as shown on your shop, regardless of the cryptocurrency selected';
83+
84+
85+
$_['api_key'] = 'API Key';
86+
$_['api_key_info'] = "Insert here your CryptAPI Pro API Key. You can get one with CryptAPI Pro. Notice: If API permission 'Address Override' is not enabled you must set the address in the dashboard otherwise payments may fail.";

upload/admin/view/template/extension/payment/cryptapi.twig

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
>1.2%
195195
</option>
196196
<option value="0.01"
197-
{% if payment_cryptapi_fees == "0.01" %}
197+
{% if payment_cryptapi_fees == "0.01" or payment_cryptapi_fees is empty %}
198198
selected="selected"
199199
{% endif %}
200200
>1%
@@ -287,6 +287,25 @@
287287
{% if payment_cryptapi_qrcode_size is empty %}value="300" {% else %}value="{{ payment_cryptapi_qrcode_size }}"{% endif %}>
288288
</div>
289289
</div>
290+
<div class="form-group">
291+
<label class="col-sm-2 control-label" for="cryptapi_qrcode_default">
292+
{{ qrcode_default }}
293+
</label>
294+
<div class="col-sm-10">
295+
<select name="payment_cryptapi_qrcode_default" id="cryptapi_qrcode_default" class="form-control">
296+
{% if payment_cryptapi_qrcode_default is empty or payment_cryptapi_qrcode_default != '0' %}
297+
<option value="1" selected="selected">{{ text_enabled }}</option>
298+
<option value="0">{{ text_disabled }}</option>
299+
{% elseif payment_cryptapi_branding == 1 %}
300+
<option value="1" selected="selected">{{ text_enabled }}</option>
301+
<option value="0">{{ text_disabled }}</option>
302+
{% elseif payment_cryptapi_branding == 0 %}
303+
<option value="1">{{ text_enabled }}</option>
304+
<option value="0" selected="selected">{{ text_disabled }}</option>
305+
{% endif %}
306+
</select>
307+
</div>
308+
</div>
290309
<div class="form-group">
291310
<label class="col-sm-2 control-label" for="cryptapi_qrcode">
292311
<span data-toggle="tooltip" title="{{ text_qrcode }}">
@@ -398,7 +417,7 @@
398417
<div class="form-group">
399418
<label class="col-sm-2 control-label" for="cryptapi_order_cancelation_timeout">
400419
<span data-toggle="tooltip" title="{{ text_order_cancelation_timeout }}">
401-
{{ order_cancelation_timeout }}
420+
{{ order_cancelation_timeout }}
402421
</span>
403422
</label>
404423
<div class="col-sm-10">
@@ -478,13 +497,26 @@
478497
class="form-control"/>
479498
</div>
480499
</div>
500+
<div class="form-group">
501+
<label class="col-sm-2 control-label" for="cryptapi_cryptapi_api_key">
502+
{{ api_key }}
503+
</label>
504+
<div class="col-sm-10">
505+
<input class="form-control" type="text" id="cryptapi_cryptapi_api_key" name='payment_cryptapi_api_key'
506+
{% if payment_cryptapi_api_key is empty %}value="" {% else %}value="{{ payment_cryptapi_api_key }}"{% endif %}>
507+
<p class="mt-2">
508+
{{ api_key_info }}
509+
</p>
510+
</div>
511+
</div>
481512
<div class="form-group">
482513
<div class="col-12 text-center" style="margin-bottom: 20px">
483514
<label class="control-label text-center" style="float: none !important;">
484-
<span data-toggle="tooltip" title="{{ help_cryptocurrencies }}">
485515
{{ entry_cryptocurrencies }}
486-
</span>
487516
</label>
517+
<p>
518+
{{ help_cryptocurrencies }}
519+
</p>
488520
</div>
489521
<input type="hidden" id="cryptapi_cryptocurrencies_array_cache" name="payment_cryptapi_cryptocurrencies_array_cache"
490522
value='{{ payment_cryptapi_cryptocurrencies_array|json_encode() }}'>

upload/catalog/controller/extension/payment/cryptapi.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public function confirm()
8181
$selected = $this->request->post['cryptapi_coin'];
8282
$address = $this->config->get('payment_cryptapi_cryptocurrencies_address_' . $selected);
8383

84-
if (!empty($address)) {
84+
$apiKey = $this->config->get('payment_cryptapi_api_key');
85+
86+
if (!empty($address) || !empty($apiKey)) {
8587
$nonce = $this->model_extension_payment_cryptapi->generateNonce();
8688

8789
require_once(DIR_SYSTEM . 'library/cryptapi.php');
@@ -103,7 +105,8 @@ public function confirm()
103105
$callbackUrl = $this->url->link('extension/payment/cryptapi/callback', 'order_id=' . $this->session->data['order_id'] . '&nonce=' . $nonce, true);
104106
$callbackUrl = str_replace('&amp;', '&', $callbackUrl);
105107

106-
$helper = new CryptAPIHelper($selected, $address, $callbackUrl, [], true);
108+
109+
$helper = new CryptAPIHelper($selected, $address, $apiKey, $callbackUrl, [], true);
107110
$addressIn = $helper->get_address();
108111

109112
$qrCodeDataValue = $helper->get_qrcode($cryptoTotal, $qr_code_size);
@@ -396,7 +399,7 @@ public function cron()
396399

397400
$remaining = $calc['remaining'];
398401
$remaining_pending = $calc['remaining_pending'];
399-
$remaining_fiat = $calc['remaining_fiat'];
402+
$already_paid = $calc['already_paid'];
400403

401404
if ($value_refresh !== 0 && $last_price_update + $value_refresh <= time() && !empty($last_price_update)) {
402405

@@ -423,7 +426,7 @@ public function cron()
423426
$this->model_extension_payment_cryptapi->updatePaymentData($order_id, 'cryptapi_last_price_update', time());
424427
}
425428

426-
if ($order_timeout !== 0 && (strtotime($order['date_added']) + $order_timeout) <= time() && $remaining_fiat >= floatval($metaData['cryptapi_total_fiat']) && (int)$metaData['cryptapi_cancelled'] === 0) {
429+
if ($order_timeout !== 0 && (strtotime($order['date_added']) + $order_timeout) <= time() && $already_paid <=0 && (int)$metaData['cryptapi_cancelled'] === 0) {
427430
$processing_state = 7;
428431
$this->model_checkout_order->addOrderHistory($order['order_id'], $processing_state);
429432
}
@@ -465,7 +468,7 @@ public function callback()
465468

466469
$history[$data['uuid']] = [
467470
'timestamp' => time(),
468-
'value_paid' => $paid,
471+
'value_paid' => CryptAPIHelper::sig_fig($paid, 6),
469472
'value_paid_fiat' => $fiat_conversion,
470473
'pending' => $data['pending']
471474
];

upload/catalog/model/extension/payment/cryptapi.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ public function validateCurrencies()
5555

5656
if (count($cryptocurrencies) > 0) {
5757
foreach ($cryptocurrencies as $token => $coin) {
58-
if ($coin && !empty($this->config->get('payment_cryptapi_cryptocurrencies_address_' . $token))) {
59-
$status = true;
60-
break;
58+
if ($coin) {
59+
if(!empty($this->config->get('payment_cryptapi_cryptocurrencies_address_' . $token) || !empty($this->config->get('payment_cryptapi_api_key')))) {
60+
$status = true;
61+
break;
62+
}
6163
}
6264
}
6365
}

upload/catalog/view/theme/default/template/extension/payment/cryptapi_success.twig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,38 @@
1414
<div class="ca_payment_details">
1515
<div class="ca_payments_wrapper">
1616
<div class="ca_qrcode_wrapper"
17-
style="{% if qr_code_setting == 'hide_ammount' or qr_code_setting =='hide_without_ammount' %}display: none;{% endif %}; width: {{ qr_code_size + 20 }}px;">
17+
style="{% if qrcode_default == '0' %}display: none;{% endif %}; width: {{ qr_code_size + 20 }}px;">
1818
{% if crypto_allowed_value == true %}
1919
<div class="inner-wrapper">
2020
<figure>
21-
{% if qr_code_setting != 'hide_ammount' %}
21+
{% if qr_code_setting != 'hide_without_ammount' %}
2222
<img class="ca_qrcode no_value"
2323
{% if qr_code_setting == 'ammount' %}
2424
style="display:none;"
2525
{% endif %}
2626
src="data:image/png;base64,{{ qr_code }}" alt="{{ qrcode_alt_text }}"/>
2727
{% endif %}
28-
{% if qr_code_setting != 'hide_without_ammount' %}
28+
{% if qr_code_setting != 'hide_ammount' %}
2929
<img class="ca_qrcode value"
3030
{% if qr_code_setting == 'without_ammount' %}
3131
style="display:none;"
3232
{% endif %} src="data:image/png;base64,{{ qr_code_value }}"
3333
alt="{{ qrcode_alt_value_text }}"/>
3434
{% endif %}
3535
</figure>
36-
{% if qr_code_setting != 'hide_ammount' and qr_code_setting != 'hide_without_ammount' %}
36+
{% if qr_code_setting != 'hide_without_ammount' %}
3737
<div class="ca_qrcode_buttons">
3838
{% if qr_code_setting != 'hide_without_ammount' %}
3939
<button class="ca_qrcode_btn no_value
40-
{% if qr_code_setting == 'without_ammount' %}
40+
{% if qr_code_setting == 'without_ammount' or qr_code_setting == 'hide_ammount' %}
4141
active
4242
{% endif %}" aria-label="{{ qrcode_alt_show_value }}">
4343
{{ qrcode_button_noamount_text }}
4444
</button>
4545
{% endif %}
4646
{% if qr_code_setting != 'hide_ammount' %}
4747
<button class="ca_qrcode_btn value
48-
{% if qr_code_setting == 'ammount' %}
48+
{% if qr_code_setting == 'ammount' or qr_code_setting == 'hide_without_ammount' %}
4949
active
5050
{% endif %}" aria-label="{{ qrcode_alt_show_value }}">
5151
{{ qrcode_button_amount_text }}
@@ -85,7 +85,7 @@
8585
<div class="ca_payment_notification ca_notification_remaining" style="display: none">
8686
<strong>{{ text_notice }}</strong>: {{ notification_remaining|format(min_tx_notice) }}
8787
</div>
88-
{% if refresh_value_interval != 'none' %}
88+
{% if refresh_value_interval != '0' %}
8989
<div class="ca_time_refresh">
9090
{{ order_value_refresh|format(crypto_coin|upper) }}
9191
<span class="ca_time_seconds_count" data-soon="{{ text_moment }}" data-seconds="{{ conversion_timer }}">{{ conversion_timer|date('i:s') }}</span>
@@ -100,7 +100,7 @@
100100
<div class="ca_loader"></div>
101101
</div>
102102
</div>
103-
{% if order_cancelation_timeout != 'none' %}
103+
{% if order_cancelation_timeout != '0' %}
104104
<span class="ca_notification_cancel" data-text="{{ order_cancelled_minute }}">
105105
{{ order_valid_time|format(cancel_timer, cancel_timer|date('H:i')) }}
106106
</span>

0 commit comments

Comments
 (0)