diff --git a/modules/gateways/blockonomics.php b/modules/gateways/blockonomics.php index 213b2f8..eaf3719 100644 --- a/modules/gateways/blockonomics.php +++ b/modules/gateways/blockonomics.php @@ -241,12 +241,28 @@ function blockonomics_link($params) $blockonomics = new Blockonomics(); $order_hash = $blockonomics->getOrderHash($params['invoiceid'], $params['amount'], $params['currency'], $params['basecurrencyamount']); - $system_url = \App::getSystemURL(); - $form_url = $system_url . 'modules/gateways/blockonomics/payment.php'; + $order_params = []; + $active_cryptos = $blockonomics->getActiveCurrencies(); + // Check how many crypto currencies are activated + if (count($active_cryptos) > 1) { + $order_params = ['select_crypto' => $order_hash]; + } elseif (count($active_cryptos) === 1) { + $order_params = [ + 'show_order' => $order_hash, + 'crypto' => array_keys($active_cryptos)[0] + ]; + } elseif (count($active_cryptos) === 0) { + $order_params = [ + 'crypto' => 'empty' + ]; + } - //pass only the uuid to the payment page + $form_url = \App::getSystemURL() . 'modules/gateways/blockonomics/payment.php'; + //pass only the order hash to the payment page $form = '
'; - $form .= ''; + foreach ($order_params as $name => $param) { + $form .= ''; + } $form .= ''; $form .= '
'; diff --git a/modules/gateways/blockonomics/assets/css/order.css b/modules/gateways/blockonomics/assets/css/order.css index 1cddcb5..c28e605 100644 --- a/modules/gateways/blockonomics/assets/css/order.css +++ b/modules/gateways/blockonomics/assets/css/order.css @@ -1,4 +1,4 @@ -/* ----- Order Page Styles ------*/ +/* ----- Checkout Page Styles ------*/ [ng\:cloak], [ng-cloak], [data-ng-cloak], @@ -9,23 +9,11 @@ } .bnomics-order-container { - margin: 0 auto; - padding: 10px; + margin: 5vh auto; + padding: 8px; max-width: 700px; } -.bnomics-order-container h4 { - padding: 3px 0 3px 0 !important; - font-weight: 600; -} - -.bnomics-order-container h5 { - margin: 15px 0; - letter-spacing: 1px; - font-weight: normal; - text-transform: unset; -} - .bnomics-progress-bar-container { position: relative; overflow: hidden; @@ -62,114 +50,24 @@ .bnomics-btc-info .bnomics-qr-code { flex: 1; + padding-top: 1em; } .bnomics-btc-info .bnomics-amount { flex: 2; } -.bnomics-altcoin-pane { - align-items: center; - flex: 1; - text-align: center; -} - -.bnomics-address, .bnomics-amount { - position:relative; - width: 100%; -} - -.bnomics-amount-input, .bnomics-address-input { - background-color: #fff; - border: 1px solid #ccc; - padding: 2px 4px; - font-weight: 600; - margin-top: 5px; - margin-bottom: 10px; - width: 100%; - border: 1px solid #DDD; - background-color: #fff; - box-shadow: none; - text-align: center; - padding:7px; - cursor: pointer; -} - -.bnomics-amount-input li, .bnomics-address-input li { - display: inline-block; - list-style: none; - margin-left: 5px; -} - -.bnomics-select-container { - text-align:center; - max-width:350px; - margin:auto; -} - -.bnomics-select-options { - cursor:pointer; -} - -.bnomics-select-options h3 { - display:inline; -} - -.bnomics-select-container table{ - border-collapse: separate; - border-spacing: 0 1em; -} -.bnomics-select-container td { - border: 1px solid lightgrey; - padding:20px; - border-radius:10px; -} - -.bnomics-select-currency-button{ - float: right; -} - -.bnomics-select-currency-code { - text-transform: uppercase; -} - -.bnomics-order-expired-wrapper, .bnomics-order-error-wrapper { - text-align: center; -} - -.bnomics-blockonomics-currency { - width: 100%; - text-align: center; - padding:0 0 20px 0; -} - -.bnomics-grey { - color:grey; -} - -.bnomics-spinner-wrapper { - width: 100%; - text-align: center; - padding: 20px; -} - -.bnomics-spinner { - margin: auto; - width: 60px; - height: 60px; - animation: rotate 1.4s infinite ease-in-out, background 1.4s infinite ease-in-out alternate; -} - .bnomics-powered-by { text-align: center; - margin-top: 1.6em; - font-size: 0.8em; + margin-top: 2.6em; + font-size: 0.6em; padding: 0; } .bnomics-qr-code-hint { text-align: center; margin-bottom: 1em; + font-size: 0.8em; padding: 0 20px; } @@ -177,19 +75,9 @@ text-transform: uppercase; } -.bnomics-amount-seperator{ - width:10%; - margin:0; - margin-left:45% -} - .bnomics-time-left { line-height: 3; - font-size: 12px; -} - -.bnomics-payment-option { - text-align:center; + font-size: 0.8em; } .bnomics-order-id { @@ -209,90 +97,37 @@ text-align: left; } -.bnomics-paywith-btc { - border-radius: 10px 0px 0px 10px; -} - -.bnomics-paywith-altcoin { - border-radius: 0px 10px 10px 0px; -} - -.bnomics-paywith-option { - color:#B9B9B9; - background-color:#F3F3F3; - border: 1px solid #B9B9B9; - padding: 8px 18px; - text-align: center; - text-decoration: none; - display: inline-block; - cursor: pointer; -} - -.bnomics-paywith-selected { - color:#fff; - background-color:#B9B9B9; -} - -.bnomics-symbol-selected { - color:#fff; - background-color:#B9B9B9; - border: 0px solid #B9B9B9; - padding: 1px 3px; +.bnomics-order-expired-wrapper, .bnomics-order-error-wrapper { text-align: center; - text-decoration: none; - border-radius: 3px; -} - -.bnomics-paywith-label { - font-size:1.25em; -} - -.bnomics-altcoin-bg { - min-height: 180px; -} - -.bnomics-altcoin-bg-color{ - padding: 15px 10%; -} - -.bnomics-altcoin-cancel{ - margin-top:5px; } -.bnomics-copy-text{ - padding-bottom: 15px !important; -} - -.bnomics-status-flex { - padding-top:10px; - padding-bottom:10px; -} - -.bnomics-status-flex > div { +.bnomics-amount-input, .bnomics-address-input { + padding: 2px 4px; + font-weight: 600; + margin-top: 5px; + margin-bottom: 10px; + width: 100%; + border: 1px solid #DDD; + box-shadow: none; text-align: center; - padding: 5px; -} - -.bnomics-horizontal-align { - margin: auto; -} - -.bnomics-alt-icon{ - width: 100% !important; - font-size:60px !important; - margin: 25px 0px !important; + padding:7px; + cursor: pointer; + margin-left: 0; } -.bnomics-small{ - font-size: 0.8em; +.bnomics-amount-input li, .bnomics-address-input li { + display: inline-block; + list-style: none; + margin-left: 5px; + word-break: break-all; } -.bnomics-bold{ - font-weight: bold; +.bnomics-grey { + color:grey; } -.bnomics-left{ - text-align: left; +.bnomics-address, .bnomics-amount{ + margin-top: 10px; } .bnomics-display-error { @@ -308,7 +143,7 @@ to { width:auto;height: auto; } } -/* ---- Mobile -----*/ +/* Mobile */ @media screen and (max-width: 800px) { .bnomics-btc-info { display: block !important; @@ -318,23 +153,103 @@ text-align: center; } - .bnomics-order-container h5 { - margin: 10px 0; - } - - .bnomics-altcoin-pane { - display: block; - } - .bnomics-order-info { display: block; } - .bnomics-copy-icon { - display:none !important; +} + +/* ----- Select Crypto Styles ------*/ +@font-face { + font-family: 'cryptos'; + src: url('../fonts/cryptos.woff') format('woff'); + font-weight: normal; + font-style: normal; + font-display: block; +} + +[class^="bnomics-icon-"], [class*=" bnomics-icon-"] { + font-family: 'cryptos' !important; + speak: never; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + font-size: 4em; + display: block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.bnomics-icon-bch:before { + content: "\e900"; +} +.bnomics-icon-btc:before { + content: "\e901"; +} + +.bnomics-rotate-btc { + -webkit-transform:rotate(15deg); + -moz-transform: rotate(15deg); + -ms-transform: rotate(15deg); + -o-transform: rotate(15deg); + transform: rotate(15deg); + margin-left: auto; + margin-right: auto; +} + +.bnomics-rotate-bch { + -webkit-transform:rotate(-15deg); + -moz-transform: rotate(-15deg); + -ms-transform: rotate(-15deg); + -o-transform: rotate(-15deg); + transform: rotate(-15deg); + margin-left: auto; + margin-right: auto; +} + +.bnomics-select-options { + cursor:pointer; + width:50%; + box-shadow: 0 4px 8px 0; + transition: 0.3s; + border-radius:5px; + text-align: center !important; + word-break: break-word; + text-transform: uppercase; +} + +.bnomics-select-options:hover { + box-shadow: 0 8px 16px 0; +} + +.bnomics-select-container { + padding-top: 10vh; + text-align:center; + max-width:400px; + margin:auto; +} + +.bnomics-select-container table{ + border-collapse: separate; + border-spacing: 10px 0px; + border: none; +} + +/* Mobile */ +@media screen and (max-width: 350px) { + .bnomics-select-container td { + padding: 20px 5px; } } /* ---- Spinner ---- */ +.bnomics-spinner-wrapper { + width: 100%; + text-align: center; + padding: 20px; +} + .bnomics-spinner { display: inline-block; width: 70px; @@ -352,19 +267,3 @@ @-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } } - -.rotateimgbtc { - -webkit-transform:rotate(15deg); - -moz-transform: rotate(15deg); - -ms-transform: rotate(15deg); - -o-transform: rotate(15deg); - transform: rotate(15deg) -} - -.rotateimgbch { - -webkit-transform:rotate(-15deg); - -moz-transform: rotate(-15deg); - -ms-transform: rotate(-15deg); - -o-transform: rotate(-15deg); - transform: rotate(-15deg) -} \ No newline at end of file diff --git a/modules/gateways/blockonomics/assets/fonts/cryptos.woff b/modules/gateways/blockonomics/assets/fonts/cryptos.woff new file mode 100755 index 0000000..3b210ae Binary files /dev/null and b/modules/gateways/blockonomics/assets/fonts/cryptos.woff differ diff --git a/modules/gateways/blockonomics/assets/js/app.js b/modules/gateways/blockonomics/assets/js/app.js index 7fabe70..b2bf315 100644 --- a/modules/gateways/blockonomics/assets/js/app.js +++ b/modules/gateways/blockonomics/assets/js/app.js @@ -1,52 +1,37 @@ -service = angular.module("shoppingcart.services", ["ngResource"]); +(function () { +'use strict'; -service.factory('Order', function($resource) { - param = {}; - var item = $resource(window.location.pathname, param); - return item; -}); - -app = angular.module('shopping-cart-demo', ["monospaced.qrcode", "shoppingcart.services"],function($interpolateProvider) { +angular.module('BlockonomicsApp', ['ngResource', 'monospaced.qrcode'],function($interpolateProvider) { $interpolateProvider.startSymbol('[['); $interpolateProvider.endSymbol(']]'); -}); +}) +.controller('CheckoutController', CheckoutController) +.factory('Order', Order) +.service('Url', Url) +.config(Config); + +Config.$inject = ['$compileProvider']; +function Config($compileProvider) { + $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|data|chrome-extension|bitcoin|bitcoincash):/); +} + +CheckoutController.$inject = ['$scope', '$interval', 'Order', '$timeout', 'Url']; +function CheckoutController($scope, $interval, Order, $timeout, Url) { + var active_cryptos_div = document.getElementById("active_cryptos"); + var active_cryptos = JSON.parse(active_cryptos_div.dataset.active_cryptos); + var crypto_code = Url.get_parameter_by_name("crypto"); + $scope.crypto = active_cryptos[crypto_code]; -app.config(function($compileProvider) { - $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|data|chrome-extension|bitcoin|bitcoincash):/); - // Angular before v1.2 uses $compileProvider.urlSanitizationWhitelist(...) -}); - -//CheckoutController -app.controller('CheckoutController', function($scope, $interval, Order, $httpParamSerializer, $timeout) { - //get order uuid from url var time_period_div = document.getElementById("time_period"); var blockonomics_time_period = time_period_div.dataset.time_period; var totalTime = blockonomics_time_period * 60; var totalProgress = 100; - - var order_uuid_div = document.getElementById("order_uuid"); - $scope.order_uuid = order_uuid_div.dataset.order_uuid; - - var order_id_div = document.getElementById("order_id"); - $scope.order_id = order_id_div.dataset.order_id; - - var active_currencies_div = document.getElementById("active_currencies"); - var active_currencies = JSON.parse(active_currencies_div.dataset.active_currencies); - $scope.active_currencies = active_currencies; - + $scope.no_display_error = true; $scope.copyshow = false; - $scope.display_problems = true; - //Create url when the order is received - $scope.finish_order_url = function() { - var params = {}; - params.finish_order = $scope.order_id; - url = window.location.pathname; - var serializedParams = $httpParamSerializer(params); - if (serializedParams.length > 0) { - url += ((url.indexOf('?') === -1) ? '?' : '&') + serializedParams; - } - return url; - } + //fetch url params + $scope.order_hash = Url.get_parameter_by_name("show_order"); + + check_blockonomics_order(); //Increment bitcoin timer $scope.tick = function() { @@ -60,26 +45,12 @@ app.controller('CheckoutController', function($scope, $interval, Order, $httpPar $scope.progress = Math.floor($scope.clock * totalProgress / totalTime); }; - //Select Blockonomics currency - $scope.select_blockonomics_currency = function(blockonomics_currency) { - $scope.currency_selecter = false; - $scope.currency = $scope.active_currencies[blockonomics_currency]; - $scope.currency.code = blockonomics_currency; - check_blockonomics_uuid(); - } - - //Fetch the blockonomics_currency symbol from name - function getAltKeyByValue(object, value) { - return Object.keys(object).find(key => object[key] === value); - } - //Proccess the order data - function proccess_order_data(data) { - $scope.order = data; - if(data.blockonomics_currency === 'btc'){ + function proccess_order_data() { + if($scope.crypto.code === 'btc'){ var subdomain = 'www'; }else{ - var subdomain = data.blockonomics_currency; + var subdomain = $scope.crypto.code; } //Check the status of the order if ($scope.order.status == -1) { @@ -91,58 +62,57 @@ app.controller('CheckoutController', function($scope, $interval, Order, $httpPar } $scope.tick_interval = $interval($scope.tick, 1000); //Connect and Listen on websocket for payment notification - var ws = new ReconnectingWebSocket("wss://" + subdomain + ".blockonomics.co/payment/" + $scope.order.addr + "?timestamp=" + $scope.order.timestamp); + var ws = new ReconnectingWebSocket("wss://" + subdomain + ".blockonomics.co/payment/" + $scope.order.addr); ws.onmessage = function(evt) { ws.close(); $interval(function() { - //Redirect to order received page if message from socket - window.location = $scope.finish_order_url(); + //Redirect to order confirmation page if message from socket + window.location = Url.get_wc_endpoint({'finish_order' : $scope.order.id_order}); //Wait for 2 seconds for order status to update on server }, 2000, 1); } } + else if ($scope.order.status >= 0){ + //Goto order confirmation as payment is already in process or done + window.location = Url.get_wc_endpoint({'finish_order' : $scope.order.id_order}); + } + } + - //Check if the blockonomics uuid is present - function check_blockonomics_uuid() { + //Check if the blockonomics order is present + function check_blockonomics_order() { $scope.spinner = true; - if (typeof $scope.order_uuid != 'undefined') { - //Fetch the order using uuid + if (typeof $scope.order_hash != 'undefined') { + //Fetch the order using order_hash Order.get({ - "get_order": $scope.order_uuid, - "blockonomics_currency": $scope.currency.code + "get_order": $scope.order_hash, + "crypto": $scope.crypto.code }, function(data) { $scope.spinner = false; if(data.txid !== undefined && data.txid !== ""){ $scope.txid = data.txid; $scope.pending_error = true; }else if(data.addr !== undefined){ - proccess_order_data(data); + $scope.order = data; + // show the checkout page + proccess_order_data(); $scope.checkout_panel = true; - }else if($scope.currency.code === 'btc'){ - $scope.address_error_btc = true; - }else if($scope.currency.code === 'bch'){ + }else if($scope.crypto.code === 'btc'){ + if (data.error && data.error.toLowerCase().indexOf("gap limit") !== -1) + $scope.btc_gaplimit_error = data.error; + else + $scope.address_error_btc = true; + }else if($scope.crypto.code === 'bch'){ $scope.address_error_bch = true; } }); } } - - $scope.spinner = true; - if(Object.keys($scope.active_currencies).length === 1){ - // Auto select btc if 1 activated currency - $scope.currency = $scope.active_currencies['btc']; - $scope.currency.code = 'btc'; - check_blockonomics_uuid(); - }else if(Object.keys($scope.active_currencies).length >= 1){ - //Show user currency selector if > 1 activated currency - $scope.currency_selecter = true; - $scope.spinner = false; - } function select_text(divid) { - selection = window.getSelection(); + var selection = window.getSelection(); var div = document.createRange(); div.setStartBefore(document.getElementById(divid)); @@ -153,20 +123,14 @@ app.controller('CheckoutController', function($scope, $interval, Order, $httpPar function copy_to_clipboard(divid) { - // Create a new textarea element and give it id='temp_element' var textarea = document.createElement('textarea'); textarea.id = 'temp_element'; - // Optional step to make less noise on the page, if any! textarea.style.height = 0; - // Now append it to your page somewhere, I chose document.body.appendChild(textarea); - // Give our textarea a value of whatever inside the div of id=containerid textarea.value = document.getElementById(divid).innerText; - // Now copy whatever inside the textarea to clipboard var selector = document.querySelector('#temp_element'); selector.select(); document.execCommand('copy'); - // Remove the textarea document.body.removeChild(textarea); select_text(divid); @@ -195,9 +159,47 @@ app.controller('CheckoutController', function($scope, $interval, Order, $httpPar $scope.blockonomics_amount_click = function() { copy_to_clipboard("bnomics-amount-copy"); } - //Copy bitcoin address to clipboard + //Reload the page if user clicks try again after the order expires $scope.try_again_click = function() { location.reload(); } +} + +Order.$inject = ['$resource', 'Url']; +function Order($resource, Url) { + var param = {}; + var item = $resource(window.location.pathname, param); + return item; +} + +Url.$inject = ['$httpParamSerializer']; +function Url($httpParamSerializer) { + var service = this; + + service.get_parameter_by_name = function(name, url) { + if (!url) { + url = window.location.href; + } + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); + } + + service.get_wc_endpoint = function(new_params = {}) { + var params = {}; + for (var key in new_params) { + params[key] = new_params[key]; + } + var url = window.location.pathname; + var serializedParams = $httpParamSerializer(params); + if (serializedParams.length > 0) { + url += ((url.indexOf('?') === -1) ? '?' : '&') + serializedParams; + } + return url; + } +} -}); +})(); \ No newline at end of file diff --git a/modules/gateways/blockonomics/assets/templates/checkout.tpl b/modules/gateways/blockonomics/assets/templates/checkout.tpl new file mode 100644 index 0000000..6ed661d --- /dev/null +++ b/modules/gateways/blockonomics/assets/templates/checkout.tpl @@ -0,0 +1,123 @@ + + +
+
+ +
+
+
+ +
+
+
+ {$_BLOCKLANG.orderId}[[order.id_order]] +
+
+
+ +
+
+
+ +
+

