diff --git a/upload/catalog/controller/payment/bitcoin.php b/upload/catalog/controller/payment/bitcoin.php index d5c63e5..f651cce 100644 --- a/upload/catalog/controller/payment/bitcoin.php +++ b/upload/catalog/controller/payment/bitcoin.php @@ -51,6 +51,9 @@ protected function index() { $this->data['bitcoin_total'] = round($this->currency->convert($order['total'], $current_default_currency, "BTC"),4); + $this->db->query("UPDATE `" . DB_PREFIX . "order` SET bitcoin_total = '" . $this->data['bitcoin_total'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'"); + + require_once('jsonRPCClient.php'); $bitcoin = new jsonRPCClient('http://'.$this->config->get('bitcoin_rpc_username').':'.$this->config->get('bitcoin_rpc_password').'@'.$this->config->get('bitcoin_rpc_address').':'.$this->config->get('bitcoin_rpc_port').'/'); @@ -71,6 +74,7 @@ protected function index() { $this->data['error'] = false; $this->data['bitcoin_send_address'] = $bitcoin->getaccountaddress($this->config->get('bitcoin_prefix').'_'.$order_id); + $this->db->query("UPDATE `" . DB_PREFIX . "order` SET bitcoin_address = '" . $this->data['bitcoin_send_address'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'"); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/bitcoin.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/bitcoin.tpl'; @@ -87,7 +91,7 @@ public function confirm_sent() { $order_id = $this->session->data['order_id']; $order = $this->model_checkout_order->getOrder($order_id); $current_default_currency = $this->config->get('config_currency'); - $bitcoin_total = round($this->currency->convert($order['total'], $current_default_currency, "BTC"),4); + $bitcoin_total = $order['bitcoin_total']; require_once('jsonRPCClient.php'); $bitcoin = new jsonRPCClient('http://'.$this->config->get('bitcoin_rpc_username').':'.$this->config->get('bitcoin_rpc_password').'@'.$this->config->get('bitcoin_rpc_address').':'.$this->config->get('bitcoin_rpc_port').'/'); @@ -99,17 +103,19 @@ public function confirm_sent() { try { $received_amount = $bitcoin->getreceivedbyaccount($this->config->get('bitcoin_prefix').'_'.$order_id,0); + if(round((float)$received_amount,4) >= round((float)$bitcoin_total,4)) { + $order = $this->model_checkout_order->getOrder($order_id); + $this->model_checkout_order->confirm($order_id, $this->config->get('bitcoin_order_status_id')); + echo true; + } + else { + echo false; + } } catch (Exception $e) { + $this->data['error'] = true; echo false; } - if(round((float)$received_amount,4) >= round((float)$bitcoin_total,4)) { - $order = $this->model_checkout_order->getOrder($order_id); - $this->model_checkout_order->confirm($order_id, $this->config->get('bitcoin_order_status_id')); - echo true; - } - else { - echo false; - } + } public function checkUpdate() { diff --git a/upload/catalog/view/theme/default/template/payment/bitcoin.tpl b/upload/catalog/view/theme/default/template/payment/bitcoin.tpl index aa7da73..a59022a 100644 --- a/upload/catalog/view/theme/default/template/payment/bitcoin.tpl +++ b/upload/catalog/view/theme/default/template/payment/bitcoin.tpl @@ -119,6 +119,9 @@ $('#button-pay').on('click', function() { type: 'GET', url: 'index.php?route=payment/bitcoin/confirm_sent', timeout: 5000, + error: function() { + document.getElementById("cboxLoadedContent").innerHTML = document.getElementById("cboxLoadedContent").innerHTML + '
'; + }, success: function(received) { if(received) { location.href = 'index.php?route=checkout/success'; diff --git a/upload/vqmod/xml/opencart-bitcoin-module.xml b/upload/vqmod/xml/opencart-bitcoin-module.xml new file mode 100644 index 0000000..4bc75b4 --- /dev/null +++ b/upload/vqmod/xml/opencart-bitcoin-module.xml @@ -0,0 +1,16 @@ +