Skip to content

Commit 820e5bc

Browse files
committed
v3.2.3
- Minor fixes
1 parent 9815fba commit 820e5bc

10 files changed

Lines changed: 79 additions & 93 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.idea/
1+
.idea/
2+
.DS_STORE

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,8 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
161161
#### 3.2.2
162162
* Minor fixes
163163

164+
#### 3.2.3
165+
* Minor fixes
166+
164167
### Upgrade Notice
165168
* No breaking changes

admin/controller/payment/cryptapi.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,8 @@ public function order_info(&$route, &$data, &$output)
254254

255255
public function install(): void
256256
{
257-
if ($this->user->hasPermission('modify', 'extension/cryptapi')) {
258-
$this->load->model('extension/cryptapi/payment/cryptapi');
259-
260-
// Create events
261-
$this->load->model('setting/event');
262-
263-
if (!$this->model_setting_event->getEventByCode('cryptapi_order_info')) {
264-
$this->model_setting_event->addEvent(['code' => 'cryptapi_order_info', 'description' => '', 'trigger' => 'admin/view/sale/order_info/before', 'action' => 'extension/cryptapi/payment/cryptapi|order_info', 'status' => 1, 'sort_order' => '1']);
265-
}
266-
267-
if (!$this->model_setting_event->getEventByCode('cryptapi_order_button')) {
268-
$this->model_setting_event->addEvent(['code' => 'cryptapi_order_button', 'description' => '', 'trigger' => 'catalog/view/account/order_info/before', 'action' => 'extension/cryptapi/payment/cryptapi|order_pay_button', 'status' => 1, 'sort_order' => '1']);
269-
}
270-
271-
if (!$this->model_setting_event->getEventByCode('cryptapi_after_purchase')) {
272-
$this->model_setting_event->addEvent(['code' => 'cryptapi_after_purchase', 'description' => '', 'trigger' => 'catalog/view/common/success/after', 'action' => 'extension/cryptapi/payment/cryptapi|after_purchase', 'status' => 1, 'sort_order' => '1']);
273-
}
257+
$this->load->model('extension/cryptapi/payment/cryptapi');
274258

275-
$this->model_extension_cryptapi_payment_cryptapi->install();
276-
}
259+
$this->model_extension_cryptapi_payment_cryptapi->install();
277260
}
278261
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?php
22

3-
$base_url = sprintf(
4-
"%s://%s",
5-
$_SERVER['HTTPS'] ? 'https' : 'http',
6-
$_SERVER['SERVER_NAME']
7-
);
8-
93
// Heading
104
$_['heading_title'] = 'CryptAPI';
115