Display Error

+

Unable to render correctly, Note to Administrator: Please enable lite mode in the Blockonomics plugin.

+
+ +
+

{$_BLOCKLANG.error.btc.title}

+

{$_BLOCKLANG.error.btc.message}

+
+ +
+

Could not generate new Bitcoin address

+

Note to webmaster: [[btc_gaplimit_error]].

+
+ +
+

{$_BLOCKLANG.error.bch.title}

+

{$_BLOCKLANG.error.bch.message}

+
+ +
+

{$_BLOCKLANG.error.pending.title}

+ {$_BLOCKLANG.error.pending.message} +
+ +
+

{$_BLOCKLANG.paymentExpired}


+

{$_BLOCKLANG.tryAgain}

+
+ +
+

{$_BLOCKLANG.paymentError}

+
+ +
+
+
+
+ + + + +
+
+ +
+
{$_BLOCKLANG.payAmount}
+
{$_BLOCKLANG.copyClipboard}
+
    +
  • [[order.bits/1.0e8]]
  • +
  • [[crypto.code | uppercase]]
  • +
  • +
  • [[order.value]]
  • +
  • [[order.currency]]
  • +
+
+ +
+
{$_BLOCKLANG.payAddress}
+
{$_BLOCKLANG.copyClipboard}
+
    +
  • [[order.addr]]
  • +
