diff --git a/Bootstrap.php b/Bootstrap.php
new file mode 100644
index 0000000..bfc4d1b
--- /dev/null
+++ b/Bootstrap.php
@@ -0,0 +1,78 @@
+getPlugin());
+ // Display the Novalnet transaction comments on order status page when payment before order completion option is set to 'Ja'
+ $dispatcher->listen('shop.hook.' . \HOOK_BESTELLABSCHLUSS_INC_BESTELLUNGINDB, [$novalnetHookHandler, 'orderStatusPage']);
+ // Loads the Novalnet Payment form on the checkout page
+ $dispatcher->listen('shop.hook.' . \HOOK_BESTELLVORGANG_PAGE_STEPZAHLUNG, [$novalnetHookHandler, 'displayNnPaymentForm']);
+ // Used for the frontend template customization
+ $dispatcher->listen('shop.hook.' . \HOOK_SMARTY_OUTPUTFILTER, [$novalnetHookHandler, 'contentUpdate']);
+ // Display the Novalnet transaction comments aligned in My Account page of the user
+ $dispatcher->listen('shop.hook.' . \HOOK_JTL_PAGE, [$novalnetHookHandler, 'accountPage']);
+ // Change the WAWI pickup status as 'JA' before payment completion
+ $dispatcher->listen('shop.hook.' . \HOOK_BESTELLABSCHLUSS_INC_BESTELLUNGINDB_ENDE, [$novalnetHookHandler, 'changeWawiPickupStatus']);
+ // Change the payment name based on the customer chosen payment in the payment form
+ $dispatcher->listen('shop.hook.' . \HOOK_BESTELLVORGANG_PAGE_STEPBESTAETIGUNG, [$novalnetHookHandler, 'updatePaymentName']);
+ // Handle the webhook process
+ if (isset($_REQUEST['novalnet_webhook'])) {
+ // When the Novalnet webhook is triggered and known through URL, we call the appropriate Novalnet webhook handler
+ $novalnetWebhookHandler = new NovalnetWebhookHandler($this->getPlugin());
+ $dispatcher->listen('shop.hook.' . \HOOK_INDEX_NAVI_HEAD_POSTGET, [$novalnetWebhookHandler, 'handleNovalnetWebhook']);
+ }
+ if (isset($_REQUEST['novalnet_refund'])) {
+ // When the Novalnet webhook is triggered and known through URL, we call the appropriate Novalnet webhook handler
+ $novalnetWebhookHandler = new NovalnetWebhookHandler($this->getPlugin());
+ $dispatcher->listen('shop.hook.' . \HOOK_INDEX_NAVI_HEAD_POSTGET, [$novalnetWebhookHandler, 'handleNovalnetRefund']);
+ }
+ }
+ }
+
+ /**
+ * Render the Novalnet admin tabs in the shop backend
+ *
+ * @param string $tabName
+ * @param int $menuID
+ * @param JTLSmarty $smarty
+ * @return string
+ */
+ public function renderAdminMenuTab(string $tabName, int $menuID, JTLSmarty $smarty): string
+ {
+ // Render Novalnet Plugin's backend tabs and it's related functions
+ $backendRenderer = new NovalnetBackendTabRenderer($this->getPlugin(), $this->getDB());
+ return $backendRenderer->renderNovalnetTabs($tabName, $menuID, $smarty);
+ }
+}
diff --git a/Migrations/Migration20210608221920.php b/Migrations/Migration20210608221920.php
new file mode 100644
index 0000000..9ff6c38
--- /dev/null
+++ b/Migrations/Migration20210608221920.php
@@ -0,0 +1,69 @@
+execute('CREATE TABLE IF NOT EXISTS `xplugin_novalnet_transaction_details` (
+ `kId` int(10) NOT NULL AUTO_INCREMENT,
+ `cNnorderid` VARCHAR(64) NOT NULL,
+ `nNntid` BIGINT(20) NOT NULL,
+ `cZahlungsmethode` VARCHAR(64) NOT NULL,
+ `cMail` VARCHAR(255) NOT NULL,
+ `cStatuswert` VARCHAR(64),
+ `nBetrag` INT(11) NOT NULL,
+ `cSaveOnetimeToken` TINYINT(1) DEFAULT 0,
+ `cTokenInfo` LONGTEXT DEFAULT NULL,
+ `cAdditionalInfo` LONGTEXT DEFAULT NULL,
+ INDEX (cNnorderid, nNntid, cZahlungsmethode),
+ PRIMARY KEY (`kId`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
+ );
+
+ $this->execute('CREATE TABLE IF NOT EXISTS `xplugin_novalnet_callback` (
+ `kId` INT(10) NOT NULL AUTO_INCREMENT,
+ `cNnorderid` VARCHAR(64) NOT NULL,
+ `nCallbackTid` BIGINT(20) NOT NULL,
+ `nReferenzTid` BIGINT(20) NOT NULL,
+ `cZahlungsmethode` VARCHAR(64) NOT NULL,
+ `dDatum` datetime NOT NULL,
+ `nCallbackAmount` INT(11) DEFAULT NULL,
+ `cWaehrung` VARCHAR(64) DEFAULT NULL,
+ INDEX (cNnorderid),
+ PRIMARY KEY (`kId`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
+ );
+ }
+
+ /**
+ * Delete Novalnet transaction details table during the novalnet plugin uninstallation
+ *
+ */
+ public function down()
+ {
+ $this->execute('DROP TABLE IF EXISTS `xplugin_novalnet_transaction_details`');
+ $this->execute('DROP TABLE IF EXISTS `xplugin_novalnet_callback`');
+ }
+}
diff --git a/Migrations/Migration20230303113003.php b/Migrations/Migration20230303113003.php
new file mode 100644
index 0000000..2f89ab4
--- /dev/null
+++ b/Migrations/Migration20230303113003.php
@@ -0,0 +1,52 @@
+execute('ALTER TABLE xplugin_novalnet_transaction_details
+ ADD COLUMN `nCallbackAmount` INT(11) DEFAULT NULL,
+ DROP COLUMN cSaveOnetimeToken,
+ DROP COLUMN cTokenInfo'
+ );
+ // Check if the callback history table already exist or not
+ $isCallbackTableExists = Shop::Container()->getDB()->queryPrepared("SHOW TABLES LIKE :callback", [":callback" => "%xplugin_novalnet_callback%"]);
+ if ($isCallbackTableExists) {
+ $previousCallBackDetails = Shop::Container()->getDB()->queryPrepared("SELECT nc.nCallbackTid callbackTid, sum(nc.nCallbackAmount) callbackAmount FROM xplugin_novalnet_callback nc, xplugin_novalnet_transaction_details nt WHERE nc.nCallbackTid = :nCallbackTid group by :nCallbackTid", [":nCallbackTid" => "nt.nNntid", ":nCallbackTid" => "nc.nCallbackTid"]);
+ if (is_array($previousCallBackDetails) || is_object($previousCallBackDetails)) {
+ foreach ($previousCallBackDetails as $previousCallBackDetail) {
+ $previousCallBackDetails = Shop::Container()->getDB()->queryPrepared("UPDATE xplugin_novalnet_transaction_details SET nCallbackAmount = :callbackamount WHERE nNntid = :nCallbackTid and nCallbackAmount IS NULL LIMIT 1", [":callbackamount" => "$previousCallBackDetail->callbackAmount", ":nCallbackTid" => "$previousCallBackDetail->callbackTid"]);
+ }
+ }
+ // After updating the values to xplugin_novalnet_transaction_details from callback history table and the delete the below table
+ $this->execute('DROP TABLE `xplugin_novalnet_callback`');
+ }
+ }
+
+ public function down()
+ {
+
+ }
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c4e5c36
--- /dev/null
+++ b/README.md
@@ -0,0 +1,87 @@
+# JTL5 SHOP PAYMENT PLUGIN BY NOVALNET
+
+The JTL shop payment plugin by Novalnet enables secure integration of payments and payment services for all JTL shops. Novalnet payment plugin for JTL shop helps merchants to automate payment processing from checkout till collection.
+
+## Integration Requirements for JTL5 Shop Payment Plugin
+
+The module is available for the 5.0.0 - 5.3.2 versions in the following languages: EN & DE and requires PHP versions 5.6 and higher.
+Novalnet merchant account is required for processing all international and local payments in JTL shop. You can get yours here: https://www.novalnet.de/kontakt/sales
+
+## Key Features of JTL5 Shop Payment Plugin
+
+* Easy configuration of all payment methods (local & international)
+* Up-to-date payment portfolio & automated processing
+* Plug & Play platform eliminating the need of extra plugins/scripts/contracts
+* PCI-certified payment integration
+* Credit Card with 3D Secure
+* Seamless checkout Iframe integration
+* Comprehensive fraud prevention solution with more than 60 modules
+* Secure SSL encoded gateways
+* On-hold transaction configuration in the shop admin panel
+* One click shopping supported Credit/Debit Cards & Direct Debit SEPA
+* Zero amount authorization supported for Credit/Debit Cards, Direct Debit SEPA, Apple Pay & Google Pay
+* Real-time synchronization of data between JTL-Shop and JTL-Wawi
+* Responsive templates
+
+For detailed documentation and other technical inquiries, please send us an email at sales@novalnet.de
+
+## Integrated Payment Methods
+
+- Direct Debit SEPA
+- Direct Debit ACH
+- Credit/Debit Cards
+- Apple Pay
+- Google Pay
+- Invoice
+- Prepayment
+- Invoice with payment guarantee
+- Direct Debit SEPA with payment guarantee
+- Instalment by Invoice
+- Instalment by Direct Debit SEPA
+- iDEAL
+- Sofort
+- giropay
+- Barzahlen/viacash
+- Przelewy24
+- eps
+- PayPal
+- MB Way
+- PostFinance Card
+- PostFinance E-Finance
+- Bancontact
+- Multibanco
+- Online bank transfer
+- Alipay
+- WeChat Pay
+- Trustly
+- Blik
+- Payconiq
+
+## Installation of JTL5 Shop Payment Plugin
+
+Follow these steps for JTL shop Payment Integration by Novalnet:
+1. Get the payment plugin for JTL shop & detailed documentation by contacting us
+2. Upload the payment plugin to your JTL shop
+3. Activate the plugin
+4. Configure Product Activation Key & Payment access key in the shop admin panel
+5. Activate & configure the preferred payment types in your shop admin panel
+
+## License
+
+See our License Agreement at: https://www.novalnet.com/payment-plugins-free-license/
+
+## Documentation & Support
+
+If you have any inquiries, please contact one of the following departments:
+
+### Technical support
+technic@novalnet.de
++49 89 9230683-19
+
+### Sales team
+sales@novalnet.de
++49 89 9230683-20
+
+## Who is Novalnet?
+
+Novalnet AG is a German payment provider offering payment gateways for online merchants and marketplaces worldwide. Our PCI DSS certified SaaS engine is designed to automate the entire payment process from checkout to debt collection – with a single integration. We cover real-time risk management; secure payments (local + international) through escrow accounts, integrate receivables management, dynamic member and subscription management as well as other customized payment solutions to your JTL shop. For a complete and seamless shop system we do support JTL-Wawi integration for JTL shop.
diff --git a/adminmenu/NovalnetBackendTabRenderer.php b/adminmenu/NovalnetBackendTabRenderer.php
new file mode 100644
index 0000000..0e245d4
--- /dev/null
+++ b/adminmenu/NovalnetBackendTabRenderer.php
@@ -0,0 +1,226 @@
+plugin = $plugin;
+ $this->db = $db;
+ $this->novalnetPaymentGateway = new NovalnetPaymentGateway();
+ }
+
+ /**
+ * @param string $tabName
+ * @param int $menuID
+ * @param JTLSmarty $smarty
+ * @return string
+ * @throws \SmartyException
+ */
+ public function renderNovalnetTabs(string $tabName, int $menuID, JTLSmarty $smarty): string
+ {
+ $this->smarty = $smarty;
+
+ if ($tabName == 'Info') {
+ return $this->renderNovalnetInfoPage();
+ } elseif ($tabName == 'Bestellungen') {
+ return $this->renderNovalnetOrdersPage($menuID);
+ } else {
+ throw new InvalidArgumentException('Cannot render tab ' . $tabName);
+ }
+ }
+
+ /**
+ * Display the Novalnet info template page
+ *
+ * @return string
+ */
+ private function renderNovalnetInfoPage(): string
+ {
+ $request = $_REQUEST;
+ $novalnetRequestType = !empty($request['nn_request_type']) ? $request['nn_request_type'] : null;
+ $langCode = ($_SESSION['AdminAccount']->language == 'de-DE') ? 'ger' : 'eng';
+ $configuredWebhookUrl = $this->novalnetPaymentGateway->novalnetPaymentHelper->getConfigurationValues('novalnet_webhook_url');
+ $novalnetWebhookUrl = !empty($configuredWebhookUrl) ? $configuredWebhookUrl : Shop::getURL() . '/?novalnet_webhook';
+
+ if (!empty($novalnetRequestType)) {
+ // Based on the request type, we either auto-configure the merchant settings or configure the webhook URL
+ if ($novalnetRequestType == 'autofill') {
+ $this->handleMerchantAutoConfig($request);
+ } elseif ($novalnetRequestType == 'configureWebhook') {
+ $this->configureWebhookUrl($request);
+ }
+ }
+
+ return $this->smarty->assign('postUrl', Shop::getURL() . '/' . \PFAD_ADMIN . 'plugin.php?kPlugin=' . $this->plugin->getID())
+ ->assign('languageTexts', $this->novalnetPaymentGateway->novalnetPaymentHelper->getNnLanguageText(['jtl_novalnet_notification_text', 'jtl_novalnet_configure_webhook', 'jtl_novalnet_webhook_alert_text', 'jtl_novalnet_webhook_notification_text', 'jtl_novalnet_webhook_error_text', 'jtl_novalnet_webhook_configuration_tooltip', 'jtl_novalnet_webhook_notification', 'jtl_novalnet_info_page_text'], $langCode))
+ ->assign('adminUrl', $this->plugin->getPaths()->getadminURL())
+ ->assign('webhookUrl', $novalnetWebhookUrl)
+ ->fetch($this->plugin->getPaths()->getAdminPath() . 'templates/novalnet_info.tpl');
+ }
+
+ /**
+ * Display the Novalnet order template
+ *
+ * @param int $menuID
+ * @return string
+ */
+ private function renderNovalnetOrdersPage(int $menuID): string
+ {
+ $request = $_REQUEST;
+ $novalnetRequestType = !empty($request['nn_request_type']) ? $request['nn_request_type'] : null;
+
+ if (!empty($novalnetRequestType)) {
+ $this->displayNovalnetorderDetails($request['order_no'], $menuID);
+ }
+
+ $orders = [];
+ $nnOrderCount = $this->db->query('SELECT cNnorderid FROM xplugin_novalnet_transaction_details', ReturnType::AFFECTED_ROWS);
+ $pagination = (new Pagination('novalnetorders'))->setItemCount($nnOrderCount)->assemble();
+ $langCode = ($_SESSION['AdminAccount']->language == 'de-DE') ? 'ger' : 'eng';
+
+ $orderArr = $this->db->query('SELECT DISTINCT ord.kBestellung FROM tbestellung ord JOIN xplugin_novalnet_transaction_details nov WHERE ord.cBestellNr = nov.cNnorderid ORDER BY ord.kBestellung DESC LIMIT ' . $pagination->getLimitSQL(), ReturnType::ARRAY_OF_OBJECTS);
+
+ foreach ($orderArr as $order) {
+ $orderId = (int) $order->kBestellung;
+ $ordObj = new Bestellung($orderId);
+ $ordObj->fuelleBestellung(true, 0, false);
+ $orders[$orderId] = $ordObj;
+ }
+
+ if ($_SESSION['AdminAccount']->language == 'de-DE') {
+ $paymentStatus = ['5' => 'teilversendet', '4' => 'versendet', '3' => 'bezahlt', '2' => 'in Bearbeitung' , '1' => 'neu' , '-1' => 'storniert'];
+ } else {
+ $paymentStatus = ['5' => 'partially delivered', '4' => 'shipped', '3' => 'paid', '2' => 'in progress' , '1' => 'new' , '-1' => 'cancelled'];
+ }
+
+ return $this->smarty->assign('orders', $orders)
+ ->assign('pagination', $pagination)
+ ->assign('pluginId', $this->plugin->getID())
+ ->assign('postUrl', Shop::getURL() . '/' . \PFAD_ADMIN . 'plugin.php?kPlugin=' . $this->plugin->getID())
+ ->assign('paymentStatus', $paymentStatus)
+ ->assign('hash', 'plugin-tab-' . $menuID)
+ ->assign('adminUrl', $this->plugin->getPaths()->getadminURL())
+ ->assign('languageTexts', $this->novalnetPaymentGateway->novalnetPaymentHelper->getNnLanguageText(['jtl_novalnet_order_number', 'jtl_novalnet_customer_text', 'jtl_novalnet_payment_name_text', 'jtl_novalnet_wawi_pickup', 'jtl_novalnet_total_amount_text', 'jtl_novalnet_order_creation_date', 'jtl_novalnet_orders_not_available', 'jtl_novalnet_order_status'], $langCode))
+ ->fetch($this->plugin->getPaths()->getAdminPath() . 'templates/novalnet_orders.tpl');
+ }
+
+ /**
+ * Handling of the merchant auto configuration process
+ *
+ * @param array $post
+ * @return none
+ */
+ private function handleMerchantAutoConfig(array $post): void
+ {
+ $autoConfigRequestParams = [];
+ $autoConfigRequestParams['merchant']['signature'] = $post['nn_public_key'];
+ $autoConfigRequestParams['custom']['lang'] = ($_SESSION['AdminAccount']->language == 'de-DE') ? 'DE' : 'EN';
+
+ $responseData = $this->novalnetPaymentGateway->performServerCall($autoConfigRequestParams, 'merchant_details', $post['nn_private_key']);
+ print json_encode($responseData);
+ exit;
+ }
+
+
+ /**
+ * Configuring webhook URL in admin portal
+ *
+ * @param array $post
+ * @return none
+ */
+ private function configureWebhookUrl(array $post): void
+ {
+ $webhookRequestParams = [];
+ $webhookRequestParams['merchant']['signature'] = $post['nn_public_key'];
+ $webhookRequestParams['webhook']['url'] = $post['nn_webhook_url'];
+ $webhookRequestParams['custom']['lang'] = ($_SESSION['AdminAccount']->language == 'de-DE') ? 'DE' : 'EN';
+
+ $responseData = $this->novalnetPaymentGateway->performServerCall($webhookRequestParams, 'webhook_configure', $post['nn_private_key']);
+
+ // Upon successful intimation in Novalnet server, we also store it in the internal DB
+ if ($responseData['result']['status'] == 'SUCCESS') {
+ $this->novalnetPaymentGateway->novalnetPaymentHelper->performDbUpdateProcess('tplugineinstellungen', 'cName', 'novalnet_webhook_url', ['cWert' => $post['nn_webhook_url']]);
+ }
+
+ print json_encode($responseData);
+ exit;
+ }
+
+ /**
+ * Display the Novalnet transaction details template
+ *
+ * @param mixed $orderNo
+ * @param int $menuID
+ * @return string
+ */
+ private function displayNovalnetorderDetails($orderNo, int $menuID): string
+ {
+ $getOrderComment = $this->db->query('SELECT ord.cKommentar, ord.kSprache FROM tbestellung ord JOIN xplugin_novalnet_transaction_details nov ON ord.cBestellNr = nov.cNnorderid WHERE cNnorderid = "' . $orderNo . '"', ReturnType::SINGLE_OBJECT);
+
+ $langCode = ($getOrderComment->kSprache == 1) ? 'ger' : 'eng';
+
+ $instalmentInfo = $this->novalnetPaymentGateway->getInstalmentInfoFromDb($orderNo, $langCode);
+
+ $smartyVar = $this->smarty->assign('adminUrl', $this->plugin->getPaths()->getadminURL())
+ ->assign('orderNo', $orderNo)
+ ->assign('languageTexts',$this->novalnetPaymentGateway->novalnetPaymentHelper->getNnLanguageText(['jtl_novalnet_invoice_payments_order_number_reference'], $langCode))
+ ->assign('orderComment', $getOrderComment)
+ ->assign('menuId', '#plugin-tab-' . $menuID)
+ ->assign('instalmentDetails', $instalmentInfo)
+ ->fetch($this->plugin->getPaths()->getAdminPath() . 'templates/novalnet_order_details.tpl');
+
+ print $smartyVar;
+ exit;
+ }
+}
diff --git a/adminmenu/css/novalnet_admin.css b/adminmenu/css/novalnet_admin.css
new file mode 100644
index 0000000..b86d38a
--- /dev/null
+++ b/adminmenu/css/novalnet_admin.css
@@ -0,0 +1,36 @@
+.nn_fa {
+ float: right;
+ font-size: 15px;
+}
+
+#nn_header {
+ color :#e85b0e;
+ font-size:14px;
+ font-weight:bold;
+}
+
+.body_div {
+ padding:5px;
+ overflow-y:auto;
+ margin-bottom : 2%;
+ height:82%;
+}
+
+#overlay_window_block_body h1 {
+ font-weight:bold;
+}
+
+#nn_transaction_details {
+ line-height: 2.0;
+}
+
+.nn_back_tab {
+ color: white;
+ float: right;
+ padding-left: 15px;
+ padding-right: 15px;
+}
+
+.nn_webhook_button, .nn_webhook_notify {
+ margin-left: 35% !important;
+}
diff --git a/adminmenu/js/novalnet_admin.js b/adminmenu/js/novalnet_admin.js
new file mode 100644
index 0000000..cff0481
--- /dev/null
+++ b/adminmenu/js/novalnet_admin.js
@@ -0,0 +1,251 @@
+/*
+ * This script is used for Novalnet plugin admin management process
+ *
+ * @author Novalnet
+ * @copyright Copyright (c) Novalnet
+ * @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz
+ *
+*/
+
+jQuery(document).ready(function() {
+ // set the toggle for the payment settings
+ var paymentSettings = jQuery('.tab-content').children()[2];
+
+ jQuery(paymentSettings).find('[class*=subheading]').append('');
+
+ jQuery(paymentSettings).find('.mb-3').hover(function () {
+ jQuery(this).css('cursor', 'pointer');
+ });
+
+ // Payment settings toggle
+ jQuery('.nn_fa').each(function(){
+ jQuery(this).parent().addClass('nn-toggle-heading');
+ jQuery(this).parent().next().next().addClass('nn-toggle-content');
+ });
+ jQuery('.nn-toggle-content').hide();
+
+ jQuery('.nn-toggle-heading').on('click',function(){
+ jQuery(this).next().next().toggle(700);
+ if( jQuery(this).children('i').hasClass('fa-chevron-circle-down') ) {
+ jQuery(this).children('i').addClass('fa-chevron-circle-up').removeClass('fa-chevron-circle-down');
+ } else {
+ jQuery(this).children('i').addClass('fa-chevron-circle-down').removeClass('fa-chevron-circle-up');
+ }
+ });
+
+ if (jQuery('#novalnet_tariffid').val() == undefined) {
+ jQuery('input[name=novalnet_tariffid]').attr('id', 'novalnet_tariffid');
+ }
+
+ // Display the alert box if the public and private key was not configured
+ if (jQuery('input[name=novalnet_public_key]').val() == '' && jQuery('input[name=novalnet_private_key]').val() == '') {
+ if (jQuery('.nn_mandatory_alert').length == 0) {
+ jQuery('.content-header').prepend('
' + ' ' + jQuery('input[name=nn_lang_notification]').val() + '
');
+ }
+ }
+
+ // Autofill the merchant details
+ if (jQuery('input[name=novalnet_public_key]').val() != undefined && jQuery('input[name=novalnet_public_key]').val() != '') {
+ fillMerchantConfiguration();
+ } else if (jQuery('input[name=novalnet_public_key]').val() == '') {
+ jQuery('#novalnet_tariffid').val('');
+ }
+
+ jQuery('input[name=novalnet_public_key], input[name=novalnet_private_key]' ).on('change', function () {
+ if (jQuery('input[name=novalnet_public_key]').val() != '' && jQuery('input[name=novalnet_private_key]').val() != '') {
+ fillMerchantConfiguration();
+ } else {
+ jQuery('#novalnet_tariffid').val('');
+ }
+ });
+
+ // Set the webhook URL
+ jQuery('input[name=novalnet_webhook_url]').val(jQuery('#nn_webhook_url').val());
+
+ if (jQuery('.nn_webhook_button').length == 0) {
+ jQuery('#novalnet_webhook_url').parent().parent().after(' ');
+ }
+ jQuery('#nn_webhook_configure_button').on('click', function() {
+ if(jQuery('#novalnet_webhook_url').val() != undefined && jQuery('#novalnet_webhook_url').val() != '') {
+ alert(jQuery('input[name=nn_webhook_change]').val());
+ configureWebhookUrlAdminPortal();
+ } else {
+ alert(jQuery('input[name=nn_webhook_invalid]').val());
+ }
+ });
+
+ // Display the webhook test mode activation message
+ if (jQuery('.nn_webhook_notify').length == 0) {
+ jQuery('#novalnet_webhook_testmode').parent().parent().parent().parent().after(('' + jQuery('#nn_webhook_notification').val() + '
'));
+ }
+
+ // While click the back button in the Novalnet order history show the order table
+ jQuery(document).on('click', '.nn_back_tab', function() {
+ jQuery('.nn_order_table').show();
+ jQuery('#nn_transaction_info').hide();
+ jQuery('.pagination-toolbar').show();
+ });
+});
+
+function fillMerchantConfiguration() {
+ var autoconfigurationRequestParams = { 'nn_public_key' : jQuery('input[name=novalnet_public_key]').val(), 'nn_private_key' : jQuery('input[name=novalnet_private_key]').val(), 'nn_request_type' : 'autofill' };
+ transactionRequestHandler(autoconfigurationRequestParams);
+}
+
+function transactionRequestHandler(requestParams)
+{
+ requestParams = typeof(requestParams !== 'undefined') ? requestParams : '';
+
+ var requestUrl = jQuery('input[id=nn_post_url]').val() ;
+ if ('XDomainRequest' in window && window.XDomainRequest !== null) {
+ var xdr = new XDomainRequest();
+ var query = jQuery.param(requestParams);
+ xdr.open('GET', requestUrl + query) ;
+ xdr.onload = function () {
+ autofillMerchantDetails(this.responseText);
+ };
+ xdr.onerror = function () {
+ _result = false;
+ };
+ xdr.send();
+ } else {
+ jQuery.ajax({
+ url : requestUrl,
+ type : 'post',
+ dataType : 'html',
+ data : requestParams,
+ global : false,
+ async : false,
+ success : function (result) {
+ autofillMerchantDetails(result);
+ }
+ });
+ }
+}
+
+function autofillMerchantDetails(result)
+{
+ var fillParams = jQuery.parseJSON(result);
+
+ if (fillParams.result.status != 'SUCCESS') {
+ jQuery('input[name="novalnet_public_key"],input[name="novalnet_private_key"]').val('');
+ jQuery('.content-header').prepend('' + fillParams.result.status_text + '
');
+ jQuery('#novalnet_tariffid').val('');
+ return false;
+ }
+
+ var tariffKeys = Object.keys(fillParams.merchant.tariff);
+ var saved_tariff_id = jQuery('#novalnet_tariffid').val();
+ var tariff_id;
+
+ try {
+ var select_text = decodeURIComponent(escape('Auswählen'));
+ } catch(e) {
+ var select_text = 'Auswählen';
+ }
+
+ jQuery('#novalnet_tariffid').replaceWith('');
+
+ jQuery('#novalnet_tariffid').find('option').remove();
+
+ for (var i = 0; i < tariffKeys.length; i++)
+ {
+ if (tariffKeys[i] !== undefined) {
+ jQuery('#novalnet_tariffid').append(
+ jQuery(
+ '