@@ -20,9 +14,9 @@
2014
$_['text_extension'] = 'Extensions';
2115
$_['text_success'] = 'Success: You have modified your CryptAPI details!';
2216
$_['text_edit'] = 'Edit CryptAPI';
23-
$_['text_cryptapi'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="' . $base_url . '/extension/cryptapi/admin/view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" style="border: 1px solid #EEEEEE; height:37px" /></a>';
17+
$_['text_cryptapi'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="' . HTTP_CATALOG . '/extension/cryptapi/admin/view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" style="border: 1px solid #EEEEEE; height:37px" /></a>';
2418
$_['text_connect_cryptapi'] = 'This module allows you to accept CryptAPI Payments securely.';
25-
$_['text_cryptapi_image'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="' . $base_url . '/extension/cryptapi/admin/view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" class="img-fluid" /></a>';
19+
$_['text_cryptapi_image'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="' . HTTP_CATALOG . '/extension/cryptapi/admin/view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" class="img-fluid" /></a>';
2620
$_['text_cryptapi_suppport'] = 'If you need any help or have any suggestion, contact us via the live chat on our <a target="_blank" href="https://cryptapi.io">website</a>';
2721
$_['text_blockchain_fees'] = 'This will add an estimation of the blockchain fee to the order value';
2822
$_['text_fees'] = 'Set the CryptAPI service fee you want to charge the costumer. Note: Fee you want to charge your costumers (to cover CryptAPI\'s fees fully or partially)';

admin/model/payment/cryptapi.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@
33
class CryptAPI extends \Opencart\System\Engine\Model {
44

55
public function install() {
6+
// Create events
7+
$this->load->model('setting/event');
8+
9+
if (!$this->model_setting_event->getEventByCode('cryptapi_order_info')) {
10+
$this->model_setting_event->addEvent(['code' => 'cryptapi_order_info', 'description' => '', 'trigger' => 'admin/view/sale/order_info/before', 'action' => 'extension/cryptapi/payment/cryptapi|order_info', 'status' => 1, 'sort_order' => '1']);
11+
}
12+
13+
if (!$this->model_setting_event->getEventByCode('cryptapi_order_button')) {
14+
$this->model_setting_event->addEvent(['code' => 'cryptapi_order_button', 'description' => '', 'trigger' => 'catalog/view/account/order_info/before', 'action' => 'extension/cryptapi/payment/cryptapi|order_pay_button', 'status' => 1, 'sort_order' => '1']);
15+
}
16+
17+
if (!$this->model_setting_event->getEventByCode('cryptapi_after_purchase')) {
18+
$this->model_setting_event->addEvent(['code' => 'cryptapi_after_purchase', 'description' => '', 'trigger' => 'catalog/view/common/success/after', 'action' => 'extension/cryptapi/payment/cryptapi|after_purchase', 'status' => 1, 'sort_order' => '1']);
19+
}
20+
621
$this->db->query("
722
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cryptapi_order` (
823
`order_id` int(11) NOT NULL,
924
`response` TEXT
10-
) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;");
25+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci");
1126
}
1227

1328
public function getOrder($order_id): array

catalog/controller/payment/cryptapi.php

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function pay()
237237
$cancel_timer = (int)$metaData['cryptapi_order_timestamp'] + (int)$this->config->get('payment_cryptapi_order_cancelation_timeout') - time();
238238

239239
$params = [
240-
'module_path' => \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper::base_url() . '/extension/cryptapi/catalog/view/image/',
240+
'module_path' => HTTP_SERVER . '/extension/cryptapi/catalog/view/image/',
241241
'header' => $this->load->controller('common/header'),
242242
'footer' => $this->load->controller('common/footer'),
243243
'currency_symbol_left' => $currencySymbolLeft,
@@ -251,7 +251,7 @@ public function pay()
251251
'qr_code' => $metaData['cryptapi_qrcode'],
252252
'qr_code_value' => $metaData['cryptapi_qrcode_value'],
253253
'show_branding' => $this->config->get('payment_cryptapi_branding'),
254-
'branding_logo' => \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper::base_url() . '/extension/cryptapi/catalog/view/image/payment.png',
254+
'branding_logo' => HTTP_SERVER . '/extension/cryptapi/catalog/view/image/payment.png',
255255
'qr_code_setting' => $this->config->get('payment_cryptapi_qrcode'),
256256
'order_timestamp' => $order['total'],
257257
'order_cancelation_timeout' => $this->config->get('payment_cryptapi_order_cancelation_timeout'),
@@ -292,30 +292,37 @@ public function after_purchase(&$route, &$data, &$output)
292292

293293
$nonce = $metaData['cryptapi_nonce'];
294294

295-
// Send the E-mail with the order URL
296-
$mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'));
297-
$mail->parameter = $this->config->get('config_mail_parameter');
298-
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
299-
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
300-
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
301-
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
302-
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
303-
304-
$subject = sprintf($this->language->get('order_subject'), $order['order_id'], strtoupper($metaData['cryptapi_currency']));
305-
306-
$data['order_greeting'] = sprintf($this->language->get('order_greeting'), $order['order_id'], strtoupper($metaData['cryptapi_currency']));
307-
$data['order_url'] = $metaData['cryptapi_payment_url'];
308-
$data['store'] = html_entity_decode($order['store_name'], ENT_QUOTES, 'UTF-8');
309-
$data['store_url'] = $order['store_url'];
310-
311-
$html = $this->load->view('extension/cryptapi/payment/cryptapi_email', $data);
312-
313-
$mail->setTo($order['email']);
314-
$mail->setFrom($this->config->get('config_email'));
315-
$mail->setSender(html_entity_decode($order['store_name'], ENT_QUOTES, 'UTF-8'));
316-
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
317-
$mail->setHtml($html);
318-
$mail->send();
295+
/**
296+
* Tries sending an e-mail. Will fail if configuration is not set but won't throw an error.
297+
*/
298+
try {
299+
// Send the E-mail with the order URL
300+
$mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'));
301+
$mail->parameter = $this->config->get('config_mail_parameter');
302+
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
303+
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
304+
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
305+
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
306+
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
307+
308+
$subject = sprintf($this->language->get('order_subject'), $order['order_id'], strtoupper($metaData['cryptapi_currency']));
309+
310+
$data['order_greeting'] = sprintf($this->language->get('order_greeting'), $order['order_id'], strtoupper($metaData['cryptapi_currency']));
311+
$data['order_url'] = $metaData['cryptapi_payment_url'];
312+
$data['store'] = html_entity_decode($order['store_name'], ENT_QUOTES, 'UTF-8');
313+
$data['store_url'] = $order['store_url'];
314+
315+
$html = $this->load->view('extension/cryptapi/payment/cryptapi_email', $data);
316+
317+
$mail->setTo($order['email']);
318+
$mail->setFrom($this->config->get('config_email'));
319+
$mail->setSender(html_entity_decode($order['store_name'], ENT_QUOTES, 'UTF-8'));
320+
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
321+
$mail->setHtml($html);
322+
$mail->send();
323+
} catch (\Exception $exception) {
324+
# don't do anything
325+
}
319326

320327
return $this->response->redirect($this->url->link('extension/cryptapi/payment/cryptapi|pay', 'order_id=' . $order['order_id'] . 'nonce=' . $nonce, true));
321328
}
@@ -418,9 +425,9 @@ public function cron($load_class = true)
418425
$this->load->model('extension/cryptapi/payment/cryptapi');
419426
$this->response->addHeader('Content-Type: application/json');
420427

421-
$order_timeout = intval($this->config->get('payment_cryptapi_order_cancelation_timeout'));
422-
$value_refresh = intval($this->config->get('payment_cryptapi_refresh_values'));
423-
$qrcode_size = intval($this->config->get('payment_cryptapi_qrcode_size'));
428+
$order_timeout = (int) $this->config->get('payment_cryptapi_order_cancelation_timeout');
429+
$value_refresh = (int) $this->config->get('payment_cryptapi_refresh_values');
430+
$qrcode_size = (int) $this->config->get('payment_cryptapi_qrcode_size');
424431

425432
$response = $this->response->setOutput(json_encode(['status' => 'ok']));
426433

@@ -447,15 +454,15 @@ public function cron($load_class = true)
447454

448455
$history = json_decode($metaData['cryptapi_history'], true);
449456

450-
$min_tx = floatval($metaData['cryptapi_min']);
457+
$min_tx = (float) $metaData['cryptapi_min'];
451458

452459
$calc = \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper::calc_order($history, $metaData['cryptapi_total'], floatval($metaData['cryptapi_total_fiat']));
453460

454461
$remaining = $calc['remaining'];
455462
$remaining_pending = $calc['remaining_pending'];
456463
$already_paid = $calc['already_paid'];
457464

458-
if ($value_refresh !== 0 && $last_price_update + $value_refresh <= time()) {
465+
if ($value_refresh !== 0 && ($last_price_update + $value_refresh <= time())) {
459466
if ($remaining === $remaining_pending) {
460467
$cryptapi_coin = $metaData['cryptapi_currency'];
461468

@@ -479,7 +486,7 @@ public function cron($load_class = true)
479486
$this->model_extension_cryptapi_payment_cryptapi->updatePaymentData($order_id, 'cryptapi_last_price_update', time());
480487
}
481488

482-
if ($order_timeout !== 0 && (strtotime($order['date_added']) + $order_timeout) <= time() && $already_paid <= 0 && (int)$metaData['cryptapi_cancelled'] === 0) {
489+
if ($order_timeout !== 0 && (strtotime($order['date_added']) + $order_timeout) <= time() && $already_paid <= 0) {
483490
$this->model_checkout_order->addHistory($order['order_id'], 7);
484491
$this->model_extension_cryptapi_payment_cryptapi->updatePaymentData($order_id, 'cryptapi_cancelled', '1');
485492
}

catalog/language/en-gb/payment/cryptapi.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
<?php
22

3-
$base_url = sprintf(
4-
"%s://%s",
5-
$_SERVER['HTTPS'] ? 'https' : 'http',
6-
$_SERVER['SERVER_NAME']
7-
);
8-
93
// Text
10-
$_['text_title'] = 'Cryptocurrency' . ' <img src="' . $base_url . 'image/catalog/cryptapi/payment.png" alt="cryptapi" style="height:23px" />';
4+
$_['text_title'] = 'Cryptocurrency' . ' <img src="' . HTTP_SERVER . 'image/catalog/cryptapi/payment.png" alt="cryptapi" style="height:23px" />';
115
$_['text_legend'] = 'Pay with cryptocurrency';
126
$_['text_basket'] = 'Basket';
137
$_['text_checkout'] = 'Checkout';
@@ -22,7 +16,7 @@
2216

2317
$_['button_pay'] = 'Pay now';
2418

25-
$_['branding_logo'] = '<img src="' . $base_url . 'image/catalog/cryptapi/payment_success.png" alt="cryptapi" style="width:122px;" />';
19+
$_['branding_logo'] = '<img src="' . HTTP_SERVER . 'image/catalog/cryptapi/payment_success.png" alt="cryptapi" style="width:122px;" />';
2620
$_['wallet_text'] = 'WALLET';
2721
$_['qr_code_text_open'] = 'Open QR CODE';
2822
$_['qr_code_text_close'] = 'Close QR CODE';

catalog/view/javascript/js/cryptapi_script.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,36 @@ function check_status(ajax_url) {
1515

1616
if (data.cancelled === 1) {
1717
jQuery('.ca_loader').remove();
18-
jQuery('.ca_payments_wrapper').slideUp('400');
19-
jQuery('.ca_payment_cancelled').slideDown('400');
20-
jQuery('.ca_progress').slideUp('400');
18+
jQuery('.ca_payments_wrapper').slideUp('200');
19+
jQuery('.ca_payment_cancelled').slideDown('200');
20+
jQuery('.ca_progress').slideUp('200');
2121
is_paid = true;
2222
}
2323

2424
if (data.is_pending === 1) {
2525
waiting_payment.addClass('done');
2626
waiting_network.addClass('done');
2727
jQuery('.ca_loader').remove();
28-
jQuery('.ca_notification_refresh').remove();
29-
jQuery('.ca_notification_cancel').remove();
28+
jQuery('.ca_payment_notification').remove();
3029

3130
setTimeout(function () {
32-
jQuery('.ca_payments_wrapper').slideUp('400');
33-
jQuery('.ca_payment_processing').slideDown('400');
34-
}, 5000);
31+
jQuery('.ca_payments_wrapper').slideUp('200');
32+
jQuery('.ca_payment_processing').slideDown('200');
33+
}, 300);
3534
}
3635

3736
if (data.is_paid) {
3837
waiting_payment.addClass('done');
3938
waiting_network.addClass('done');
4039
payment_done.addClass('done');
4140
jQuery('.ca_loader').remove();
42-
jQuery('.ca_notification_refresh').remove();
43-
jQuery('.ca_notification_cancel').remove();
41+
jQuery('.ca_payment_notification').remove();
4442

4543
setTimeout(function () {
46-
jQuery('.ca_payments_wrapper').slideUp('400');
47-
jQuery('.ca_payment_processing').slideUp('400');
48-
jQuery('.ca_payment_confirmed').slideDown('400');
49-
}, 5000);
44+
jQuery('.ca_payments_wrapper').slideUp('200');
45+
jQuery('.ca_payment_processing').slideUp('200');
46+
jQuery('.ca_payment_confirmed').slideDown('200');
47+
}, 300);
5048

5149
is_paid = true;
5250
}

install.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CryptAPI Payment Module",
33
"code": "cryptapi",
4-
"version": "3.2.2",
4+
"version": "3.2.3",
55
"author": "CryptAPI",
66
"link": "https://cryptapi.io"
77
}

system/library/cryptapi.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,6 @@ public static function sig_fig($value, $digits)
284284
return $answer;
285285
}
286286

287-
public static function base_url(): string
288-
{
289-
return sprintf(
290-
"%s://%s",
291-
$_SERVER['HTTPS'] ? 'https' : 'http',
292-
$_SERVER['SERVER_NAME']
293-
);
294-
}
295-
296287
public static function calc_order($history, $total, $total_fiat): array
297288
{
298289
$already_paid = 0;

0 commit comments

Comments
 (0)