+
+ +
+
+
+
+
+ [[clock*1000 | date:'mm:ss' : 'UTC']] min +
+
+
+
+
+
+ +
+ {$_BLOCKLANG.howToPay}
+
{$_BLOCKLANG.poweredBy}
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/modules/gateways/blockonomics/assets/templates/crypto_options.tpl b/modules/gateways/blockonomics/assets/templates/crypto_options.tpl new file mode 100644 index 0000000..cd3f8c8 --- /dev/null +++ b/modules/gateways/blockonomics/assets/templates/crypto_options.tpl @@ -0,0 +1,23 @@ + + +
+
+ + + {foreach $active_currencies as $crypto} + + {/foreach} + +
+ +

+ {$_BLOCKLANG.payWith} +

+ + {$crypto['name']}
+ {$crypto['code']} +

+
+
+
+
\ No newline at end of file diff --git a/modules/gateways/blockonomics/assets/templates/no_crypto_selected.tpl b/modules/gateways/blockonomics/assets/templates/no_crypto_selected.tpl new file mode 100644 index 0000000..4d3f053 --- /dev/null +++ b/modules/gateways/blockonomics/assets/templates/no_crypto_selected.tpl @@ -0,0 +1,10 @@ + + +
+

+ No crypto currencies are enabled for checkout +

