Skip to content

Commit af2d446

Browse files
author
CryptAPI
committed
Initial Relase
0 parents  commit af2d446

18 files changed

Lines changed: 1389 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
![CryptAPI](https://i.imgur.com/IfMAa7E.png)
2+
3+
# CryptAPI Payment Gateway for OpenCart
4+
Accept cryptocurrency payments on your OpenCart store
5+
6+
### Requirements:
7+
8+
```
9+
OpenCart >= 3.0
10+
```
11+
12+
### Description
13+
14+
Accept payments in Bitcoin, Bitcoin Cash, Litecoin, Ethereum, Monero and IOTA directly to your crypto wallet, without any sign-ups or lengthy processes.
15+
All you need is to provide your crypto address.
16+
17+
#### Allow users to pay with crypto directly on your store
18+
19+
The CryptAPI extension enables your OpenCart store to get receive payments in cryptocurrency, with a simple setup and no sign-ups required.
20+
21+
Currently accepted cryptocurrencies are:
22+
23+
* (BTC) Bitcoin
24+
* (BCH) Bitcoin Cash
25+
* (LTC) Litecoin
26+
* (ETH) Ethereum
27+
* (XMR) Monero
28+
* (IOTA) IOTA
29+
30+
CryptAPI will attempt to automatically convert the value you set on your store to the cryptocurrency your customer chose.
31+
Exchange rates are fetched hourly from CoinMarketCap.
32+
33+
Supported currencies for automatic exchange rates are:
34+
35+
* (USD) United States Dollar
36+
* (EUR) Euro
37+
* (GBP) Great Britain Pound
38+
* (JPY) Japanese Yen
39+
* (CNY) Chinese Yuan
40+
* (INR) Indian Rupee
41+
* (CAD) Canadian Dollar
42+
* (HKD) Hong Kong Dollar
43+
* (BRL) Brazilian Real
44+
* (DKK) Danish Krone
45+
* (MXN) Mexican Peso
46+
* (AED) United Arab Emirates Dirham
47+
48+
If your OpenCart's currency is none of the above, the exchange rates will default to USD.
49+
If you're using OpenCart in a different currency not listed here and need support, please [contact us](https://cryptapi.io) via our live chat.
50+
51+
#### Why choose CryptAPI?
52+
53+
CryptAPI has no setup fees, no monthly fees, no hidden costs, and you don't even need to sign-up!
54+
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.
55+
56+
CryptAPI has a low 1% fee on the transactions processed. No hidden costs.
57+
For more info on our fees [click here](https://cryptapi.io/get_started/#fees)
58+
59+
### Installation
60+
61+
1. Open your OpenCart admin
62+
2. Go to Extensions
63+
3. Upload the .zip file
64+
65+
### Configuration
66+
67+
1. Access your OpenCart Admin Panel
68+
2. Go to Extensions -> Extensions
69+
3. Select "Payments"
70+
4. Scroll down to "CryptAPI"
71+
5. Activate the payment method (if inactive)
72+
6. Select which cryptocurrencies you wish to accept
73+
7. Input your addresses to the cryptocurrencies you selected. This is where your funds will be sent to, so make sure the addresses are correct.
74+
8. Save Changes
75+
9. All done!
76+
77+
### Frequently Asked Questions
78+
79+
#### Do I need an API key?
80+
81+
No. You just need to insert your crypto address of the cryptocurrencies you wish to accept. Whenever a customer pays, the money will be automatically and instantly forwarded to your address.
82+
83+
#### How long do payments take before they're confirmed?
84+
85+
This depends on the cryptocurrency you're using. Bitcoin usually takes up to 11 minutes, Ethereum usually takes less than a minute.
86+
87+
#### Is there a minimum for a payment?
88+
89+
Yes, the minimums change according to the chosen cryptocurrency and can be checked [here](https://cryptapi.io/get_started/#fees).
90+
If the OpenCart order total is below the chosen cryptocurrency's minimum, an error is raised to the user.
91+
92+
#### Where can I find more documentation on your service?
93+
94+
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.
95+
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!
96+
97+
#### Where can I get support?
98+
99+
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/).
100+
101+
### Changelog
102+
103+
#### 1.0
104+
* Initial release.
105+
106+
### Upgrade Notice
107+
* Initial release.
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?php
2+
class ControllerExtensionPaymentCryptapi extends Controller {
3+
4+
private $error = array();
5+
6+
public function index() {
7+
$this->load->language('extension/payment/cryptapi');
8+
9+
$this->document->setTitle($this->language->get('heading_title'));
10+
11+
$this->load->model('setting/setting');
12+
13+
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
14+
$this->model_setting_setting->editSetting('payment_cryptapi', $this->request->post);
15+
16+
$this->session->data['success'] = $this->language->get('text_success');
17+
18+
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'].'&type=payment', true));
19+
}
20+
21+
$this->load->model('localisation/geo_zone');
22+
23+
$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
24+
25+
$this->load->model('localisation/order_status');
26+
27+
$orderStatuses = $this->model_localisation_order_status->getOrderStatuses();
28+
$orderStatusesFiltered = [];
29+
$orderStatusesIgnore = [
30+
'Canceled',
31+
'Canceled Reversal',
32+
'Chargeback',
33+
'Complete',
34+
'Denied',
35+
'Expired',
36+
'Failed',
37+
'Processed',
38+
'Processing',
39+
'Refunded',
40+
'Reversed',
41+
'Shipped',
42+
'Voided'
43+
];
44+
foreach ($orderStatuses as $orderStatus) {
45+
if (!in_array($orderStatus['name'], $orderStatusesIgnore)){
46+
$orderStatusesFiltered[] = $orderStatus;
47+
}
48+
}
49+
$data['order_statuses'] = $orderStatusesFiltered;
50+
51+
if (isset($this->error['warning'])) {
52+
$data['error_warning'] = $this->error['warning'];
53+
} else {
54+
$data['error_warning'] = '';
55+
}
56+
57+
$data['breadcrumbs'] = array();
58+
59+
$data['breadcrumbs'][] = array(
60+
'text' => $this->language->get('text_home'),
61+
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
62+
);
63+
64+
$data['breadcrumbs'][] = array(
65+
'text' => $this->language->get('text_extension'),
66+
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true)
67+
);
68+
69+
$data['breadcrumbs'][] = array(
70+
'text' => $this->language->get('heading_title'),
71+
'href' => $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true)
72+
);
73+
74+
$data['action'] = $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true);
75+
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true);
76+
77+
if (isset($this->request->post['payment_cryptapi_btc_address'])) {
78+
$data['payment_cryptapi_btc_address'] = $this->request->post['payment_cryptapi_btc_address'];
79+
} else {
80+
$data['payment_cryptapi_btc_address'] = $this->config->get('payment_cryptapi_btc_address');
81+
}
82+
83+
if (isset($this->request->post['payment_cryptapi_bch_address'])) {
84+
$data['payment_cryptapi_bch_address'] = $this->request->post['payment_cryptapi_bch_address'];
85+
} else {
86+
$data['payment_cryptapi_bch_address'] = $this->config->get('payment_cryptapi_bch_address');
87+
}
88+
89+
if (isset($this->request->post['payment_cryptapi_ltc_address'])) {
90+
$data['payment_cryptapi_ltc_address'] = $this->request->post['payment_cryptapi_ltc_address'];
91+
} else {
92+
$data['payment_cryptapi_ltc_address'] = $this->config->get('payment_cryptapi_ltc_address');
93+
}
94+
95+
if (isset($this->request->post['payment_cryptapi_eth_address'])) {
96+
$data['payment_cryptapi_eth_address'] = $this->request->post['payment_cryptapi_eth_address'];
97+
} else {
98+
$data['payment_cryptapi_eth_address'] = $this->config->get('payment_cryptapi_eth_address');
99+
}
100+
101+
if (isset($this->request->post['payment_cryptapi_xmr_address'])) {
102+
$data['payment_cryptapi_xmr_address'] = $this->request->post['payment_cryptapi_xmr_address'];
103+
} else {
104+
$data['payment_cryptapi_xmr_address'] = $this->config->get('payment_cryptapi_xmr_address');
105+
}
106+
107+
if (isset($this->request->post['payment_cryptapi_iota_address'])) {
108+
$data['payment_cryptapi_iota_address'] = $this->request->post['payment_cryptapi_iota_address'];
109+
} else {
110+
$data['payment_cryptapi_iota_address'] = $this->config->get('payment_cryptapi_iota_address');
111+
}
112+
113+
if (isset($this->request->post['payment_cryptapi_cryptocurrencies'])) {
114+
$data['payment_cryptapi_cryptocurrencies'] = $this->request->post['payment_cryptapi_cryptocurrencies'];
115+
} else {
116+
$data['payment_cryptapi_cryptocurrencies'] = $this->config->get('payment_cryptapi_cryptocurrencies');
117+
}
118+
119+
if (isset($this->request->post['payment_cryptapi_standard_geo_zone_id'])) {
120+
$data['payment_cryptapi_standard_geo_zone_id'] = $this->request->post['payment_cryptapi_standard_geo_zone_id'];
121+
} else {
122+
$data['payment_cryptapi_standard_geo_zone_id'] = $this->config->get('payment_cryptapi_standard_geo_zone_id');
123+
}
124+
125+
if (isset($this->request->post['payment_cryptapi_order_status_id'])) {
126+
$data['payment_cryptapi_order_status_id'] = $this->request->post['payment_cryptapi_order_status_id'];
127+
} else {
128+
$data['payment_cryptapi_order_status_id'] = $this->config->get('payment_cryptapi_order_status_id');
129+
if (!$data['payment_cryptapi_order_status_id']) {
130+
$data['payment_cryptapi_order_status_id'] = 1;
131+
}
132+
}
133+
134+
if (isset($this->request->post['payment_cryptapi_status'])) {
135+
$data['payment_cryptapi_status'] = $this->request->post['payment_cryptapi_status'];
136+
} else {
137+
$data['payment_cryptapi_status'] = $this->config->get('payment_cryptapi_status');
138+
}
139+
140+
if (isset($this->request->post['payment_cryptapi_sort_order'])) {
141+
$data['payment_cryptapi_sort_order'] = $this->request->post['payment_cryptapi_sort_order'];
142+
} else {
143+
$data['payment_cryptapi_sort_order'] = $this->config->get('payment_cryptapi_sort_order');
144+
}
145+
146+
$data['header'] = $this->load->controller('common/header');
147+
$data['column_left'] = $this->load->controller('common/column_left');
148+
$data['footer'] = $this->load->controller('common/footer');
149+
150+
$this->response->setOutput($this->load->view('extension/payment/cryptapi', $data));
151+
}
152+
153+
public function install() {
154+
$this->load->model('extension/payment/cryptapi');
155+
$this->model_extension_payment_cryptapi->install();
156+
}
157+
158+
public function uninstall() {
159+
$this->load->model('extension/payment/cryptapi');
160+
$this->model_extension_payment_cryptapi->uninstall();
161+
}
162+
163+
public function order_info(&$route, &$data, &$output)
164+
{
165+
$order_id = $this->request->get['order_id'];
166+
$this->load->model('extension/payment/cryptapi');
167+
$order = $this->model_extension_payment_cryptapi->getOrder($order_id);
168+
if ($order) {
169+
$metaData = $order['response'];
170+
if (!empty($metaData)) {
171+
$metaData = json_decode($metaData, true);
172+
$fields = [];
173+
foreach ($metaData as $key => $val) {
174+
$field = ['name' => $key, 'value' => $val];
175+
$fields[] = $field;
176+
}
177+
if (isset($data['payment_custom_fields']) && is_array($data['payment_custom_fields'])) {
178+
$data['payment_custom_fields'] = array_merge($data['payment_custom_fields'], $fields);
179+
} else {
180+
$data['payment_custom_fields'] = $fields;
181+
}
182+
}
183+
}
184+
}
185+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
// Heading
3+
$_['heading_title'] = 'CryptAPI';
4+
5+
// Text
6+
$_['text_extension'] = 'Extensions';
7+
$_['text_success'] = 'Success: You have modified your CryptAPI details!';
8+
$_['text_edit'] = 'Edit CryptAPI';
9+
$_['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>';
10+
$_['text_connect_cryptapi'] = 'This module allows you to accept CryptAPI Payments (BTC, BCH, LTC, ETH, XMR and IOTA) securely.';
11+
$_['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>';
12+
$_['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>';
13+
14+
$_['text_btc'] = 'Bitcoin';
15+
$_['text_bch'] = 'Bitcoin Cash';
16+
$_['text_ltc'] = 'Litecoin';
17+
$_['text_eth'] = 'Ethereum';
18+
$_['text_xmr'] = 'Monero';
19+
$_['text_iota'] = 'IOTA';
20+
21+
// Entry
22+
$_['entry_cryptocurrencies'] = 'Accepted Cryptocurrencies';
23+
$_['entry_btc_address'] = $_['text_btc']. ' Address';
24+
$_['entry_bch_address'] = $_['text_bch']. ' Address';
25+
$_['entry_ltc_address'] = $_['text_ltc']. ' Address';
26+
$_['entry_eth_address'] = $_['text_eth']. ' Address';
27+
$_['entry_xmr_address'] = $_['text_xmr']. ' Address';
28+
$_['entry_iota_address'] = $_['text_iota']. ' Address';
29+
30+
$_['entry_order_status'] = 'Order status';
31+
$_['entry_status'] = 'Status';
32+
$_['entry_geo_zone'] = 'Geo Zone';
33+
$_['entry_sort_order'] = 'Sort order';
34+
35+
// Error
36+
$_['error_permission'] = 'Warning: You do not have permission to modify the CryptAPI payment module';
37+
38+
// Help hints
39+
$_['help_cryptocurrencies'] = 'Select which coins do you wish to accept.';
40+
$_['help_btc_address'] = 'Insert your Bitcoin address here. Leave blank if you want to skip this cryptocurrency.';
41+
$_['help_bch_address'] = 'Insert your Bitcoin Cash address here. Leave blank if you want to skip this cryptocurrency.';
42+
$_['help_ltc_address'] = 'Insert your Litecoin address here. Leave blank if you want to skip this cryptocurrency.';
43+
$_['help_eth_address'] = 'Insert your Ethereum address here. Leave blank if you want to skip this cryptocurrency.';
44+
$_['help_xmr_address'] = 'Insert your Monero address here. Leave blank if you want to skip this cryptocurrency.';
45+
$_['help_iota_address'] = 'Insert your IOTA address here. Leave blank if you want to skip this cryptocurrency.';
46+
47+
48+
// Order page - payment tab
49+
$_['text_payment_info'] = 'Payment information';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
class ModelExtensionPaymentCryptapi extends 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+
$this->load->model('setting/event');
12+
$this->model_setting_event->addEvent('payment_cryptapi', 'catalog/view/common/success/after', 'extension/payment/cryptapi/after_purchase');
13+
$this->model_setting_event->addEvent('payment_cryptapi', 'catalog/controller/checkout/success/before', 'extension/payment/cryptapi/before_checkout_success');
14+
$this->model_setting_event->addEvent('payment_cryptapi', 'admin/view/sale/order_info/before', 'extension/payment/cryptapi/order_info');
15+
}
16+
17+
public function uninstall() {
18+
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "cryptapi_order`;");
19+
$this->load->model('setting/event');
20+
$this->model_setting_event->deleteEventByCode('payment_cryptapi');
21+
}
22+
23+
public function getOrder($order_id) {
24+
$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "cryptapi_order` WHERE `order_id` = '" . (int)$order_id . "' LIMIT 1");
25+
26+
if ($qry->num_rows) {
27+
$order = $qry->row;
28+
return $order;
29+
} else {
30+
return false;
31+
}
32+
}
33+
}
4.03 KB
Loading

0 commit comments

Comments
 (0)