Skip to content

Commit 7b83299

Browse files
committed
v3.2.4
- Minor fixes and improvements
1 parent 820e5bc commit 7b83299

File tree

5 files changed

+52
-22
lines changed

5 files changed

+52
-22
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The CryptAPI extension enables your OpenCart store to get receive payments in cr
2424
* (ETH) Ethereum
2525
* (BCH) Bitcoin Cash
2626
* (LTC) Litecoin
27-
* (XMR) Monero
27+
* (MATIC) Polygon
2828
* (TRX) Tron
2929
* (BNB) Binance Coin
3030
* (USDT) USDT
@@ -164,5 +164,8 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
164164
#### 3.2.3
165165
* Minor fixes
166166

167+
#### 3.2.4
168+
* Minor fixes and improvements
169+
167170
### Upgrade Notice
168171
* No breaking changes

catalog/controller/payment/cryptapi.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ public function sel_crypto()
8484
public function confirm()
8585
{
8686
// Library
87+
$this->load->language('extension/cryptapi/payment/cryptapi');
8788
require(DIR_EXTENSION . 'cryptapi/system/library/cryptapi.php');
8889

8990
$json = array();
91+
$err_coin = '';
9092

9193
if ($this->config->get('payment_cryptapi_status')) {
9294
$this->load->model('checkout/order');
@@ -95,13 +97,18 @@ public function confirm()
9597
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
9698
$cryptoFee = empty($this->session->data['cryptapi_fee']) ? 0 : $this->session->data['cryptapi_fee'];
9799
$total = $this->currency->format($order_info['total'] + $cryptoFee, $order_info['currency_code'], 1.00000, false);
98-
99-
$selected = $this->request->post['cryptapi_coin'];
100-
$address = $this->config->get('payment_cryptapi_cryptocurrencies_address_' . $selected);
101-
102100
$apiKey = $this->config->get('payment_cryptapi_api_key');
101+
if (empty($this->request->post['cryptapi_coin'])) {
102+
$err_coin = $this->language->get('error_coin');
103+
} else {
104+
$selected = $this->request->post['cryptapi_coin'];
105+
$address = $this->config->get('payment_cryptapi_cryptocurrencies_address_' . $selected);
106+
if (empty($address) && empty($apiKey)) {
107+
$err_coin = $this->language->get('error_apikey');
108+
}
109+
}
103110

104-
if (!empty($address) || !empty($apiKey)) {
111+
if (empty($err_coin) && (!empty($address) || !empty($apiKey))) {
105112
$nonce = $this->model_extension_cryptapi_payment_cryptapi->generateNonce();
106113

107114
$disable_conversion = $this->config->get('payment_cryptapi_disable_conversion');
@@ -112,18 +119,20 @@ public function confirm()
112119

113120
$cryptoTotal = \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper::get_conversion($order_info['currency_code'], $selected, $total, $disable_conversion);
114121

115-
if ($cryptoTotal < $minTx) {
116-
$message = $this->module->l('Payment error: ', 'validation');
117-
$message .= $this->module->l('Value too low, minimum is', 'validation');
118-
$message .= ' ' . $minTx . ' ' . strtoupper($selected);
119-
$json['error'] = $message;
120-
} else {
121-
$callbackUrl = $this->url->link('extension/cryptapi/payment/cryptapi|callback', 'order_id=' . $this->session->data['order_id'] . '&nonce=' . $nonce, true);
122-
$callbackUrl = str_replace('&amp;', '&', $callbackUrl);
122+
$callbackUrl = $this->url->link('extension/cryptapi/payment/cryptapi|callback', 'order_id=' . $this->session->data['order_id'] . '&nonce=' . $nonce, true);
123+
$callbackUrl = str_replace('&amp;', '&', $callbackUrl);
123124

124-
$helper = new \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper($selected, $address, $apiKey, $callbackUrl, [], true);
125-
$addressIn = $helper->get_address();
125+
$helper = new \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper($selected, $address, $apiKey, $callbackUrl, [], true);
126+
$addressIn = $helper->get_address();
127+
if (!isset($addressIn)) {
128+
$err_coin = $this->language->get('error_adress');
129+
} else {
130+
if (($cryptoTotal < $minTx)) {
131+
$err_coin = $this->language->get('value_minim') . ' ' . $minTx . ' ' . strtoupper($selected);
132+
}
133+
}
126134

135+
if (empty($err_coin)) {
127136
$qrCodeDataValue = $helper->get_qrcode($cryptoTotal, $qr_code_size);
128137
$qrCodeData = $helper->get_qrcode('', $qr_code_size);
129138
$paymentURL = $this->url->link('extension/cryptapi/payment/cryptapi|pay', 'order_id=' . $this->session->data['order_id'] . 'nonce=' . $nonce, true);
@@ -150,7 +159,11 @@ public function confirm()
150159

151160
$this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_cryptapi_order_status_id'), '', true);
152161
$json['redirect'] = $this->url->link('checkout/success', 'order_id=' . $this->session->data['order_id'] . 'nonce=' . $nonce, true);
162+
} else {
163+
$json['error']['warning'] = sprintf($this->language->get('error_payment'), $err_coin);
153164
}
165+
} else {
166+
$json['error']['warning'] = sprintf($this->language->get('error_payment'), $err_coin);
154167
}
155168
}
156169

@@ -542,7 +555,7 @@ public function callback()
542555

543556
$metaData = json_decode($this->model_extension_cryptapi_payment_cryptapi->getPaymentData($order['order_id']), true);
544557

545-
$history = json_decode($metaData['cryptapi_history'], true);// <<-something's wrong
558+
$history = json_decode($metaData['cryptapi_history'], true); // <<-something's wrong
546559

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

@@ -578,10 +591,10 @@ function order_pay_button(&$route, &$data, &$output)
578591

579592
$orderFetch = $this->model_checkout_order->getOrder($order_id);
580593
$order = $this->model_extension_cryptapi_payment_cryptapi->getOrder($order_id);
581-
594+
582595
$orderObj = isset($order['response']) ? json_decode($order['response']) : '';
583596

584-
if(!$orderObj) {
597+
if (!$orderObj) {
585598
return;
586599
}
587600

@@ -590,4 +603,4 @@ function order_pay_button(&$route, &$data, &$output)
590603
$data['continue'] = $orderObj->cryptapi_payment_url;
591604
}
592605
}
593-
}
606+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
$_['text_paywith'] = 'Pay with';
1414
$_['text_notice'] = 'Notice';
1515
$_['text_moment'] = 'a moment';
16+
$_['error_payment'] = 'Payment error: %s!';
17+
$_['value_minim'] = 'Value too low, minimum is';
18+
$_['error_coin'] = 'No cryptocurrency selected for payment';
19+
$_['error_apikey'] = 'Insufficient store owner details for payment';
20+
$_['error_adress'] = 'This cryptocurrency cannot be used for payment at this time';
1621

1722
$_['button_pay'] = 'Pay now';
1823

@@ -50,4 +55,4 @@
5055

5156
$_['order_subject'] = 'New Order %1$s. Please send a %2$s payment';
5257
$_['order_greeting'] = 'Hello. Order %1$s was created successfully and a payment address was generated for the cryptocurrency %2$s.';
53-
$_['order_send_payment'] = 'To complete your order or check payment status, use the button provided bellow:';
58+
$_['order_send_payment'] = 'To complete your order or check payment status, use the button provided bellow:';

catalog/view/template/payment/cryptapi.twig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
url: 'index.php?route=extension/cryptapi/payment/cryptapi|sel_crypto',
3939
data: $(this).serialize(),
4040
success: function (res) {
41+
$('.alert-dismissible').remove();
4142
$('#button-payment-method').trigger('click');
4243
}
4344
});
@@ -58,9 +59,17 @@
5859
$('#button-confirm').button('reset');
5960
},
6061
success: function (json) {
62+
$('.alert-dismissible').remove();
6163
if (json['redirect']) {
6264
location = json['redirect'];
65+
} else if (json['error']) {
66+
67+
if (json['error']['warning']) {
68+
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error']['warning'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
69+
6370
}
71+
}
72+
6473
},
6574
error: function (xhr, ajaxOptions, thrownError) {
6675
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);

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.3",
4+
"version": "3.2.4",
55
"author": "CryptAPI",
66
"link": "https://cryptapi.io"
77
}

0 commit comments

Comments
 (0)