+

+ Note to webmaster: Can be enabled via Setup > Payments > Payment Gateways > Blockonomics > Currencies +

+
diff --git a/modules/gateways/blockonomics/blockonomics.php b/modules/gateways/blockonomics/blockonomics.php index 8f31fa4..10465eb 100644 --- a/modules/gateways/blockonomics/blockonomics.php +++ b/modules/gateways/blockonomics/blockonomics.php @@ -90,16 +90,18 @@ public function getApiKey() */ public function getSupportedCurrencies() { - return [ - 'btc' => [ - 'name' => 'Bitcoin', - 'uri' => 'bitcoin', - ], - 'bch' => [ - 'name' => 'Bitcoin Cash', - 'uri' => 'bitcoincash', - ], - ]; + return array( + 'btc' => array( + 'code' => 'btc', + 'name' => 'Bitcoin', + 'uri' => 'bitcoin' + ), + 'bch' => array( + 'code' => 'bch', + 'name' => 'Bitcoin Cash', + 'uri' => 'bitcoincash' + ) + ); } /* @@ -307,7 +309,7 @@ function ($table) { $table->string('blockonomics_currency'); $table->primary('addr'); $table->decimal('basecurrencyamount', 10, 2); - $table->index('id_order'); + $table->index(['id_order', 'blockonomics_currency']); } ); } catch (Exception $e) { diff --git a/modules/gateways/blockonomics/payment.php b/modules/gateways/blockonomics/payment.php index 10e42f0..979ef25 100644 --- a/modules/gateways/blockonomics/payment.php +++ b/modules/gateways/blockonomics/payment.php @@ -10,30 +10,43 @@ // Init Blockonomics class $blockonomics = new Blockonomics(); -require $blockonomics->getLangFilePath(isset($_REQUEST['language']) ? $_REQUEST['language'] : ''); +require $blockonomics->getLangFilePath(isset($_REQUEST['language']) ? htmlspecialchars($_REQUEST['language']) : ''); $ca = new ClientArea(); - $ca->setPageTitle('Bitcoin Payment'); - $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('payment.php', 'Bitcoin Payment'); - $ca->initPage(); /* * SET POST PARAMETERS TO VARIABLES AND CHECK IF THEY EXIST */ -$get_order = htmlspecialchars(isset($_REQUEST['get_order']) ? $_REQUEST['get_order'] : ''); -$finish_order = htmlspecialchars(isset($_REQUEST['finish_order']) ? $_REQUEST['finish_order'] : ''); - -$order_hash = htmlspecialchars(isset($_REQUEST['order']) ? $_REQUEST['order'] : ''); - -$system_url = App::getSystemURL(); - -if ($get_order) { - $blockonomics_currency = htmlspecialchars(isset($_REQUEST['blockonomics_currency']) ? $_REQUEST['blockonomics_currency'] : ''); - $existing_order = $blockonomics->processOrderHash($get_order, $blockonomics_currency); +$show_order = isset($_GET["show_order"]) ? htmlspecialchars($_GET['show_order']) : ""; +$crypto = isset($_GET["crypto"]) ? htmlspecialchars($_GET['crypto']) : ""; +$select_crypto = isset($_GET["select_crypto"]) ? htmlspecialchars($_GET['select_crypto']) : ""; +$finish_order = isset($_GET["finish_order"]) ? htmlspecialchars($_GET['finish_order']) : ""; +$get_order = isset($_GET['get_order']) ? htmlspecialchars($_GET['get_order']) : ""; + +if($crypto === "empty"){ + $ca->setTemplate('/modules/gateways/blockonomics/assets/templates/no_crypto_selected.tpl'); +}else if ($show_order && $crypto) { + $time_period_from_db = $blockonomics->getTimePeriod(); + $time_period = isset($time_period_from_db) ? $time_period_from_db : '10'; + $ca->assign('time_period', $time_period); + $active_currencies = $blockonomics->getActiveCurrencies(); + $ca->assign('active_currencies', json_encode($active_currencies)); + $ca->setTemplate('/modules/gateways/blockonomics/assets/templates/checkout.tpl'); +}else if ($select_crypto) { + $active_currencies = $blockonomics->getActiveCurrencies(); + $ca->assign('active_currencies', $active_currencies); + $ca->assign('order_hash', $select_crypto); + $ca->setTemplate('/modules/gateways/blockonomics/assets/templates/crypto_options.tpl'); +}else if ($finish_order) { + $finish_url = App::getSystemURL() . 'viewinvoice.php?id=' . $finish_order . '&paymentsuccess=true'; + header("Location: $finish_url"); + exit(); +}else if ($get_order && $crypto) { + $existing_order = $blockonomics->processOrderHash($get_order, $crypto); // No order exists, exit if (is_null($existing_order->id_order)) { exit(); @@ -41,37 +54,9 @@ header('Content-Type: application/json'); exit(json_encode($existing_order)); } -} elseif ($finish_order) { - $finish_url = $system_url . 'viewinvoice.php?id=' . $finish_order . '&paymentsuccess=true'; - header("Location: $finish_url"); - exit(); -} elseif (!$order_hash) { - echo 'Error: Failed to fetch order data.
- Note to admin: Please check that your System URL is configured correctly. - If you are using SSL, verify that System URL is set to use HTTPS and not HTTP.
- To configure System URL, please go to WHMCS admin > Setup > General Settings > General'; - exit(); -} - -$ca->assign('order_uuid', $order_hash); - -$time_period_from_db = $blockonomics->getTimePeriod(); -$time_period = isset($time_period_from_db) ? $time_period_from_db : '10'; -$ca->assign('time_period', $time_period); - -$active_currencies = $blockonomics->getActiveCurrencies(); -if ($active_currencies) { - $ca->assign('active_currencies', json_encode($active_currencies)); -} else { - echo 'Error: No active blockonomics currencies.
- Note to admin: Check your API keys are configured.'; - exit(); } -$order_id = $blockonomics->getOrderIdByHash($order_hash); -$ca->assign('order_id', $order_id); $ca->assign('_BLOCKLANG', $_BLOCKLANG); - -$ca->setTemplate('/modules/gateways/blockonomics/payment.tpl'); - $ca->output(); + +exit(); diff --git a/modules/gateways/blockonomics/payment.tpl b/modules/gateways/blockonomics/payment.tpl deleted file mode 100644 index a9eb183..0000000 --- a/modules/gateways/blockonomics/payment.tpl +++ /dev/null @@ -1,144 +0,0 @@ - - -
-
-
-
-
- -
-
-
- -
-
-
- {$_BLOCKLANG.orderId}[[order_id]] -
-
-
- -
-
-
- -
-

{$_BLOCKLANG.error.btc.title}

-

{$_BLOCKLANG.error.btc.message}

-
- -
-

{$_BLOCKLANG.error.bch.title}

-

{$_BLOCKLANG.error.bch.message}

-
- -
-

{$_BLOCKLANG.error.pending.title}

- {$_BLOCKLANG.error.pending.message} -
- -
-

{$_BLOCKLANG.payWith}

- - - - -
[[active_currency.name]] Logo -

[[active_currency.name]]

-
-
- -
-

{$_BLOCKLANG.paymentExpired}


-

{$_BLOCKLANG.tryAgain}

-
- -
-

{$_BLOCKLANG.paymentError}

-
- -
-
-
-
- - - - -
-
- -
-
- {$_BLOCKLANG.payAmount}
-
- {$_BLOCKLANG.copyClipboard}
-
    -
  • [[order.bits/1.0e8]]
  • -
  • [[order.blockonomics_currency | uppercase]]
  • -
  • -
  • [[order.value]]
  • -
  • [[order.currency]]
  • -
- -
- -
-
- {$_BLOCKLANG.payAddress}
-
- {$_BLOCKLANG.copyClipboard}
-
    -
  • [[order.addr]]
  • -
-
- -
-
-
-
-
- [[clock*1000 | date:'mm:ss' : 'UTC']] - min -
-
-
-
-
-
- -
- {$_BLOCKLANG.howToPay}
-
{$_BLOCKLANG.poweredBy}
-
-
-
-
- - - - - - - - \ No newline at end of file