Skip to content

Commit 40f2a1e

Browse files
author
Ariano Fonseca Ângelo
committed
v3.2
- Support for BlockBee - New e-mail once a order is done with a link for payment - New settings layout - Minor fixes
1 parent 7755dc3 commit 40f2a1e

27 files changed

Lines changed: 1447 additions & 1246 deletions

File tree

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Accept cryptocurrency payments on your OpenCart store
66
### Requirements:
77

88
```
9-
OpenCart >= 3.0
9+
OpenCart >= 4.0
1010
```
1111

1212
### Description
@@ -72,7 +72,7 @@ CryptAPI has no setup fees, no monthly fees, no hidden costs, and you don't even
7272
Simply set your crypto addresses and you're ready to go. As soon as your customers pay we forward your earnings directly to your own wallet.
7373

7474
CryptAPI has a low 1% fee on the transactions processed. No hidden costs.
75-
For more info on our fees [click here](https://cryptapi.io/get_started/#fees)
75+
For more info on our fees [click here](https://cryptapi.io/fees)
7676

7777
### Installation
7878

@@ -113,12 +113,12 @@ If the OpenCart order total is below the chosen cryptocurrency's minimum, an err
113113

114114
#### Where can I find more documentation on your service?
115115

116-
You can find more documentation about our service on our [get started](https://cryptapi.io/get_started) page, our [technical documentation](https://cryptapi.io/docs/) page or our [resources](https://cryptapi.io/resources/) page.
116+
You can find more documentation about our service on our [get started](https://cryptapi.io/get_started) page, our [technical documentation](https://docs.cryptapi.io/) page or our [resources](https://cryptapi.io/ecommerce/) page.
117117
If there's anything else you need that is not covered on those pages, please get in touch with us, we're here to help you!
118118

119119
#### Where can I get support?
120120

121-
The easiest and fastest way is via our live chat on our [website](https://cryptapi.io) or via our [contact form](https://cryptapi.io/contact/).
121+
The easiest and fastest way is via our live chat on our [website](https://cryptapi.io) or via our [contact form](https://cryptapi.io/contacts/).
122122

123123
### Changelog
124124

@@ -148,5 +148,11 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
148148
#### 3.1.1
149149
* Minor fixes
150150

151+
#### 3.2
152+
* Support for BlockBee
153+
* New e-mail once a order is done with a link for payment
154+
* New settings layout
155+
* Minor fixes
156+
151157
== Upgrade Notice ==
152158
* No breaking changes

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

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<?php
22

3-
class ControllerExtensionPaymentCryptapi extends Controller
4-
{
3+
namespace Opencart\Admin\Controller\Extension\CryptAPI\Payment;
4+
5+
use Opencart\System\Engine\Config;
56

6-
private $error = array();
7+
class CryptAPI extends \Opencart\System\Engine\Controller
8+
{
9+
private $error = [];
710

811
public function index()
912
{
10-
require_once(DIR_SYSTEM . 'library/cryptapi.php');
13+
require(DIR_EXTENSION . 'cryptapi/system/library/cryptapi.php');
1114

12-
$this->load->language('extension/payment/cryptapi');
15+
$this->load->language('extension/cryptapi/payment/cryptapi');
1316

1417
$this->document->setTitle($this->language->get('heading_title'));
1518

16-
$this->load->model('setting/setting');
19+
$this->load->model('extension/cryptapi/payment/cryptapi');
1720

1821
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
1922
$this->model_setting_setting->editSetting('payment_cryptapi', $this->request->post);
@@ -76,14 +79,14 @@ public function index()
7679
'href' => $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true)
7780
);
7881

79-
$data['action'] = $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true);
80-
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true);
82+
$data['action'] = $this->url->link('extension/cryptapi/payment/cryptapi', 'user_token=' . $this->session->data['user_token']);
83+
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment');
8184

8285
/**
8386
* Defining Cryptocurrencies
8487
*/
8588

86-
$supported_coins = CryptAPIHelper::get_supported_coins();
89+
$supported_coins = \Opencart\Extension\CryptAPI\System\Library\CryptAPIHelper::get_supported_coins();
8790

8891
$data['payment_cryptapi_cryptocurrencies_array'] = $supported_coins;
8992

@@ -204,41 +207,72 @@ public function index()
204207
$data['column_left'] = $this->load->controller('common/column_left');
205208
$data['footer'] = $this->load->controller('common/footer');
206209

207-
$this->response->setOutput($this->load->view('extension/payment/cryptapi', $data));
208-
}
209-
210-
public function install()
211-
{
212-
$this->load->model('extension/payment/cryptapi');
213-
$this->model_extension_payment_cryptapi->install();
214-
}
215-
216-
public function uninstall()
217-
{
218-
$this->load->model('extension/payment/cryptapi');
219-
$this->model_extension_payment_cryptapi->uninstall();
210+
$this->response->setOutput($this->load->view('extension/cryptapi/payment/cryptapi', $data));
220211
}
221212

222213
public function order_info(&$route, &$data, &$output)
223214
{
224215
$order_id = $this->request->get['order_id'];
225-
$this->load->model('extension/payment/cryptapi');
226-
$order = $this->model_extension_payment_cryptapi->getOrder($order_id);
216+
$this->load->model('extension/cryptapi/payment/cryptapi');
217+
$order = $this->model_extension_cryptapi_payment_cryptapi->getOrder($order_id);
227218
if ($order) {
228219
$metaData = $order['response'];
220+
229221
if (!empty($metaData)) {
230222
$metaData = json_decode($metaData, true);
231-
$fields = [];
223+
$fields = '';
232224
foreach ($metaData as $key => $val) {
233-
$field = ['name' => $key, 'value' => $val];
234-
$fields[] = $field;
225+
if ($key === 'cryptapi_qrcode_value' || $key === 'cryptapi_qrcode') {
226+
$fields .= '<tr><td>' . $key . '</td><td style="line-break: anywhere"><img width="100" class="img-fluid" src="data:image/png;base64,' . $val . '"/></td></tr>';
227+
} else if ($key === 'cryptapi_history') {
228+
$history = json_decode($val);
229+
$historyObj = '<table class="table table-bordered">';
230+
foreach ($history as $h_key => $h_val) {
231+
$historyObj .= '<tr><td colspan="2"><strong>UUID:</strong> ' . $h_key . '</td>';
232+
foreach ($h_val as $hrow_key => $hrow_value) {
233+
$historyObj .= '<tr><td>' . $hrow_key . '</td><td>' . $hrow_value . '</td>';
234+
}
235+
$historyObj .= '</tr>';
236+
}
237+
$historyObj .= '</table>';
238+
$fields .= '<tr><td>' . $key . '</td><td>' . $historyObj . '</td></tr>';
239+
240+
} else if ($key === 'cryptapi_last_price_update' || $key === 'cryptapi_order_timestamp') {
241+
$fields .= '<tr><td>' . $key . '</td><td style="line-break: anywhere">' . date('d-m-Y H:i:s', (int)$val) . '</td></tr>';
242+
243+
} else {
244+
$fields .= '<tr><td>' . $key . '</td><td style="line-break: anywhere">' . $val . '</td></tr>';
245+
}
235246
}
236-
if (isset($data['payment_custom_fields']) && is_array($data['payment_custom_fields'])) {
237-
$data['payment_custom_fields'] = array_merge($data['payment_custom_fields'], $fields);
238-
} else {
239-
$data['payment_custom_fields'] = $fields;
247+
248+
if ($data['tabs'][0]['code'] === 'cryptapi') {
249+
$data['tabs'][0]['content'] = '<table style="font-size: 13px;" class="table table-bordered">' . $fields . '<table>';
240250
}
241251
}
242252
}
243253
}
254+
255+
public function install(): void
256+
{
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+
}
274+
275+
$this->model_extension_cryptapi_payment_cryptapi->install();
276+
}
277+
}
244278
}

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
3+
$base_url = sprintf(
4+
"%s://%s",
5+
$_SERVER['HTTPS'] ? 'https' : 'http',
6+
$_SERVER['SERVER_NAME']
7+
);
8+
29
// Heading
310
$_['heading_title'] = 'CryptAPI';
411

@@ -9,14 +16,13 @@
916

1017
$_['never'] = 'Never';
1118

12-
1319
// Text
1420
$_['text_extension'] = 'Extensions';
1521
$_['text_success'] = 'Success: You have modified your CryptAPI details!';
1622
$_['text_edit'] = 'Edit CryptAPI';
17-
$_['text_cryptapi'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" style="border: 1px solid #EEEEEE; height:37px" /></a>';
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>';
1824
$_['text_connect_cryptapi'] = 'This module allows you to accept CryptAPI Payments securely.';
19-
$_['text_cryptapi_image'] = '<a target="_BLANK" href="https://cryptapi.io/"><img src="view/image/payment/cryptapi.png" alt="cryptapi" title="cryptapi" class="img-fluid" /></a>';
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>';
2026
$_['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>';
2127
$_['text_blockchain_fees'] = 'This will add an estimation of the blockchain fee to the order value';
2228
$_['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)';
@@ -25,6 +31,9 @@
2531
$_['text_refresh_values'] = 'The system will automatically update the conversion value of the invoices (with real-time data), every X minutes. This feature is helpful whenever a customer takes long time to pay a generated invoice and the selected crypto a volatile coin/token (not stable coin). Warning: Setting this setting to none might create conversion issues, as we advise you to keep it at 5 minutes.';
2632
$_['text_order_cancelation_timeout'] = 'Selects the ammount of time the user has to pay for the order. When this time is over, order will be marked as \'Cancelled\' and every paid value will be ignored. Notice: If the user still sends money to the generated address, value will still be redirected to you. Warning: We do not advice more than 1 Hour.';
2733

34+
$_['text_tab_general'] = 'General';
35+
$_['text_tab_crypto'] = 'Cryptocurrencies';
36+
$_['text_tab_advanced'] = 'Advanced';
2837

2938
// Entry
3039
$_['entry_cryptocurrencies'] = 'Accepted Cryptocurrencies';
@@ -70,7 +79,7 @@
7079
$_['error_permission'] = 'Warning: You do not have permission to modify the CryptAPI payment module';
7180

7281
// Help hints
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.';
82+
$_['help_cryptocurrencies'] = 'If you are using BlockBee you can choose if setting the receiving addresses here bellow or in your BlockBee 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 BlockBee settings, you need to NOT select “Address Override” while creating the API key.';
7483
$_['help_cryptocurrency'] = 'Click the checkbox to enable the cryptocurrency';
7584

7685

@@ -82,5 +91,10 @@
8291
$_['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';
8392

8493

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.";
94+
$_['api_key'] = 'BlockBee API Key';
95+
$_['api_key_info'] = "Insert here your BlockBee API Key. You can get one with BlockBee. Notice: If API permission 'Address Override' is not enabled you must set the address in the dashboard otherwise payments may fail.";
96+
97+
$_['info_icon'] = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ms-1 bi bi-info-circle" viewBox="0 0 16 16">
98+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
99+
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
100+
</svg>';

admin/model/payment/cryptapi.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
namespace Opencart\Admin\Model\Extension\CryptAPI\Payment;
3+
class CryptAPI extends \Opencart\System\Engine\Model {
4+
5+
public function install() {
6+
$this->db->query("
7+
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cryptapi_order` (
8+
`order_id` int(11) NOT NULL,
9+
`response` TEXT
10+
) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;");
11+
}
12+
13+
public function getOrder($order_id): array
14+
{
15+
$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "cryptapi_order` WHERE `order_id` = '" . (int)$order_id . "' LIMIT 1");
16+
17+
if ($qry->num_rows) {
18+
$order = $qry->row;
19+
return $order;
20+
} else {
21+
return [];
22+
}
23+
}
24+
}
File renamed without changes.

0 commit comments

Comments
 (0)