-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap.php
83 lines (79 loc) · 4.17 KB
/
Bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* This file refers to the initialization of a plugin for the subsequent use
*
* @author Novalnet
* @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\src\NovalnetWebhookHandler;
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);
// Custom frontend operations for the Novalnet Plugin
if (Shop::isFrontend()) {
$novalnetHookHandler = new NovalnetHookHandler($this->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 Wawi refund workflow 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']);
}
if (isset($_REQUEST['novalnet_wawi_invoice'])) {
// When the Wawi generates the invoice workflow 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, 'handleNovalnetInvoice']);
}
}
}
/**
* 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);
}
}