-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9f46f3a
Showing
72 changed files
with
11,470 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Novalnet payment plugin | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Novalnet End User License Agreement | ||
* | ||
* DISCLAIMER | ||
* | ||
* If you wish to customize Novalnet payment extension for your needs, | ||
* please contact technic@novalnet.de for more information. | ||
* | ||
* @author Novalnet AG | ||
* @copyright Copyright (c) Novalnet | ||
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz | ||
* | ||
* Script: Bootstrap.php | ||
* | ||
*/ | ||
|
||
namespace Plugin\jtl_novalnet; | ||
|
||
use JTL\Events\Dispatcher; | ||
use JTL\Plugin\Bootstrapper; | ||
use JTL\Shop; | ||
use JTL\Smarty\JTLSmarty; | ||
use Plugin\jtl_novalnet\frontend\NovalnetHookHandler; | ||
use Plugin\jtl_novalnet\adminmenu\NovalnetBackendTabRenderer; | ||
|
||
/** | ||
* Class Bootstrap | ||
* @package Plugin\jtl_novalnet | ||
*/ | ||
class Bootstrap extends Bootstrapper | ||
{ | ||
/** | ||
* Boot additional services for the payment method | ||
*/ | ||
public function boot(Dispatcher $dispatcher): void | ||
{ | ||
parent::boot($dispatcher); | ||
|
||
if (Shop::isFrontend()) { | ||
|
||
$novalnetHookHandler = new NovalnetHookHandler($this->getPlugin()); | ||
|
||
// Custom frontend operations for the Novalnet Plugin | ||
$dispatcher->listen('shop.hook.' . \HOOK_BESTELLABSCHLUSS_INC_BESTELLUNGINDB, [$novalnetHookHandler, 'orderStatusPage']); | ||
$dispatcher->listen('shop.hook.' . \HOOK_SMARTY_OUTPUTFILTER, [$novalnetHookHandler, 'contentUpdate']); | ||
$dispatcher->listen('shop.hook.' . \HOOK_BESTELLVORGANG_PAGE, [$novalnetHookHandler, 'removeSavedDetails']); | ||
$dispatcher->listen('shop.hook.' . \HOOK_JTL_PAGE, [$novalnetHookHandler, 'accountPage']); | ||
$dispatcher->listen('shop.hook.' . \HOOK_BESTELLABSCHLUSS_INC_BESTELLUNGINDB_ENDE, [$novalnetHookHandler, 'changeWawiPickupStatus']); | ||
|
||
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']); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @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); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Novalnet payment plugin | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Novalnet End User License Agreement | ||
* | ||
* DISCLAIMER | ||
* | ||
* If you wish to customize Novalnet payment extension for your needs, | ||
* please contact technic@novalnet.de for more information. | ||
* | ||
* @author Novalnet AG | ||
* @copyright Copyright (c) Novalnet | ||
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz | ||
* | ||
* Script: Migration20210608221920.php | ||
*/ | ||
|
||
namespace Plugin\jtl_novalnet\Migrations; | ||
|
||
use JTL\Plugin\Migration; | ||
use JTL\Update\IMigration; | ||
|
||
/** | ||
* Class Migration20210608221920 | ||
* @package Plugin\jtl_novalnetag\Migrations | ||
*/ | ||
class Migration20210608221920 extends Migration implements IMigration | ||
{ | ||
/** | ||
* Create Novalnet transaction details table during the novalnet plugin installation | ||
* | ||
*/ | ||
public function up() | ||
{ | ||
$this->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`'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
<?php | ||
/** | ||
* Novalnet payment plugin | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Novalnet End User License Agreement | ||
* | ||
* DISCLAIMER | ||
* | ||
* If you wish to customize Novalnet payment extension for your needs, | ||
* please contact technic@novalnet.de for more information. | ||
* | ||
* @author Novalnet AG | ||
* @copyright Copyright (c) Novalnet | ||
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz | ||
* | ||
* Script: NovalnetPaymentHelper.php | ||
* | ||
*/ | ||
|
||
namespace Plugin\jtl_novalnet; | ||
|
||
use Exception; | ||
use JTL\Plugin\PluginInterface; | ||
use JTL\Shop; | ||
use JTL\Session\Frontend; | ||
use JTL\Catalog\Currency; | ||
use JTL\Plugin\Helper; | ||
|
||
/** | ||
* Class NovalnetPaymentHelper | ||
* @package Plugin\jtl_novalnetag | ||
*/ | ||
class NovalnetPaymentHelper | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
public $plugin; | ||
|
||
/** | ||
* NovalnetPaymentHelper constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->plugin = $this->getNovalnetPluginObject(); | ||
} | ||
|
||
/** | ||
* Get plugin object | ||
* | ||
* @return object | ||
*/ | ||
public function getNovalnetPluginObject() | ||
{ | ||
return Helper::getPluginById('jtl_novalnet'); | ||
} | ||
|
||
/** | ||
* Retrieve configuration values stored under Novalnet Plugin | ||
* | ||
* @param string $configuration | ||
* @param bool|string $paymentName | ||
* @return mixed | ||
*/ | ||
public function getConfigurationValues(string $configuration, $paymentName = false) | ||
{ | ||
$configValue = $paymentName ? $paymentName . '_' . $configuration : $configuration; | ||
|
||
if (!empty($this->plugin->getConfig()->getValue($configValue))) { | ||
|
||
// Only for the tariff ID field, we extract the value which is separated by tariff value and type | ||
if ($configValue == 'novalnet_tariffid') { | ||
$tariffValue = trim($this->plugin->getConfig()->getValue('novalnet_tariffid')); | ||
$tariffId = explode('-', $tariffValue); | ||
return $tariffId[0]; | ||
} | ||
return is_string($this->plugin->getConfig()->getValue($configValue)) ? trim($this->plugin->getConfig()->getValue($configValue)) : $this->plugin->getConfig()->getValue($configValue); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Returning the list of the European Union countries for checking the country code of Guaranteed consumer | ||
* | ||
* @return array | ||
*/ | ||
public function getEuropeanRegionCountryCodes(): array | ||
{ | ||
return ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', 'UK', 'CH']; | ||
} | ||
|
||
/** | ||
* Building the required billing and shipping details from customer session | ||
* | ||
* @return array | ||
*/ | ||
public function getRequiredBillingShippingDetails(): array | ||
{ | ||
// Extracting the billing address from Frontend Module | ||
$billingAddress = Frontend::getCustomer(); | ||
|
||
$billingShippingDetails['billing'] = [ | ||
'street' => $billingAddress->cStrasse, | ||
'house_no' => $billingAddress->cHausnummer, | ||
'city' => $billingAddress->cOrt, | ||
'zip' => $billingAddress->cPLZ, | ||
'country_code' => $billingAddress->cLand | ||
]; | ||
|
||
// Extracting the shipping address from the session object | ||
$shippingAddress = $_SESSION['Lieferadresse']; | ||
|
||
$billingShippingDetails['shipping'] = [ | ||
'street' => $shippingAddress->cStrasse, | ||
'house_no' => $shippingAddress->cHausnummer, | ||
'city' => $shippingAddress->cOrt, | ||
'zip' => $shippingAddress->cPLZ, | ||
'country_code' => $shippingAddress->cLand | ||
]; | ||
return $billingShippingDetails; | ||
} | ||
|
||
/** | ||
* Retrieving the reference details for one-click shopping | ||
* | ||
* @param string $paymentName | ||
* @return array | ||
*/ | ||
public function getPaymentReferenceValues($paymentName): ?array | ||
{ | ||
$customerDetails = Frontend::getCustomer(); | ||
|
||
if (!empty($customerDetails->kKunde)) { | ||
$storedValues = Shop::Container()->getDB()->query('SELECT nNntid, cStatuswert, cTokenInfo FROM xplugin_novalnet_transaction_details WHERE cZahlungsmethode LIKE "%' . $paymentName . '" AND cMail = "' . $customerDetails->cMail . '" AND cSaveOnetimeToken = 1 AND cTokenInfo != "" ORDER BY kId DESC LIMIT 3', 2); | ||
return !empty($storedValues) ? $storedValues : null; | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Convert the order amount from decimal to integer | ||
* | ||
* @return int | ||
*/ | ||
public function getOrderAmount(): int | ||
{ | ||
$convertedOrderAmount = Currency::convertCurrency(Frontend::getCart()->gibGesamtsummeWaren(true), Frontend::getCurrency()->getCode()); | ||
if (empty($convertedOrderAmount)) { | ||
$convertedOrderAmount = $_SESSION['Warenkorb']->gibGesamtsummeWaren(true); | ||
} | ||
return (int) ($convertedOrderAmount * 100); | ||
} | ||
|
||
/** | ||
* Process the database update | ||
* | ||
* @param string $tableName | ||
* @param string $keyName | ||
* @param string $keyValue | ||
* @param object $object | ||
* @return none | ||
*/ | ||
public function performDbUpdateProcess(string $tableName, $keyName, $keyValue, $object): void | ||
{ | ||
Shop::Container()->getDB()->update($tableName , $keyName , $keyValue, (object) $object); | ||
} | ||
|
||
/** | ||
* Unsets the Novalnet payment sessions | ||
* | ||
* @return none | ||
*/ | ||
public function novalnetSessionCleanUp(string $paymentName): void | ||
{ | ||
$sessionValues = array( | ||
'nn_'.$paymentName.'_request', | ||
'nn_'.$paymentName.'_payment_response', | ||
'nn_comments' | ||
); | ||
|
||
foreach($sessionValues as $sessionVal) { | ||
unset($_SESSION[$paymentName]); | ||
unset($_SESSION[$sessionVal]); | ||
} | ||
} | ||
|
||
/** | ||
* Get language texts for the fields | ||
* | ||
* @param array $languages | ||
* @return array | ||
*/ | ||
public function getNnLanguageText(array $languages, $langCode = null): array | ||
{ | ||
foreach($languages as $lang) { | ||
$languageTexts[$lang] = $this->plugin->getLocalization()->getTranslation($lang, $langCode); | ||
} | ||
return $languageTexts; | ||
} | ||
|
||
/** | ||
* Get translated text for the provided Novalnet text key | ||
* | ||
* @param string $key | ||
* @return string | ||
*/ | ||
public function getNnLangTranslationText(string $key, $langCode = null): string | ||
{ | ||
return $this->plugin->getLocalization()->getTranslation($key, $langCode); | ||
} | ||
} |
Oops, something went wrong.