Skip to content

Commit 61ed2cf

Browse files
authored
Added configuration for payment status (#11)
* Added configuration for payment status * Update info.xml * Updated assets
1 parent cfceacd commit 61ed2cf

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

Src/Services/ConfigService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function getWebhooksSecret()
4242
return $this->config->getValue('webhooks_secret');
4343
}
4444

45+
public function shouldMarkOrderAsPaid()
46+
{
47+
return $this->config->getValue('mark_order_as_paid') == '1';
48+
}
49+
4550
public function getPaymentMethodGroupEnabled()
4651
{
4752
return $this->config->getValue('payment_method_group_enabled');

info.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PluginID>MonduPayment</PluginID>
88
<XMLVersion>100</XMLVersion>
99
<ShopVersion>5.0.0</ShopVersion>
10-
<Version>1.0.11</Version>
10+
<Version>1.0.12</Version>
1111
<CreateDate>2022-06-07</CreateDate>
1212
<Install>
1313
<Hooks>
@@ -37,6 +37,15 @@
3737
<Description>Please enter your Mondu Webhooks Secret.</Description>
3838
<ValueName>webhooks_secret</ValueName>
3939
</Setting>
40+
<Setting type="selectbox" initialValue="1" sort="1" conf="Y">
41+
<Name>Mark order status as "Paid"?</Name>
42+
<Description>If set to "Yes" in JTL Wawi, column "Is Paid" will be set to Yes.</Description>
43+
<ValueName>mark_order_as_paid</ValueName>
44+
<SelectboxOptions>
45+
<Option value="1" sort="0">Yes</Option>
46+
<Option value="0" sort="1">No</Option>
47+
</SelectboxOptions>
48+
</Setting>
4049
<Setting type="none" initialValue="" sort="1" conf="Y">
4150
<Name>Invoice Payment Method Benefits</Name>
4251
<Description>Sie haben die volle Kontrolle. Sie können den Betrag jederzeit innerhalb von {net_term} Tagen überweisen.|Datenschutz ist uns wichtig - Ihre Daten werden lediglich zur Identifizierung verwendet.</Description>
@@ -56,7 +65,7 @@
5665
</Setting>
5766
</Settingslink>
5867
<Settingslink sort="2">
59-
<Name>Net Term Configuration</Name>
68+
<Name>Layout Configuration</Name>
6069
<Setting type="radio" initialValue="1" sort="1" conf="Y">
6170
<Name>Enable Payment Method Group</Name>
6271
<Description>When enabled, payment methods will be grouped by net terms.</Description>
@@ -476,7 +485,7 @@
476485
<position>body</position>
477486
</file>
478487
<file>
479-
<name>plugin-1-0-11.js</name>
488+
<name>plugin-1-0-12.js</name>
480489
<priority>1</priority>
481490
<position>body</position>
482491
</file>
@@ -489,7 +498,7 @@
489498

490499
<CSS>
491500
<file>
492-
<name>style-1-0-11.css</name>
501+
<name>style-1-0-12.css</name>
493502
<priority>4</priority>
494503
</file>
495504
</CSS>

paymentmethod/MonduPayment.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use JTL\Checkout\Bestellung;
1313
use Plugin\MonduPayment\Src\Support\HttpClients\MonduClient;
1414
use Plugin\MonduPayment\Src\Models\MonduOrder;
15+
use Plugin\MonduPayment\Src\Services\ConfigService;
1516

1617

1718
/**
@@ -24,6 +25,7 @@ public function preparePaymentProcess($order): void
2425
{
2526
parent::preparePaymentProcess($order);
2627

28+
$configService = new ConfigService();
2729
$monduClient = new MonduClient();
2830

2931
$monduClient->updateExternalInfo([
@@ -39,17 +41,20 @@ public function preparePaymentProcess($order): void
3941
'order_uuid' => $_SESSION['monduOrderUuid']
4042
]);
4143

42-
$payValue = $order->fGesamtsumme;
43-
$hash = $this->generateHash($order);
44+
if ($configService->shouldMarkOrderAsPaid())
45+
{
46+
$payValue = $order->fGesamtsumme;
47+
$hash = $this->generateHash($order);
4448

45-
$this->deletePaymentHash($hash);
46-
$this->addIncomingPayment($order, (object)[
47-
'fBetrag' => $payValue,
48-
'cZahler' => 'Mondu',
49-
'cHinweis' => $_SESSION['monduOrderUuid'],
50-
]);
49+
$this->deletePaymentHash($hash);
50+
$this->addIncomingPayment($order, (object)[
51+
'fBetrag' => $payValue,
52+
'cZahler' => 'Mondu',
53+
'cHinweis' => $_SESSION['monduOrderUuid'],
54+
]);
5155

52-
$this->setOrderStatusToPaid($order);
56+
$this->setOrderStatusToPaid($order);
57+
}
5358

5459
unset($_SESSION['monduOrderUuid']);
5560
}

0 commit comments

Comments
 (0)